Lua.Compiler.Bytecode (Lua v1.0.0-rc.1)
View SourceBytecode encoder for Lua.Compiler.Prototype.
Walks the structured instruction stream of a prototype and emits a dense
tuple-of-tuples encoding suitable for Lua.VM.Dispatcher. Integer opcode
tags occupy slot 1 of each opcode tuple; operands follow in fixed slots.
Returns {:ok, prototype} with bytecode populated when every instruction
in the prototype falls within the dispatcher's coverage. Returns
:fallback the first time an uncovered opcode is encountered — the caller
keeps the prototype as-is, and the interpreter handles it.
Sub-prototypes are compiled independently. A parent that contains an uncovered opcode falls back to interpretation even when its sub-prototypes successfully compile, and vice versa.
Summary
Functions
Compile a prototype, populating its bytecode field on success.
Functions
@spec compile(Lua.Compiler.Prototype.t()) :: Lua.Compiler.Prototype.t()
Compile a prototype, populating its bytecode field on success.
Sub-prototypes are compiled recursively; each is independent. A failure in one sub-prototype does not block another from being compiled.
The parent prototype only gains a bytecode encoding if every instruction in its own body is supported. If the parent falls back, sub-prototype encodings are still preserved on the children.
@spec op_load_constant() :: pos_integer()