The goal of this library is to provide further tools for handling the compilation part of SGScript. Specifically, this library implements bytecode parsing.
The library is compiled to a 'sgsmeta' shared library so it can be included this way (assuming that, on Linux and similar systems, LD_LIBRARY_PATH is set correctly):
dict variable, environment can be altered by setting
The structure of a function:
array consts -- contains a list of parsed constants for the function
array code -- contains a list of parsed instructions for the function
array lines -- contains a list of line numbers for the instructions, array size should be equal to that of instruction array
bool gotthis -- whether
this is required (should be false for root function)
int numargs -- number of input arguments (should be 0 for root function)
int numtmp -- number of temporary variables in function
int numclsr -- number of closures required in function
int inclsr -- number of incoming closures (not generated by the function)
string name -- name of the function ("<main>" for root function)
int line -- first line number of function definition (0 for root function)
The structure of a constant:
int type -- base type ID of constant, should be one of SVT_[NULL|BOOL|INT|REAL|STRING|FUNC]
var data -- variable in the previously specified type or a parsed function in the case of SVT_FUNC
The structure of an instruction:
meta_opname( 0 ); // returns "nop"
SGScript instruction code/type/ID constants.
These constants are only available if meta_globals is called first.
foreach loop, retrieving the iterator