Module context

Module context 

Source
Expand description

Execution context for Milkdrop expressions.

Structs§

ColdSlab 🔒
Indexed slab for cold variables. The bytecode VM resolves cold names to slab indices at compile time and addresses them directly, skipping the HashMapContext probe + the String::from allocation that MilkContext::set would otherwise pay on every store.
HotVars 🔒
Array-backed scratch slots. The bytecode VM addresses these by index (one f64 array load per access — no enum-tag match). The parallel HotVars::slots_value array backs evalexpr’s Context::get_value(name) -> Option<&Value> contract and is kept in sync with the f64 array on every write.
MilkContext
Execution context containing all Milkdrop variables.

Constants§

HOT_A
HOT_A2
HOT_ADDITIVE
HOT_ANG
HOT_B
HOT_B2
HOT_BORDER_A
HOT_BORDER_B
HOT_BORDER_G
HOT_BORDER_R
HOT_COUNT
HOT_G
HOT_G2
HOT_INSTANCE
HOT_NUM_INST
HOT_R
HOT_R2
HOT_RAD
HOT_SAMPLE
HOT_SIDES
HOT_TEX_ANG
HOT_TEX_ZOOM
HOT_THICK
HOT_VALUE1
HOT_VALUE2
HOT_X
HOT_Y
Q_CHANNEL_NAMES_32
Pre-baked "q1".."q32" strings. Hot paths that need to refer to a q-channel by name (e.g. error messages, evalexpr trait methods that only take &str) can index into this table instead of paying a format!("q{}", i) String allocation per call. Reads/writes of q-channel values themselves should go through MilkContext::q_get_idx / MilkContext::q_set_idx which skip name lookup entirely.

Functions§

hot_index_of
Map a Milkdrop hot-var name → its slot index. Used by the bytecode compiler (onedrop-eval::bytecode) and by evalexpr’s Context impl below to short-circuit reads/writes of the hot vars without a HashMap probe or String allocation.
is_hot_var
Returns true iff name is a hot-path scratch variable (per-point, per-vertex, or per-shape) routed through HotVars rather than the underlying HashMapContext. The parallel-samples analyser (onedrop-engine::wave_phase::carry) uses the same set.
q_index_of
Map a qN identifier (1 ≤ N ≤ 64) to its 0-based slot index in the q-vars array. Returns None for any non-qN name or out-of-range N. Used by the bytecode VM compiler and by MilkContext’s Context impl to bypass HashMap probes for the q-channel reads/writes that dominate per_frame state passing.