Expand description
Bytecode compiler — walks the AST and emits Op instructions into a Proto.
§Architecture
A single-pass recursive descent over the AST maintains:
- A flat local-variable stack per function (slot numbers are u16).
- A scope depth counter for block exits.
- A list of upvalue descriptors per function (used by
Closure). - Per-loop break/continue patch lists.
Jump offsets are relative (i32): positive = forward, negative = backward.
Structs§
- Chunk
- A compiled function ready for the VM.
- Compiler
- Single-pass bytecode compiler.
- Proto
- A compiled function — the unit of bytecode.
- Upval
Desc - How an upvalue is captured by a closure.
Enums§
- Constant
- A compile-time constant value.
- Instruction
- Runtime instruction set emitted by
Compiler::compile_script. - Op
- VM instruction. Operands are embedded to allow the interpreter to avoid secondary table lookups on the hot path.