Skip to main content

Module compiler

Module compiler 

Source
Expand description

AST → bytecode compiler.

Compiles a checked vibe::ast::Program into a Chunk. The compiler walks each function body and top-level statement, emitting stack-based opcodes. Local variables are assigned slot indices; string and IRI literals are interned into the constant pool.

§Compilation model

  • Each user function gets a FuncMeta entry and a code region.
  • Top-level statements are emitted into a preamble that runs before any function call.
  • Control flow uses forward/backward jumps with patching.
  • return emits Op::Return; falling off the end of a function emits Op::ReturnNull.

Enums§

CompileError
Compiler error.

Functions§

compile
Compile a full Program AST into a Chunk.
compile_expr
Compile a single expression (for cell bodies) into a Chunk. The chunk’s preamble evaluates the expression and returns it.