Compiler and static analysis
Turning source into a closure, and configuring the diagnostics that run with it.
Compiler
sq_compile is enough for most hosts. It takes a buffer and leaves a callable closure on the stack. The AST entry points below it are for tools that want the tree: a formatter, a coverage pass, an analyzer run without codegen. They follow the pipeline the compiler uses internally: parse, analyze, translate.
Compiles a source buffer and pushes the result as a closure; the top-level statements run when that closure is called. Compiling can run a pure call with constant arguments, and an error in that call fails the compile.
Parses source into an AST without generating bytecode.
Generates a closure from an AST already parsed and analyzed.
Runs the static analyzer over an AST and reports its diagnostics.
Makes the compiler report trailing whitespace as a diagnostic.
Returns the list of modules a compiled unit imports.
Frees the import list returned by sq_getimports.
Writes a parsed AST as an indented text tree.
Writes a parsed AST as one line of JSON for a tool.
Writes the bytecode of a compiled closure in readable form.
Allocates the arena an AST lives in. Release it with sq_releaseASTData.
Frees an AST arena and everything allocated from it.
Turns one compilation option on or off for this VM.
Reports whether a compilation option is on.
Turns on recording of where a container field was last written, for debugging.
Reports whether this build was compiled with variable tracing.
Makes the compiler emit line information inside expressions, for finer error positions.
Enable/disable the error callback notification of handled exceptions.
Sets the compiler error handler function.
Sets the compiler diagnostic callback function.
Gets the current compiler error handler function.
Sets the seed that randomizes table iteration order, which keeps scripts from depending on it.
Static analysis
Diagnostic state is process-wide, not per VM, so a host configures it once at startup. A diagnostic can be addressed by name or by number. sq_printwarningslist writes the full set.
Returns every diagnostic to its default state.
Loads analyzer settings from a file.
Loads analyzer settings from an already parsed key-value file.
Turns one diagnostic on or off by name.
Turns one diagnostic on or off by number.
Writes every diagnostic the analyzer knows, as --warnings-list does.
Turns the syntax-level warnings on or off.
Reports uses of global names that no compilation unit defines.
Adds a bindings object's names to the set sq_checkglobalnames accepts.