Skip to main content

Module bytecode

Module bytecode 

Source
Expand description

The bytecode representation of a function.

Compilation happens in two phases, exactly as in the reference implementation:

  • Unresolved ([FunctionBuilder]): jump targets are label ids and every variable is still described by its declaration, not its storage class.
  • Resolved (Function): jump targets are byte offsets and every variable reference names its storage class (arg, loc, var_ref or var), so the bytecode can be executed and serialised.

The split matters for testing: each phase can be compared against the corresponding pass of the reference compiler.

Structs§

ClosureVar
One captured variable of a function.
EvalSite
One direct eval(...) call site and the bindings visible at it.
EvalVisible
One binding an eval can see.
Function
A compiled function.
Instruction
A resolved instruction: opcode plus the operands encoded in its payload.
LineCol
A stretch of bytecode and the source position it came from.
VarDef
A declared variable: an argument or a local.

Enums§

Atom
One entry of a function’s atom table.
ClosureType
Where a captured variable actually lives, and therefore how a closure reaches it.
Constant
A constant in the pool.
FunctionKind
How a function was declared. Determines the calling convention.
Operand
An operand of an instruction during compilation, before addresses are known.
Storage
Where a variable lives in the resolved function.
VarKind
What a declared name is used for, which decides how it is displayed and how the function prologue initialises it.