pub struct ResolvedPolicy { /* private fields */ }Expand description
Fast, id/slot-based resolution of a WorldPolicy against a specific
Program. Built once at World creation via
ResolvedPolicy::resolve; consulted on every state access (from F2.2
on) with O(1) lookups — no string matching on the hot path.
Implementations§
Source§impl ResolvedPolicy
impl ResolvedPolicy
Sourcepub fn all_world() -> Self
pub fn all_world() -> Self
The all-World resolved policy — no name lookups needed. This is
the fast path for WorldPolicy::default() and the only policy
exercised by the oracle-anchored single-flow path.
Sourcepub fn resolve(
program: &Program,
policy: &WorldPolicy,
) -> Result<Self, PolicyError>
pub fn resolve( program: &Program, policy: &WorldPolicy, ) -> Result<Self, PolicyError>
Resolve a host-facing WorldPolicy against a linked Program’s
symbol table.
Variable names are resolved via Program::global_index; knot/
stitch paths via Program’s path-to-DefinitionId resolution
(the same table find_address/find_path_target use). A name is
tried as a variable first, then as a knot/stitch path; a name
matching neither is a PolicyError::UnknownName.
Subtree expansion (F6.1c). Every knot/stitch override is
expanded here, once, into every DefinitionId in its definition
subtree — see [expand_knot_scope] for the containment mechanism
(Program::scope_ids, the nearest-enclosing-scope table every
interior container carries, plus Program::address_by_path‘s
dotted knot/stitch grammar for the one-level knot→stitch link that
scope_ids alone doesn’t carry). overrides is a BTreeMap, so
this loop’s iteration order is deterministic (sorted by name) — and
because a knot’s name is always a proper prefix of (and therefore
sorts lexicographically before) any of its stitches’ names, a knot
override’s subtree expansion always runs before a same-subtree
stitch override in this same pass, so the stitch override’s own
inserts (which land later) win — implementing “most-specific
override wins” as a natural consequence of processing order, no
separate precedence pass needed.
Compiled base layer. Before host overrides apply, resolve
seeds scopes from the Program’s compiled #@local defaults
(docs/directive-annotations-spec.md): globals the compiler
marked flow-private seed Local, and every #@local knot/stitch
expands over its subtree exactly like a host override would.
Host overrides then layer on top — base ⊕ host-overrides — so a
host name always beats the compiled bit for that name’s subtree.
The all-World default (empty overrides, no compiled #@local
bits) resolves without any name lookups (see
all_world) — this is the fast path every
unannotated single-flow program takes.
Sourcepub fn scope_of_global(&self, slot: u32) -> Scope
pub fn scope_of_global(&self, slot: u32) -> Scope
Scope of a global variable by slot index.
Sourcepub fn scope_of_knot(&self, id: DefinitionId) -> Scope
pub fn scope_of_knot(&self, id: DefinitionId) -> Scope
Scope of a knot/stitch — or of an interior weave/sequence/choice
container nested under one — by its defining DefinitionId. See the
knot_scopes field docs and resolve for how a
knot/stitch override is expanded, at resolve time, to cover every id
in its definition subtree.
Sourcepub fn turn_index_scope(&self) -> Scope
pub fn turn_index_scope(&self) -> Scope
Scope of the turn index.
Trait Implementations§
Source§impl Clone for ResolvedPolicy
impl Clone for ResolvedPolicy
Source§fn clone(&self) -> ResolvedPolicy
fn clone(&self) -> ResolvedPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more