Skip to main content
gamedev.net
🔒 Locked

Libraries with a scripting language?

Started by Nightition 1 reply 950+ views
Original Post
Nightition
Nightition
Hi, I'm currently designing a scripting language, mostly for learning purposes, which will run under a virtual machine. Now, there is one thing I don't know how to solve - standard library (and other libraries, for that matter). I could implement various functions as 'keywords', that is, make the vm aware of them, and probably provide direct assembler instructions for each of them(since it's a custom-made assembler, used only by vm). But that doesn't really provide much flexibility - each time I want to add a function to the language, I need to change the asm and vm, and the language keyword list grows unacceptably large... Is there a standard way of doing this? Perhaps providing some mechanism of connecting .dll/.so to to the scripting language, so that new libraries can be written in a 'standard' language, and then simply imported to the script? Or can this be done in a simpler way? Thanks, -Ivan
BarsMonster
BarsMonster
I think VM modification is not that bad. If you will provide VM sources, as well as tool for generating this additional code out of some kind of formal description, this will be ok for most of usages.

I'm going to use this approach in my VM.

If you want the possibility to add libraries(DLL) without recompilation of VM, you will be stick with perticular compiller(for VM) and particular OS (windows). Also, you will have some headache while passing parameters of different type, getting return value. There will be a danger of stack corruption (if you pass something wrong).
Nightition
Nightition
I guessed it won't be that easy to implement the system
with dlls, but I thought it would be better than having
a monstrous scripting system with hundreds or thousands
of functions... It's possible (albeit not easy in the
second case) to achieve portability across platforms.

Thanks for suggestions!

Regards,
-Ivan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.