pub struct Compiler { /* private fields */ }Expand description
Compiles an AST into bytecode.
Implementations§
Source§impl Compiler
impl Compiler
pub fn new() -> Self
Sourcepub fn compile(self, program: &[SNode]) -> Result<Chunk, CompileError>
pub fn compile(self, program: &[SNode]) -> Result<Chunk, CompileError>
Compile a program (list of top-level nodes) into a Chunk. Finds the entry pipeline and compiles its body, including inherited bodies.
Sourcepub fn compile_named(
self,
program: &[SNode],
pipeline_name: &str,
) -> Result<Chunk, CompileError>
pub fn compile_named( self, program: &[SNode], pipeline_name: &str, ) -> Result<Chunk, CompileError>
Compile a specific named pipeline (for test runners).
Source§impl Compiler
impl Compiler
Sourcepub fn compile_fn_body(
&mut self,
params: &[TypedParam],
body: &[SNode],
source_file: Option<String>,
) -> Result<CompiledFunction, CompileError>
pub fn compile_fn_body( &mut self, params: &[TypedParam], body: &[SNode], source_file: Option<String>, ) -> Result<CompiledFunction, CompileError>
Compile a function body into a CompiledFunction (for import support).
This path is used when a module is imported and its top-level fn
declarations are loaded into the importer’s environment. It MUST emit
the same function preamble as the in-file Node::FnDecl path, or
imported functions will behave differently from locally-defined ones —
in particular, default parameter values would never be set and typed
parameters would not be runtime-checked.
source_file, when provided, tags the resulting chunk so runtime
errors can attribute frames to the imported file rather than the
entry-point pipeline.