pub struct Program { /* private fields */ }Expand description
Implementations§
Source§impl Program
impl Program
Sourcepub fn resolve_address(&self, id: DefinitionId) -> Option<(u32, usize)>
pub fn resolve_address(&self, id: DefinitionId) -> Option<(u32, usize)>
Resolve a definition ID to (container_idx, byte_offset).
Sourcepub fn container_bytecode(&self, idx: u32) -> &[u8] ⓘ
pub fn container_bytecode(&self, idx: u32) -> &[u8] ⓘ
Get a container’s bytecode by index.
Sourcepub fn container_count(&self) -> u32
pub fn container_count(&self) -> u32
Number of containers.
Sourcepub fn source_checksum(&self) -> u32
pub fn source_checksum(&self) -> u32
CRC-32 checksum from the source .inkb, used for transcript validation.
Sourcepub fn find_address(&self, path: &str) -> Option<(u32, usize)>
pub fn find_address(&self, path: &str) -> Option<(u32, usize)>
Resolve a qualified ink path to its (container_idx, byte_offset).
Supports knot names (intro), qualified stitches (knot.stitch), and,
for programs compiled by brink-compiler, author labels
(knot.label, knot.stitch.label). Programs without the compiler’s
address_paths table (legacy .inkb or converter output) resolve
knot/stitch scope paths only. Use this to spawn flows at named entry
points:
if let Some((idx, _)) = program.find_address("intro_scene") {
let (flow, ctx) = FlowInstance::new_at(program, idx);
}Sourcepub fn global_defaults(&self) -> Vec<Value>
pub fn global_defaults(&self) -> Vec<Value>
Build the initial globals vector from slot defaults.
Sourcepub fn global_index(&self, name: &str) -> Option<u32>
pub fn global_index(&self, name: &str) -> Option<u32>
Find the global variable slot index for a variable name, if declared.
Used by host-facing variable get/set (Story::variable/set_variable).
Sourcepub fn global_name(&self, idx: u32) -> Option<&str>
pub fn global_name(&self, idx: u32) -> Option<&str>
Resolve a global slot index to its variable name.
Sourcepub fn global_count(&self) -> u32
pub fn global_count(&self) -> u32
Number of global variable slots.
Sourcepub fn list_members(&self, list: &ListValue) -> Vec<ListMember>
pub fn list_members(&self, list: &ListValue) -> Vec<ListMember>
Resolve the active members of a list value for host-facing display: each member’s origin list name, unqualified item name, and ordinal. Sorted the same way in-story list stringification orders them (ordinal, then origin name) so the two presentations agree.
Sourcepub fn divert_target_path(&self, id: DefinitionId) -> Option<String>
pub fn divert_target_path(&self, id: DefinitionId) -> Option<String>
The qualified knot/stitch path a DefinitionId names, if it resolves
to a named scope entry (offset-0 in address_by_path) — the
destination of a Value::DivertTarget for host-facing display.
Deterministic on collision: shortest path, then lexicographically
smallest, independent of the map’s iteration order (mirrors
debug::NameResolver’s reverse lookup).