maat_bytecode
Bytecode format and serialization for the Maat virtual machine.
Role
maat_bytecode defines the complete instruction set for the Maat VM: opcodes, their operand widths, and the encode/decode functions that serialize instructions to a compact byte stream. The Bytecode struct bundles the encoded instructions, a constant pool, a type registry, and a SourceMap into a single artifact that is passed to maat_vm for execution or maat_trace for trace-generating execution.
Usage
use ;
// Encode individual instructions
let load_const = encode; // load constant at index 1
let add = encode;
// Combine into an instruction sequence
let mut instructions = from;
instructions.extend;
// Human-readable disassembly
println!;
Limits
| Limit | Value | Constraint source |
|---|---|---|
| Constant pool size | 65,535 | 2-byte Constant operand |
| Enum variants | 256 | 8-bit tag in Construct |
| Stack depth | 2,048 | MAX_STACK_SIZE |
| Global bindings | 65,535 | 2-byte SetGlobal/GetGlobal |
API Docs
Repository
github.com/maatlabs/maat. See the project README for an overview of the full compiler pipeline.