3.2. Compiler

SQRESULT sq_compile(HSQUIRRELVM v, const SQChar *s, SQInteger size, const SQChar *sourcename, SQBool raiseerror, const HSQOBJECT *bindings = nullptr)
Parameters
  • v (HSQUIRRELVM) – the target VM

  • s (const SQChar*) – a pointer to the buffer that has to be compiled.

  • size (SQInteger) – size in characters of the buffer passed in the parameter ‘s’.

  • sourcename (const SQChar*) – the symbolic name of the program (used only for more meaningful runtime errors)

  • raiseerror (SQBool) – if this value true the compiler error handler will be called in case of an error

  • *bindings (const HSQOBJECT) –

    optional compile-time bindings object (default: nullptr)

Returns

a SQRESULT. If the sq_compile fails nothing is pushed in the stack.

Remarks

in case of an error the function will call the function set by sq_setcompilererrorhandler().

compiles a quirrel program from a memory buffer; if it succeeds, push the compiled script as function in the stack.

void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable)
Parameters
  • v (HSQUIRRELVM) – the target VM

  • enable (SQBool) – if true enables the debug info generation, if == 0 disables it.

Remarks

The function affects all threads as well.

enable/disable the debug line information generation at compile time.

void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable)
Parameters
  • v (HSQUIRRELVM) – the target VM

  • enable (SQBool) – if true enables the error callback notification of handled exceptions.

Remarks

By default the VM will invoke the error callback only if an exception is not handled (no try/catch traps are present in the call stack). If notifyallexceptions is enabled, the VM will call the error callback for any exception even if between try/catch blocks. This feature is useful for implementing debuggers.

enable/disable the error callback notification of handled exceptions.

void sq_setcompilererrorhandler(HSQUIRRELVM v, SQCOMPILERERROR f)
Parameters
  • v (HSQUIRRELVM) – the target VM

  • f (SQCOMPILERERROR) – A pointer to the error handler function

Remarks

if the parameter f is NULL no function will be called when a compiler error occurs. The compiler error handler is shared between friend VMs.

sets the compiler error handler function

SQCOMPILERERROR sq_getcompilererrorhandler(HSQUIRRELVM v)
Parameters
  • v (HSQUIRRELVM) – the target VM

Returns

a pointer to the current compiler error handler function, or NULL if no function is set

gets the current compiler error handler function

void sq_setcompilerdiaghandler(HSQUIRRELVM v, SQ_COMPILER_DIAG_CB f)
Parameters
  • v (HSQUIRRELVM) – the target VM

  • f (SQ_COMPILER_DIAG_CB) – A pointer to the diagnostic callback function

Remarks

if the parameter f is NULL no function will be called when a compiler diagnostic occurs.

sets the compiler diagnostic callback function