Jump to content
  • Advertisement


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


script compiling to linked list...

This topic is 5842 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

Hello! i want to create a realy simple script system. It need to be fast, but i dont want to compile to machine code. first i could parshe my script into bytecode, and then have alot of switch states, that selected the right action... BUT! wouldnt it be faster if i created a class for each function, and then linked listed them:
class Base{ 
      virtual void do_something(void)=0;
      Base *next;//set to 0 by constructor

class DoLookAtThing : public Base{
      short data_for_this_function;//set by constructor

      void do_something(void){
           //Look at thing

           if (next!=0){next->do_something();};
I think i need 100 - 200 commands, and all the data will be stored in the command class... (no need for variables) would this be fast? is there a better way to compile from script to functions?

Share this post

Link to post
Share on other sites
Use switch. As long as the switch values are sequential, it''ll be compiled into a fast lookup-table. Look up some CPU emulator sources for inspiration.

2DNow - Specializing in yesterday''s technology today!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!