Tcl Compiler
This is the compiler portion of ParTcl.
(int register_num, string pir_code) = compile(int register_num, string tcl_code)
- Parses the Tcl code and returns generated PIR code.
- Argument register_num is the first register number that is available for use by the generated PIR.
- Return register_num is the register number that contains the result of this code.
(int register_num, str code) = compile_dispatch(int register_num, pmc thing)
- Given an object,
call its compile method,
or,
if it's constant,
generate code on its behalf.
Returns PIR code.
- Argument register_num is the first register number that is available for use by the generated PIR.
- Return register_num is the register number that contains the result of this code.
(pmc invokable) = pir_compiler(int register_num, string PIR)
(string code) = pir_compiler(int register_num, string PIR, 1)
- A thin wrapper for the <compreg>'d PIR compiler.
Given inline PIR code,
wrap it in anonymous subroutine and return the fully qualified PIR.
- If the third argument is present,
don't compile the wrapper sub,
just return the wrapped code.
- Argument register_num is the first register number that is available for use by the generated PIR.
A helper object for managing tcl compilation.
- int add_code(string)
- compile the given string as tcl code.
Return the register that the result is stored in.
- int add_expression(string)
- compile the given string as an [expr]ession.
Return the register that the result is stored in.
- add_pir(string)
- add the raw PIR to be executed.
- defer_pir(string)
- add the raw PIR to be added at the end.
(For [proc],
[exec],
etc.)
- set_result_register(int)
- If this is set,
the final result of the generated sub is this register.
- int get_result_register()
- __get_string()
- should only be called at the end of the compile cycle.
Generates a PIR string containing all the code (immediate and deferred).
- execute()
- Compile and execute the code associated with this compiler object.