Skip to main content

Crate brik64_bir

Crate brik64_bir 

Source
Expand description

§brik64-bir

Embeddable BRIK-64 BIR (BRIK Intermediate Representation) bytecode runtime.

BIR is the portable bytecode format produced by the brikc compiler. This crate lets you load and execute BIR programs from any Rust project without needing the full compiler toolchain.

§Format

BIR is a line-based text format. Each line is one instruction:

FUNCTION fn::main [] -> i64
  CONST $0 42
  RETURN $0
END

§Usage

use brik64_bir::{BirModule, BirInterpreter};

let bir_source = std::fs::read_to_string("program.bir").unwrap();
let module = BirModule::parse(&bir_source).unwrap();
let mut interp = BirInterpreter::new(module);
let exit_code = interp.run("fn::main", &[]).unwrap();
println!("Exit code: {}", exit_code);

Re-exports§

pub use interpreter::BirInterpreter;
pub use module::BirModule;
pub use value::Value;

Modules§

interpreter
BIR interpreter.
module
BIR module — parsed representation of a BIR program.
value
BIR value types.