Skip to main content

Crate maat_bytecode

Crate maat_bytecode 

Source
Expand description

Bytecode representation for the Maat virtual machine.

This crate provides a compact bytecode format for representing Maat programs. Instructions consist of an opcode byte followed by zero or more operand bytes, with all multi-byte operands encoded in big-endian format.

§Example

use maat_bytecode::{Instructions, Opcode, encode};

// Encode some bytecode instructions
let const_instr = encode(Opcode::Constant, &[0]);
let add_instr = encode(Opcode::Add, &[]);

// Combine into an instruction sequence
let mut bytecode = Instructions::from(const_instr);
bytecode.extend(&Instructions::from(add_instr));

// Display as disassembly
println!("{}", bytecode);

Structs§

Bytecode
Compiled bytecode output containing instructions and constants.
Instruction
Tracks the most recently emitted instruction for peephole operations.
Instructions
A sequence of bytecode instructions.

Enums§

Opcode
Bytecode operation codes.
TypeTag
Type tags for the OpConvert instruction operand.

Constants§

MAX_CONSTANT_POOL_SIZE
Maximum number of constants in the constant pool.
MAX_ENUM_VARIANTS
Maximum number of variants an enum may have.
MAX_FRAMES
Maximum number of call frames on the VM’s frame stack.
MAX_GLOBALS
Maximum number of global variable bindings.
MAX_LOCALS
Maximum number of local variable bindings per function scope.
MAX_STACK_SIZE
Maximum number of elements that can be pushed onto the VM’s stack.

Functions§

decode_operands
Decodes operands from an instruction byte slice.
encode
Encodes a bytecode instruction from an opcode and operands.