Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Extrarius

Creating A Scripting Engine

This topic is 5598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to create a complex scripting engine run by a VM, but I''m having a hard time resolving a few issues: First of all, all the tutorial''s I''ve read use a stack machine and one data type, usually integer. I plan on having integers, a floating point type, and a string type. Should I have a different stack for each type, or would it be more efficient to have a single stack of a base object type and have the variable types derived from that so they could all be pushed and popped on a single stack? It seems like the first method would be best, but as I''ve never done it before I''m not 100% sure. Secondly: I plan on allowing custom types in the scripting language. What is the best way to handle those? I''m not really sure other than possibly treating it as a collection of individual varibles, but pushing 50 different variables on the stack to send to a function (for ex) seems messy and inefficient. Also, it would be nice to be able to pass one of the objects created in script to a game function. Third) What would be the best way to implement arrays in the scripting language? If I go with multiple stacks from #1 should I have a second stack for each type that holds arrays of that type? I want arrays to be dynamically sized and I''m not real sure how I should keep track of that. Fourth, what is the best way to handle function calls? Pushing variables onto the stack wouldn''t work like it does in x86 asm unless I implement a lot of modifiers to be able to access variables from anywhere on the stack instead of just pushing/popping. Is there any easier way that isn''t too slow? I''ve already read most of the tutorials I could find on the internet about scripting languages, including ones here at gamedev.net, on flipcode.com, and at gamasutra.com.

Share this post


Link to post
Share on other sites
Advertisement
It would be nice to see the table of contents and some sample pages, as I''m afraid it will only cover the basics and not help me with the parts I''m having trouble with. Anybody know if the book would help me?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Also, check out "Virtual Machine Design and Implementation in C/C++" by Bill Blunden. It covers everything you''re looking for at the virtual machine level, but there''s no HLL included, just an assembler.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Look up ''Compilers: Principles, Techniques, and Tools'' by Aho, Sethi, and Ullman.

I am working on something that is similar. Feel free to check out my source code at

http://sourceforge.net/projects/saquen/

-D

Share this post


Link to post
Share on other sites
From my bookmarks: link.

While this isn''t about scripting engines, it will give you a complete understanding of how to implement things (like function calls) in a stack based environment.

Share this post


Link to post
Share on other sites
Extarius:
Gamescripting Mastery would definetly answer most of your questions. It details how to implement data types, stacks, method calls, and arrays. It doen't cover custom types though. On the whole it is a very good book, and I would definetly recommend it. The other books mentioned "Virtual Machine Design and Implementation in C/C++" and "Compilers: Principles, Techniques, and Tools" are very good as well. Yet for your needs I would definelty go with GameScripting Mastery.....


[edited by - PaleRaider on January 22, 2003 7:56:32 PM]

Share this post


Link to post
Share on other sites
I can really recommend the tutorial series at
http://www.peroxide.dk

Brilliant stuff and it implements int, bool and string types on a single stack (double type is easy to add, I''ve done it in under a half an hour). the tutorial on the VM isn''t finished yet though.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Is there a good reason you''re not using Lua or Python?

Life is shorter than you think...

Share this post


Link to post
Share on other sites
2 Main Reasons: I don't like either language, and I wouldn't learn as much using other people's code (not that I have anything against using libraries, but I like to understand whats going on under the hood first). Also, neither language would fit my needs as well as a language designed specifically to meet them.

I'm only 18, I've got the time =-P Would probably be a lot easier after I get my CS degree, but I don't want to wait till then (and really it might not help, so far I've taken 3 programming classes and none of them exposed me to anything new, taking data structures now and it doesn't seem like it will either since I've already messed around with linked lists, binary trees, sorting, etc)

[edited by - Extrarius on January 23, 2003 6:54:26 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!