3.2. Compiler

SQRESULT sq_compile(HSQUIRRELVM v, const SQChar *s, SQInteger size, const SQChar *sourcename, SQBool raiseerror)
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

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