toka.nbk: Home | Index | Next Page: TimeLibrary | Previous Page: StructLibrary
Toka relies on call threading. This is an implementation technique in which a list of addresses is compiled. Each of these is then called in sequence. The model is similar to direct threading in the Forth world.
There is one special address which marks the end of a threaded sequence. This address is 0.
As an example of this, consider the following quote:
[ a b c 1 2 + . ]
This is compiled into a list of addresses:
a, b, c, lit, 1, lit 2, +, ., 0
Note the special form for numbers. The lit() function pushes the value in the following cell to the stack.
When this quote is invoked, a will be called. After it finishes executing, b will be called, and so on until 0 is encountered. At that point, the vm_run() function exits.
toka.nbk: Home | Index | Next Page: TimeLibrary | Previous Page: StructLibrary
Notebook exported on Sunday, 1 July 2007, 19:54:43 PM EDT