maat_codegen
Bytecode code generation for the Maat programming language.
Role
maat_codegen translates a type-checked AST into Bytecode in a single deterministic pass. The Compiler manages a scope stack, a constant pool, a symbol table (SymbolsTable), and a type registry for user-defined structs and enums. It emits stack-based opcodes for arithmetic, control flow, closures, and heap-allocated compound values. The output Bytecode is self-contained and ready for maat_vm or maat_trace.
Usage
use Compiler;
use MaatLexer;
use MaatParser;
let source = "fn add(a: i64, b: i64) -> i64 { a + b }";
let mut p = new;
let program = p.parse;
let mut c = new;
c.compile_program?;
let bytecode = c.bytecode?;
// The bytecode can be passed directly to the VM or trace VM
// maat_vm::VM::new(bytecode).run()
// maat_trace::run_trace(bytecode)
API Docs
Repository
github.com/maatlabs/maat. See the project README for an overview of the full compiler pipeline.