Struct miden_processor::MastForest
source · pub struct MastForest { /* private fields */ }Expand description
Represents one or more procedures, represented as a collection of MastNodes.
A MastForest does not have an entrypoint, and hence is not executable. A crate::Program
can be built from a MastForest to specify an entrypoint.
Implementations§
source§impl MastForest
impl MastForest
State mutators
sourcepub fn add_node(
&mut self,
node: MastNode,
) -> Result<MastNodeId, MastForestError>
pub fn add_node( &mut self, node: MastNode, ) -> Result<MastNodeId, MastForestError>
Adds a node to the forest, and returns the associated MastNodeId.
Adding two duplicate nodes will result in two distinct returned MastNodeIds.
sourcepub fn add_block(
&mut self,
operations: Vec<Operation>,
decorators: Option<Vec<(usize, Decorator)>>,
) -> Result<MastNodeId, MastForestError>
pub fn add_block( &mut self, operations: Vec<Operation>, decorators: Option<Vec<(usize, Decorator)>>, ) -> Result<MastNodeId, MastForestError>
Adds a basic block node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_join(
&mut self,
left_child: MastNodeId,
right_child: MastNodeId,
) -> Result<MastNodeId, MastForestError>
pub fn add_join( &mut self, left_child: MastNodeId, right_child: MastNodeId, ) -> Result<MastNodeId, MastForestError>
Adds a join node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_split(
&mut self,
if_branch: MastNodeId,
else_branch: MastNodeId,
) -> Result<MastNodeId, MastForestError>
pub fn add_split( &mut self, if_branch: MastNodeId, else_branch: MastNodeId, ) -> Result<MastNodeId, MastForestError>
Adds a split node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_loop(
&mut self,
body: MastNodeId,
) -> Result<MastNodeId, MastForestError>
pub fn add_loop( &mut self, body: MastNodeId, ) -> Result<MastNodeId, MastForestError>
Adds a loop node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_call(
&mut self,
callee: MastNodeId,
) -> Result<MastNodeId, MastForestError>
pub fn add_call( &mut self, callee: MastNodeId, ) -> Result<MastNodeId, MastForestError>
Adds a call node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_syscall(
&mut self,
callee: MastNodeId,
) -> Result<MastNodeId, MastForestError>
pub fn add_syscall( &mut self, callee: MastNodeId, ) -> Result<MastNodeId, MastForestError>
Adds a syscall node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_dyn(&mut self) -> Result<MastNodeId, MastForestError>
pub fn add_dyn(&mut self) -> Result<MastNodeId, MastForestError>
Adds a dyn node to the forest, and returns the MastNodeId associated with it.
sourcepub fn add_external(
&mut self,
mast_root: RpoDigest,
) -> Result<MastNodeId, MastForestError>
pub fn add_external( &mut self, mast_root: RpoDigest, ) -> Result<MastNodeId, MastForestError>
Adds an external node to the forest, and returns the MastNodeId associated with it.
sourcepub fn make_root(&mut self, new_root_id: MastNodeId)
pub fn make_root(&mut self, new_root_id: MastNodeId)
Marks the given MastNodeId as being the root of a procedure.
§Panics
- if
new_root_id’s internal index is larger than the number of nodes in this forest (i.e. clearly doesn’t belong to this MAST forest).
source§impl MastForest
impl MastForest
Public accessors
sourcepub fn get_node_by_id(&self, node_id: MastNodeId) -> Option<&MastNode>
pub fn get_node_by_id(&self, node_id: MastNodeId) -> Option<&MastNode>
Returns the MastNode associated with the provided MastNodeId if valid, or else
None.
This is the failable version of indexing (e.g. mast_forest[node_id]).
sourcepub fn find_procedure_root(&self, digest: RpoDigest) -> Option<MastNodeId>
pub fn find_procedure_root(&self, digest: RpoDigest) -> Option<MastNodeId>
Returns the MastNodeId of the procedure associated with a given digest, if any.
sourcepub fn is_procedure_root(&self, node_id: MastNodeId) -> bool
pub fn is_procedure_root(&self, node_id: MastNodeId) -> bool
Returns true if a node with the specified ID is a root of a procedure in this MAST forest.
sourcepub fn procedure_digests(&self) -> impl Iterator<Item = RpoDigest>
pub fn procedure_digests(&self) -> impl Iterator<Item = RpoDigest>
Returns an iterator over the digest of the procedures in this MAST forest.
sourcepub fn procedure_roots(&self) -> &[MastNodeId]
pub fn procedure_roots(&self) -> &[MastNodeId]
Returns an iterator over the IDs of the procedures in this MAST forest.
sourcepub fn num_procedures(&self) -> u32
pub fn num_procedures(&self) -> u32
Returns the number of procedures in this MAST forest.
Trait Implementations§
source§impl Clone for MastForest
impl Clone for MastForest
source§fn clone(&self) -> MastForest
fn clone(&self) -> MastForest
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for MastForest
impl Debug for MastForest
source§impl Default for MastForest
impl Default for MastForest
source§fn default() -> MastForest
fn default() -> MastForest
source§impl Deserializable for MastForest
impl Deserializable for MastForest
source§fn read_from<R>(source: &mut R) -> Result<MastForest, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<MastForest, DeserializationError>where
R: ByteReader,
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl From<Program> for MastForest
impl From<Program> for MastForest
source§fn from(program: Program) -> MastForest
fn from(program: Program) -> MastForest
source§impl Index<MastNodeId> for MastForest
impl Index<MastNodeId> for MastForest
source§fn index(
&self,
node_id: MastNodeId,
) -> &<MastForest as Index<MastNodeId>>::Output
fn index( &self, node_id: MastNodeId, ) -> &<MastForest as Index<MastNodeId>>::Output
container[index]) operation. Read moresource§impl PartialEq for MastForest
impl PartialEq for MastForest
source§impl Serializable for MastForest
impl Serializable for MastForest
source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
impl Eq for MastForest
impl StructuralPartialEq for MastForest
Auto Trait Implementations§
impl Freeze for MastForest
impl RefUnwindSafe for MastForest
impl Send for MastForest
impl Sync for MastForest
impl Unpin for MastForest
impl UnwindSafe for MastForest
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)