SAPI - CLI

The CLI sapi is the default sapi. It is called by do_exec() in /src/main/commands/exec.c. It checks the argument list for a file to load. Loads it, converts it to bytecode.

Then it will start up the VM through vm_init() with the runmode VM_RUNMODE_CLI. However, when we have specified the debug flag -d on the command line, the VM_RUNMODE_DEBUG will be added too (it’s a bitwise-flag or’ed with the runmode). This allows the VM to start debugging.

We create (as usual) a context, codeblock and stackframe and execute that frame. Once finished, we destroy everything and exit.