A type of computer language like Forth or the HP series of calculators' RPL (Reverse Polish Lisp). TILs are generally extremely small -- the inner interpreter is usually just several tens of bytes long; they're also reasonably fast (for interpreted languages).

In a TIL, a compiled word is just a list of addresses of words it should call; a primitive word is actually executable machine code. To execute any word, the inner interpreter (called SEMI in Forth, for obscure reasons) just jumps to that word's action address. For a primitive, this is the address of the first instruction to execute; for a compiled word, this is the address of another part of the inner interpreter, which just pushes a return address and executes all the words in the list. So a definition like ": foo bar baz quux ;" compiles a word named foo to be the list of addresses (bar,baz,quux).

In order to compile a literal (like the 2 in ": double 2 * ;"), the address of the primitive LITERAL is compiled into the code, followed by the value of the literal. The word LITERAL adjusts the top of the return address stack past the literal value, then gets the literal value and places it on the data stack.

Even control flow is handled in a similar manner: when a control flow word (like IF) is encountered, it is marked by a special IMMEDIATE bit which tells the compiler to execute it immediately (rather than put its address on the word's list). The word IF compiles the word (IF) (which handles the branching at runtime), leaving 2 space addresses (for the ELSE branch, and past the IF) free immediately after it. The address of this space is left on the return stack; ELSE and THEN fill them in appropriately.

TILs typically (always?) provide primitives to use a stack machine. For instance, a literal will be pushed to the stack, and the word "*" typically pops that top 2 elements of the stack and pushes their product to the stack. It makes the required primitives a lot simpler. But this is not necessary -- just usual.

Log in or registerto write something here or to contact authors.