pub struct SplitNode { /* private fields */ }
Expand description
A Split node defines conditional execution. When the VM encounters a Split node it executes
either the on_true
child or on_false
child.
Which child is executed is determined based on the top of the stack. If the value is 1
, then
the on_true
child is executed. If the value is 0
, then the on_false
child is executed. If
the value is neither 0
nor 1
, the execution fails.
Implementations§
Source§impl SplitNode
Constructors
impl SplitNode
Constructors
pub fn new( branches: [MastNodeId; 2], mast_forest: &MastForest, ) -> Result<Self, MastForestError>
Sourcepub fn new_unsafe(branches: [MastNodeId; 2], digest: Word) -> Self
pub fn new_unsafe(branches: [MastNodeId; 2], digest: Word) -> Self
Returns a new SplitNode
from values that are assumed to be correct.
Should only be used when the source of the inputs is trusted (e.g. deserialization).
Source§impl SplitNode
Public accessors
impl SplitNode
Public accessors
Sourcepub fn digest(&self) -> Word
pub fn digest(&self) -> Word
Returns a commitment to this Split node.
The commitment is computed as a hash of the on_true
and on_false
child nodes in the
domain defined by Self::DOMAIN - i..e,:
Hasher::merge_in_domain(&[on_true_digest, on_false_digest], SplitNode::DOMAIN);
Sourcepub fn on_true(&self) -> MastNodeId
pub fn on_true(&self) -> MastNodeId
Returns the ID of the node which is to be executed if the top of the stack is 1
.
Sourcepub fn on_false(&self) -> MastNodeId
pub fn on_false(&self) -> MastNodeId
Returns the ID of the node which is to be executed if the top of the stack is 0
.
Sourcepub fn before_enter(&self) -> &[DecoratorId]
pub fn before_enter(&self) -> &[DecoratorId]
Returns the decorators to be executed before this node is executed.
Sourcepub fn after_exit(&self) -> &[DecoratorId]
pub fn after_exit(&self) -> &[DecoratorId]
Returns the decorators to be executed after this node is executed.
Source§impl SplitNode
Mutators
impl SplitNode
Mutators
pub fn remap_children(&self, remapping: &Remapping) -> Self
Sourcepub fn append_before_enter(&mut self, decorator_ids: &[DecoratorId])
pub fn append_before_enter(&mut self, decorator_ids: &[DecoratorId])
Sets the list of decorators to be executed before this node.
Sourcepub fn append_after_exit(&mut self, decorator_ids: &[DecoratorId])
pub fn append_after_exit(&mut self, decorator_ids: &[DecoratorId])
Sets the list of decorators to be executed after this node.
Trait Implementations§
Source§impl MastNodeExt for SplitNode
impl MastNodeExt for SplitNode
Source§fn decorators(&self) -> impl Iterator<Item = (usize, DecoratorId)>
fn decorators(&self) -> impl Iterator<Item = (usize, DecoratorId)>
Source§fn get_assembly_op<'m>(
&self,
mast_forest: &'m MastForest,
target_op_idx: Option<usize>,
) -> Option<&'m AssemblyOp>
fn get_assembly_op<'m>( &self, mast_forest: &'m MastForest, target_op_idx: Option<usize>, ) -> Option<&'m AssemblyOp>
AssemblyOp
associated with this node and operation (if provided), if any. Read more