pub struct LoopNode { /* private fields */ }
Expand description
A Loop node defines condition-controlled iterative execution. When the VM encounters a Loop node, it will keep executing the body of the loop as long as the top of the stack is `1``.
The loop is exited when at the end of executing the loop body the top of the stack is 0``. If the top of the stack is neither
0nor
1` when the condition is checked, the execution
fails.
Implementations§
Source§impl LoopNode
Constructors
impl LoopNode
Constructors
Sourcepub fn new(
body: MastNodeId,
mast_forest: &MastForest,
) -> Result<Self, MastForestError>
pub fn new( body: MastNodeId, mast_forest: &MastForest, ) -> Result<Self, MastForestError>
Returns a new LoopNode
instantiated with the specified body node.
Sourcepub fn new_unsafe(body: MastNodeId, digest: Word) -> Self
pub fn new_unsafe(body: MastNodeId, digest: Word) -> Self
Returns a new LoopNode
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 LoopNode
impl LoopNode
Sourcepub fn digest(&self) -> Word
pub fn digest(&self) -> Word
Returns a commitment to this Loop node.
The commitment is computed as a hash of the loop body and an empty word ([ZERO; 4]) in the domain defined by Self::DOMAIN - i..e,:
Hasher::merge_in_domain(&[body_digest, Word::default()], LoopNode::DOMAIN);
Sourcepub fn body(&self) -> MastNodeId
pub fn body(&self) -> MastNodeId
Returns the ID of the node presenting the body of the loop.
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 LoopNode
Mutators
impl LoopNode
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.
Sourcepub fn remove_decorators(&mut self)
pub fn remove_decorators(&mut self)
Removes all decorators from this node.
Trait Implementations§
Source§impl MastNodeExt for LoopNode
impl MastNodeExt for LoopNode
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