pub struct CompiledBlock {
nodes: Vec<Node>,
bytecode: Option<CompiledBytecode>,
}Expand description
A pre-compiled block of expressions ready to execute against a
MilkContext. See module docs.
Fields§
§nodes: Vec<Node>§bytecode: Option<CompiledBytecode>Implementations§
Source§impl CompiledBlock
impl CompiledBlock
Sourcepub fn from_nodes(nodes: Vec<Node>, ctx: &mut MilkContext) -> Self
pub fn from_nodes(nodes: Vec<Node>, ctx: &mut MilkContext) -> Self
Take ownership of nodes and try to lower them to bytecode
against ctx. Cold-variable names referenced by the block are
interned into ctx.cold so the emitted opcodes carry slab
indices.
On lowering failure (any unsupported operator/function) the
block stores bytecode: None and the runtime falls back to
evalexpr’s tree-walking interpreter — same observable
behaviour, just slower.
Sourcepub fn nodes(&self) -> &[Node]
pub fn nodes(&self) -> &[Node]
Underlying evalexpr nodes. Always populated, even when bytecode is also available (kept around as the fallback path for the few runtime decisions that need per-node access — e.g. per-equation error logging).
Sourcepub fn bytecode(&self) -> Option<&CompiledBytecode>
pub fn bytecode(&self) -> Option<&CompiledBytecode>
Bytecode lowering when available. None means at least one
node uses an op the VM doesn’t support; runtime falls back to
the Nodes path.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn run(&self, ctx: &mut MilkContext)
pub fn run(&self, ctx: &mut MilkContext)
Execute the block against ctx. Prefers the bytecode VM when
available; otherwise iterates the evalexpr nodes and discards
per-equation errors silently. Call sites that want to log
per-equation failures should use CompiledBlock::nodes +
CompiledBlock::bytecode directly.
Trait Implementations§
Source§impl Clone for CompiledBlock
impl Clone for CompiledBlock
Source§fn clone(&self) -> CompiledBlock
fn clone(&self) -> CompiledBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more