The LiveCode Builder Virtual Machine is a infinite register machine with a high-level and verifiable bytecode.
All bytecode runs in the context of a module instance with executing handlers forming a stack of activation frames. Each frame contains an array of registers, the first part of which are parameters followed by handler-local variables and bytecode block registers.
Most bytecode operations operate directly on registers, access to module level definitions (handlers, constants, variables) are indirected through the fetch and store operations.
Each bytecode operation has an address which can be jumped to using the jump operations.
jump <label>
The jump operation sets the address of the next instruction to execute to that identified by
jump_if_false <register>, <label>
The jump_if_true operation checks the value in
If is a runtime error if
jump_if_true <register>, <label>
The jump_if_true operation checks the value in
If is a runtime error if
assign_constant <register>, <constant>
The assign_constant operation copies
If
assign <dst-register>, <src-register>
The assign operation copies the value in
If
return [ <result-reg> ]
The return operation exits the current handler, returning to the instruction after
the invoke operation which created it. If present, the value in
If
It is a runtime error if the type of the return value does not conform to the return type of the current handler's signature.
It is a runtime error if any out or inout parameters are unassigned at the point of return.
invoke <handler>, <result-reg>, <arg1-reg>, ..., <argn-reg>
The invoke operation creates a new frame copying values from the argument registers for any in or inout parameters. It then starts executing the bytecode attached
If is a runtime error if the number of arguments provided is different from the
If it a runtime error if for in and inout parameters, the contents of The invoke indirect operation functions identically to the invoke operation
The fetch operation copies the value of It is a runtime error if the type of the value of The store operation copies the contents of It is a runtime error if the type of the value in The assign_list operation builds a list value from It is a runtime error if the type of The assign_array operation builds an array value from each key value pair
It is a runtime error if the type of The reset operation performs default initialization of Invoke Indirect
invoke <handler-reg>, <result-reg>, <arg1-reg>, ..., <argn-reg>
Fetch
fetch <dst-register>, <definition>
Store
store <src-register>, <definition>
Assign List
assign_list <dst-reg>, <element1-reg>, ..., <elementn-reg>
Assign Array
assign_array <dst-reg>, <key1-reg>, <value1-reg>, ..., <keyn-reg>, <valuen-reg>
Reset
reset <reg>