1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Docs ratchet: public items here predate `missing_docs`. Delete this
// allow once they are documented; new files get the lint by default.
use Instruction;
use Value;
/// On-disk magic for the `.bf` module format (see design notes ยง32).
/// Chosen so a corrupted/truncated file is rejected in the first 4 bytes
/// rather than partway through decoding.
pub const MAGIC: = *b"BFV0";
/// Scalar module header (v5). A list, map, or record raises the header to
/// [`ABI_VERSION_LISTS`], [`ABI_VERSION_MAPS`], or [`ABI_VERSION_RECORDS`].
/// Bump on any breaking change to instruction encoding, constant
/// representation, or function-table layout.
///
/// v2: [`Value::Message`] wire tag `5`.
/// v3: `Message.reply_cap`; [`Value::Cap`] wire tag `6` (FlowCap).
/// v4: [`Value::Str`] tag `7`, [`Value::Bytes`] tag `8`.
/// v5: CapId is 128-bit; `Message.payload` is a nested [`Value`].
/// v6: [`Value::List`] wire tag `9`. Modules without a list still encode
/// as v5 so an older reader keeps accepting them. A list constant is
/// written only as v6; v5 decoders reject tag `9`.
/// v7: [`Value::Map`] wire tag `10`. A module without a map stays on v5 or
/// v6. v5 and v6 decoders reject tag `10`.
/// v8: [`Value::Record`] wire tag `11`. A module without a record stays on
/// v5, v6, or v7. Older headers reject tag `11`.
pub const ABI_VERSION: u32 = 5;
/// ABI that introduces [`Value::List`]. [`encode`](super::encode) emits this
/// when the pool contains a list and no map or record. [`decode`](super::decode)
/// accepts v5 through v8. A v5 header rejects tag `9`.
pub const ABI_VERSION_LISTS: u32 = 6;
/// ABI that introduces [`Value::Map`]. Emitted when a constant contains a
/// map and no record. A map nested in a record is written as
/// [`ABI_VERSION_RECORDS`]. Decode accepts v5 through v8. A header below v7
/// rejects tag `10`.
pub const ABI_VERSION_MAPS: u32 = 7;
/// ABI that introduces [`Value::Record`]. Emitted when a constant contains
/// a record, including one nested in a list, map, or message. Decode accepts
/// v5 through v8. A header below v8 rejects tag `11`.
pub const ABI_VERSION_RECORDS: u32 = 8;
/// A callable entry point inside a [`Chunk`]: either bytecode-defined or a
/// slot reserved for a native (Rust) function registered with the runtime
/// via the FFI table.
/// A compiled unit of Byteflow bytecode: code, constants and the function
/// table. One `Chunk` can back many concurrently-running flows โ it is
/// immutable after construction, so it is shared behind an `Arc` rather than
/// copied per flow (see [`crate::Vm`]).