Thread: More random thoughts on constructing scripting languages.

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    106

    More random thoughts on constructing scripting languages.

    Because I'm insane and ZOMG FREEWARE3D MMORPG is so lame by now.

    from what I've heard, a virtual machine is at the core of a scripting language, and it interprets scripts and converts them into bytecode. However, I'm not particularly sure WHAT bytecode is, and what the conversion to it entails. The tutorial I found creates a virtualMachine class, which contains script objects (which contain instruction objects), and then parses them with a bunch of switch statements. This is a bit of an understatement, but it (hopefully) conveys the basic idea.

    Problem is, I don't really get how this converts anything to bytecode. Is this not actually a virtual machine, per, se, but an emulator of one?

    Also, if anyone has any articles on this, I'd love to see them. Googling's just returned a ton of stuff about the Java Virtual Machine, and don't really help me much.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Byte code are bytes which represent instructions for the virtual machine to carry out. If you wanted the value 0x01 to tell the virtual machine to quit then you would likely have something like
    Code:
    if (Byte==0x01)
       Quit();
    To create the Byte code you might do something like this
    Code:
    if (!strcmpi(Command, "Quit"))
       Byte=0x01;
    The virtual machine would be an emulator if it was designed to do the job of a system which allready exists such as game console emulators which read in ROMs and try to proecess them in the same way the console dose.
    Last edited by Quantum1024; 01-21-2006 at 01:24 AM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    An implementation of the parser/interperter for Javascript, you may find some design info listed somewhere on the site.
    http://www.mozilla.org/js/spidermonkey/

    Perhaps a better google?
    http://www.google.co.uk/search?q=par...reter+bytecode

    Some other stuff
    http://www.bloodshed.net/compilers/index.html#tutorials
    http://www.amazon.com/gp/product/047...lance&n=283155
    http://en.wikipedia.org/wiki/Compiler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 08:16 AM
  2. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 05:51 PM
  4. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 02:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM