maat_bytecode 0.12.0

Bytecode format and serialization for the Maat virtual machine
Documentation

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);