Author Topic: compiling a script  (Read 2639 times)

0 Members and 1 Guest are viewing this topic.

tflath

  • Guest
compiling a script
« on: May 26, 2002, 02:47:46 AM »
I was just wondering what happens when you compile a script. Are the commands just translated into shorter codes? How is it all put together? And how does the interpreter read the file?



Offline Chris Cromer

Re:compiling a script
« Reply #1 on: May 26, 2002, 02:55:26 AM »
Well I beleive it turns the compiled code into an assembly like languages. Other than that I don't know much about what happens after you compile it.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Brian Provinciano

Re:compiling a script
« Reply #2 on: May 26, 2002, 01:46:44 PM »
In AGI, it is bascily just converted into shorter codes, but not SCI. SCI is very very complicated. It uses a virtual machine which acts just like a PC, or any other computer.

This code...
      = gScore + gScore addScore
      (if(> addScore 0)
         (scoreSound:playMaybe())
      )
Is compiled into this code...
          lsl 15
          lap 1
          add
          sal 15
          lsp 1
          ldi 0
          gt?
          bnt code_05B0
          pushi 131
          pushi 0
          lofsa $0184
          send 4
 code_05B0:
          ret
Which in binary is...
           8B 0F
           87 01
           02
           A3 0F
           8F 01
           34 00 00
           1E
           30 0A 00
           38 83 00
           39 00
           72 D6 FB
           4B 04
           48

I doesn't really matter though, that the compiled code is complicated since the langauge I use it easy. The compiler takes care of the hard stuff.

The scripts are object oriented, split into segments. The scripts have references in the vocabs. The interpreter basicly loads the first instance of script.000 and executes it's play() method. From there, it calls other classes, etc. There's more to it than I can simply explain here. I suggest checking out the FreeSCI docs at http://freesci.linuxgames.com

tflath

  • Guest
Re:compiling a script
« Reply #3 on: May 26, 2002, 10:25:49 PM »
Thanks for the help on that. Just a few more things. Once the script is compiled, does the interpreter execute it line for line? Also, is there a practical purpose for having an interpreter? Wouldn't it make more sense to compile the script so it could be run by itself? Thanks

Offline Brian Provinciano

Re:compiling a script
« Reply #4 on: May 26, 2002, 11:39:51 PM »
Good questions!  :)

The intepreter does execute code line by line, but jumps from class to instance to method to procedures and all over the place, so it could execute 1000 lines of code between one line and another if the line makes a call.

Though it executes line by line, that's not how the programmer sees it. I suppose everything executes line by line no matter how object/event oriented it is. From a programmer's view, code it executed on events. As the programmer, you enter the code executed when the an object is initialzed in the init() method, the code you want to be continually executed in the doit() method, the code that will handle input in the handleEvent() method, etc.

The reason they compiled to scripts rather than actual code is portability. They wrote interpreters to execute the scripts for many platforms. Thanks to Sierra and FreeSCI, if you make a game with SCI Studio, it will be able to run under MS-DOS, Windows, MacOS, Amiga, AtariST, Linux, Solaris, BSD, the handheld iPaq, and more! You as the game developer will only need to compile it once in SCI Studio, and will be able to use it on all of those platforms with the appropriate interpreter.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.046 seconds with 20 queries.