Skip to main content

Expr

Struct Expr 

Source
pub struct Expr { /* private fields */ }
Expand description

A compiled expression: parse once, eval every frame.

Implementations§

Source§

impl Expr

Source

pub fn eval(&self, vars: &Variables<'_>) -> f32

Evaluate against a variable binding. Total and allocation-free.

Source

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.

Source

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.

Source

pub fn source(&self) -> String

This expression rendered back to source text (normalized whitespace and parentheses, not the author’s original characters).

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,