toka.nbk: Home | Index | Next Page: QuotesLibrary | Previous Page: Quotes


 quotes.c

Use

Build, operate on quotes.

Functions Provided

Variables:
  QUOTE quotes[8]
  Holds details about the compiler state, heap,
  etc for quotes during compilation.

  long qdepth
  Tracks how deeply the quotes are nested

  long quote_counter
  Tracks the current loop index

  Inst top
  Holds a pointer to the root quote

begin_quote()
Create a new quote. This allocates space for it,
and sets the compiler flag. A pointer to the
quote's start is pushed to the stack.

end_quote()
Terminate the previously opened quote and perform
data_class() semantics.

invoke()
Call a quote (passed on TOS)

compile()
Compile the code needed to call a quote (passed on TOS)

iterate()
Repeat execution of a quote (passed on TOS), NOS
number of times.

alt_iterate()
Repeat execution of a quote (passed on TOS), NOS
number of times.

truefalse()
Takes three items (true-xt, false-xt, and a flag)
from the stack. Stack should be passed in as:
  flag true false 
It will execute true if the flag is true, false
otherwise.

recurse()
Compiles a call to the top-level quote. As a
trivial example:
  [ dup 1 > [ dup 1 - recurse swap 2 - recurse + ] ifTrue ] is fib

qlit()
Push the value in the following memory location
to the stack. This is used instead of lit() so
that the decompiler (and eventually debugger) can
reliably identify nested quotes as opposed to 
regular literals.

quote_index()
Return the current loop index (counter)

quote_while_true()
Return execution of a quote until the quote
returns FALSE.

quote_while_false()
Return execution of a quote until the quote
returns TRUE.

Primitives Provided

[
]
recurse
i
whileTrue
whileFalse
compile
invoke
iterate
+iterate
ifTrueFalse

toka.nbk: Home | Index | Next Page: QuotesLibrary | Previous Page: Quotes


Notebook exported on Sunday, 1 July 2007, 19:54:43 PM EDT