Skip to main content

byteflow/bytecode/
mod.rs

1//! Instruction set, `.bf` (BFV0) wire format, assembler and verifier.
2//!
3//! Pure data plane — no threads, no mailboxes. The scheduler and VM consume
4//! [`Chunk`] values produced here.
5//!
6//! | Piece | Purpose |
7//! |-------|---------|
8//! | [`Opcode`] / [`Instruction`] | ISA (opcodes are **append-only**) |
9//! | [`Value`] / [`Message`] | Runtime / constant-pool tags (ABI versioned) |
10//! | [`Program`] / [`Fn`] | Host-side assembler with named registers |
11//! | [`encode`] / [`decode`] | `.bf` module bytes (`MAGIC` + [`ABI_VERSION`]) |
12//! | [`verify`] | Structural checks before a [`crate::Runtime`] starts |
13//!
14//! Headers: [`ABI_VERSION`] (scalars, v5), [`ABI_VERSION_LISTS`] (v6),
15//! [`ABI_VERSION_MAPS`] (v7), and [`ABI_VERSION_RECORDS`] (v8). [`encode`]
16//! writes the oldest of these that can hold the constant pool. [`decode`]
17//! accepts all four.
18
19mod asm;
20pub(crate) mod builder;
21mod cap;
22mod chunk;
23mod disasm;
24mod format;
25mod instruction;
26mod opcode;
27mod pattern;
28mod program;
29mod restart;
30mod value;
31mod verify;
32
33pub use asm::{assemble, AssembleError};
34pub use cap::{
35    Cap, CapId, CapIdError, CapRights, CapTarget, NativeIdx, NativeMask, RevocationCell,
36};
37pub use chunk::{
38    Chunk, FunctionDef, ABI_VERSION, ABI_VERSION_LISTS, ABI_VERSION_MAPS, ABI_VERSION_RECORDS,
39    MAGIC,
40};
41pub use disasm::disassemble;
42pub use format::{decode, decode_with, encode, FormatError};
43pub(crate) use format::{decode_value, encode_value, MAX_VALUE_DEPTH};
44pub use instruction::Instruction;
45pub use opcode::{IntCmp, Opcode};
46pub use pattern::payload_matches;
47pub use program::{Fn, FuncId, Label, Program, Reg, RegWindow};
48pub use restart::RestartPolicy;
49pub use value::{
50    MapKey, Message, Value, MAX_LIST_LEN, MAX_MAP_LEN, MAX_RECORD_LEN, TAG_SYS_AWAIT, TAG_SYS_DOWN,
51    TAG_SYS_EXIT,
52};
53pub use verify::{verify, verify_with, ConstantKind, TrustLevel, VerifyConfig, VerifyError};