Module compiled_block

Module compiled_block 

Source
Expand description

Compiled block: bundles a Vec<Node> (evalexpr fallback) with an optional CompiledBytecode lowering.

Most preset hot loops (per-frame eqs, per-vertex warp eqs, custom-shape per-frame, custom-wave per-frame / per_frame_init, …) want the same “prefer bytecode VM, fall back to evalexpr Node walk” branching that [onedrop-engine::engine::wave_phase] already wires by hand for the per_point hot path. This newtype hoists that pattern into the eval crate so every call site picks it up uniformly.

  • from_nodes(Vec<Node>) — try-compiles the bytecode lazily; on failure (an op the VM doesn’t support: rand, gmegabuf, …) the block keeps the Nodes and runtime falls back transparently.
  • run(&mut MilkContext) — single entry point that picks the bytecode path when available. The bytecode path is infallible by construction (try_compile is the only failure point); the fallback discards per-equation errors silently.
  • nodes() / bytecode() — exposed for call sites that still want per-equation error logging or special handling (sequential vs parallel-samples in [onedrop-engine::engine::wave_phase]).

Structs§

CompiledBlock
A pre-compiled block of expressions ready to execute against a MilkContext. See module docs.