plotnik_bytecode/bytecode/constants.rs
1//! Bytecode format constants.
2
3/// Magic bytes identifying a Plotnik bytecode file.
4pub const MAGIC: [u8; 4] = *b"PTKQ";
5
6/// Current bytecode format version.
7/// v2: Removed explicit offsets (computed from counts), added regex section.
8/// v3: Removed flags field (unlinked mode).
9pub const VERSION: u32 = 3;
10
11/// Section alignment in bytes.
12pub const SECTION_ALIGN: usize = 64;
13
14/// Step size in bytes (all instructions are 8-byte aligned).
15pub const STEP_SIZE: usize = 8;
16
17/// Maximum payload slots for Match instructions.
18///
19/// Match64 (the largest variant) supports up to 28 u16 slots for
20/// effects, neg_fields, and successors combined. When an epsilon
21/// transition needs more successors, it must be split into a cascade.
22pub const MAX_MATCH_PAYLOAD_SLOTS: usize = 28;
23
24/// Maximum pre-effects per Match instruction.
25///
26/// Pre-effect count is stored in 3 bits (max 7). When exceeded,
27/// overflow effects must be emitted in leading epsilon transitions.
28pub const MAX_PRE_EFFECTS: usize = 7;