pub struct Expr { /* private fields */ }Expand description
A compiled expression: parse once, eval every frame.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn eval(&self, vars: &Variables<'_>) -> f32
pub fn eval(&self, vars: &Variables<'_>) -> f32
Evaluate against a variable binding. Total and allocation-free.
Sourcepub fn eval_probed(&self, vars: &Variables<'_>, obs: &mut Observations) -> f32
pub fn eval_probed(&self, vars: &Variables<'_>, obs: &mut Observations) -> f32
Evaluate exactly as eval does, additionally accumulating
per-node reachability into obs (Plan 0041 / ADR-0042).
Harness only. Nothing on the render path calls this: it allocates
(the observation arena grows on first touch) and it walks the tree twice.
eval is untouched and remains the only thing a frame executes.
Call it repeatedly with the same obs across a run of varying
Variables — one Observations per expression. What accumulates is
which way each comparison and each select() condition went, and — for
each clamp() — both how close its inner value came to the upper bound
and how many hops it spent at that bound (ADR-0062);
flag_gates reads the verdict back out.
Sourcepub fn flag_gates(&self, obs: &Observations) -> Vec<GateFlag>
pub fn flag_gates(&self, obs: &Observations) -> Vec<GateFlag>
The gates obs never saw exercised, named by their source text.
Read every one as a suspect, not a conviction: it says the run these
observations came from never drove the gate both ways, which is a
property of the stimulus as much as of the preset. A gate on tempo is
correctly one-sided under a single-BPM generator.
Nodes never reached at all are silent — a select() buried inside a dead
branch is not a second finding, it is the same one. Fix the outer gate
and the inner one starts reporting.
Sourcepub fn source(&self) -> String
pub fn source(&self) -> String
This expression rendered back to source text (normalized whitespace and parentheses, not the author’s original characters).
Sourcepub fn uses_index(&self) -> bool
pub fn uses_index(&self) -> bool
Whether this expression references the per-element index, i.e. whether
it wants to be evaluated once per element rather than once per frame
(Plan 0034 Phase 4). Free to call — the answer was computed at compile.
Sourcepub fn as_const(&self) -> Option<f32>
pub fn as_const(&self) -> Option<f32>
The value this expression always takes, when it takes only one.
Some exactly when the compiled root is a constant — a literal, or
anything the compiler folded to one (2 * 0.008 folds; bass * 0 does
not, and deliberately: the fold is syntactic and a binding that names a
variable is not resting anywhere).
Read by the loader, which can only warn about a value it knows a binding rests at. An expression that sweeps through a bad range is not something a load-time check can see, and pretending otherwise would put a false warning on every preset that animates the parameter.
Sourcepub fn uses_vertex(&self) -> bool
pub fn uses_vertex(&self) -> bool
Whether this expression references any per-vertex position variable
(x, y, rad, ang) — Plan 0100 Phase 1. Free to call; the answer was
computed at compile.
The loader uses it for a warning, not for routing: only a [per_vertex]
table’s bindings are evaluated per vertex, and outside one these names
read 0.
Sourcepub fn uses_latch(&self, slot: usize) -> bool
pub fn uses_latch(&self, slot: usize) -> bool
Whether this expression reads the latch at slot in its preset’s
[latch] order (ADR-0137).
Not precomputed like the two above, because nothing routes on it: the loader asks it once per latch per binding, to warn about a latch no binding names. Never called per frame.