pub struct Program { /* private fields */ }
Expand description
An executable program for Miden VM.
A program consists of a MAST forest, an entrypoint defining the MAST node at which the program execution begins, and a definition of the kernel against which the program must be executed (the kernel can be an empty kernel).
Implementations§
Source§impl Program
Constructors
impl Program
Constructors
Sourcepub fn new(mast_forest: Arc<MastForest>, entrypoint: MastNodeId) -> Self
pub fn new(mast_forest: Arc<MastForest>, entrypoint: MastNodeId) -> Self
Sourcepub fn with_kernel(
mast_forest: Arc<MastForest>,
entrypoint: MastNodeId,
kernel: Kernel,
) -> Self
pub fn with_kernel( mast_forest: Arc<MastForest>, entrypoint: MastNodeId, kernel: Kernel, ) -> Self
Sourcepub fn with_advice_map(self, advice_map: AdviceMap) -> Self
pub fn with_advice_map(self, advice_map: AdviceMap) -> Self
Produces a new program with the existing MastForest
and where all key/values in the
provided advice map are added to the internal advice map.
Source§impl Program
Public accessors
impl Program
Public accessors
Sourcepub fn hash(&self) -> Word
pub fn hash(&self) -> Word
Returns the hash of the program’s entrypoint.
Equivalently, returns the hash of the root of the entrypoint procedure.
Sourcepub fn entrypoint(&self) -> MastNodeId
pub fn entrypoint(&self) -> MastNodeId
Returns the entrypoint associated with this program.
Sourcepub fn mast_forest(&self) -> &Arc<MastForest>
pub fn mast_forest(&self) -> &Arc<MastForest>
Returns a reference to the underlying MastForest
.
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 fallible version of indexing (e.g. program[node_id]
).
Sourcepub fn find_procedure_root(&self, digest: Word) -> Option<MastNodeId>
pub fn find_procedure_root(&self, digest: Word) -> Option<MastNodeId>
Returns the MastNodeId
of the procedure root associated with a given digest, if any.
Sourcepub fn num_procedures(&self) -> u32
pub fn num_procedures(&self) -> u32
Returns the number of procedures in this program.
Trait Implementations§
Source§impl Deserializable for Program
impl Deserializable for Program
Source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
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 ProgramInfo
impl From<Program> for ProgramInfo
Source§impl PrettyPrint for Program
impl PrettyPrint for Program
Source§fn to_pretty_string(&self) -> String
fn to_pretty_string(&self) -> String
Source§fn pretty_print(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn pretty_print(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Source§impl Serializable for Program
impl Serializable for Program
Source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self
into bytes and writes these bytes into the target
.