« Previous: Execution Engines · Guide Index · Next: Command-Line Interface »
Beyond running source directly, QuantoScript can compile a program ahead of time — either to portable bytecode or to a native binary.
qs build compiles a .qs file to a .qvm bytecode file:
qs build program.qs # writes program.qvm
qs build program.qs -o custom.qvm # custom output pathRun the compiled file with the VM:
qs run program.qvm
qs vm program.qvmCompiling ahead of time gives faster startup and lets you distribute a program without shipping its source.
A .qvm file begins with a magic header and a format version, and carries a
CRC32 checksum of the source. The loader validates the header, the version, and
the checksum, and reports a clear error on malformed files.
Disassemble a program for debugging:
qs vm --dump-bytecode program.qsThe native compiler emits C for a subset of the language, which you can build with any C compiler:
qs native program.qs # emits a_native.c
gcc -O2 a_native.c -o program_native # build it
./program_nativeOr let qs compile do both steps:
qs compile program.qs # writes a.exe (a.out on Unix); pass an output path to change itqs compile needs two things: a C compiler (gcc) on your PATH, and the
QuantoScript runtime sources (quanto.c and src/parts/). The sources are
looked up next to the installed binary, under QUANTO_HOME, and in the current
directory tree; if you keep them somewhere else, point QS_SOURCE_DIR at the
directory that contains quanto.c.
- Integer arithmetic
if/elsewhileandrepeat- Variable assignment
print
Functions, strings, lists, maps, closures, classes, and exceptions are outside the native path. For everything else, run on the interpreter or the bytecode VM.
Command-Line Interface lists every command and flag.
« Previous: Execution Engines · Guide Index · Next: Command-Line Interface »