SGScript Metaprogramming helper library

Table of Contents


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):

include "sgsmeta";

SGScript API



meta_globals [function]


load all global constants

meta_unpack [function]

meta_unpack( string bytecode_buffer )

parse a bytecode buffer

The structure of a function:

The structure of a constant:

The structure of an instruction:

meta_opname [function]

meta_opname( int id )

retrieve bytecode instruction name by ID

meta_opname( 0 ); // returns "nop"

SI_ [constants]

SGScript instruction code/type/ID constants.

These constants are only available if meta_globals is called first.