Skip to main content

Module expr

Module expr 

Source
Expand description

Arb’s computational substrate: arithmetic expressions are compiled to a fusevm::Chunk and executed on the fusevm VM (Cranelift JIT for hot chunks). This is what “arb runs on fusevm” means concretely — every computed value in a spec flows through fusevm bytecode, not a bespoke evaluator.

x is the pipeline input scalar; a bareword identifier (amount, latency) is a field of the current record, resolved by the caller’s closure. Both are baked into the chunk as constants per evaluation, so no VM slot state is assumed across run(). Comparisons (== != < <= > >=) lower to fusevm’s Num* ops and yield a boolean; eval_pred reads the result via Value::is_truthy for where.

Enums§

BinOp
Expr

Functions§

chunk_of
Lower e to the fusevm chunk eval_ctx would run, without running it.
control_names
Collect the names of every Control reference in e (e.g. .th -> “th”).
control_names_typed
Split control refs by the type they resolve to: Match/InSet inners are string controls, everything else is numeric. Lets resolve_pipeline require numeric controls to resolve (or drop the filter) while string controls with an empty value simply match everything.
eval
Evaluate as a number with no field resolver (field refs -> NaN).
eval_ctx
Lower e to a fusevm chunk (with x and resolved fields baked in), run it on the VM, and return the resulting number. resolve maps a field name to its numeric value.
eval_pred
Evaluate as a predicate with no field resolver.
eval_pred_ctx
Evaluate e as a predicate — compiled to fusevm, run on the VM, read as a boolean via Value::is_truthy. resolve maps a field name to its value.
expr_has_str
Whether e contains a string predicate (match/in .set) — the query layer routes such a where to the Rust evaluator instead of the numeric VM.
parse
Parse an expression: numbers, x, + - * / %, comparisons (== != < <= > >=), unary -, and parentheses.
prefix_controls
Rewrite every Control(name) in e to Control("{ns}.{name}"), in place — used by import X as Y to namespace a module’s control references.
substitute_controls
Return a copy of e with control refs substituted: a numeric Control -> Num(num(n)) when resolvable (else left as-is -> NaN); a string control inside match/in .set -> Str(strv(n)) (empty when unset -> matches all).