[−][src]Module haru::compiler
Provides a compiler for executing a program and running in the virtual machine.
Example for emitting bytecode for the program print('Hello World')
:
use haru::ast; use haru::vmbindings::vm::{Vm, VmOpcode}; use haru::compiler::Compiler; let mut c = Compiler::new(); let prog = ast::grammar::start("print('Hello World')\n").unwrap(); for stmt in prog { stmt.emit(&mut c); } c.vm.code.push(VmOpcode::OP_HALT);
Structs
Compiler | Compiler for processing AST nodes and executing generated bytecode in a virtual machine. |
SourceMap | Mapping for a source code range to bytecode range. |
Type Definitions
ArrayIndexRange | Indexed range for a stream of source code or bytecode. |