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) -> Program
pub fn new(mast_forest: Arc<MastForest>, entrypoint: MastNodeId) -> Program
Sourcepub fn with_kernel(
mast_forest: Arc<MastForest>,
entrypoint: MastNodeId,
kernel: Kernel,
) -> Program
pub fn with_kernel( mast_forest: Arc<MastForest>, entrypoint: MastNodeId, kernel: Kernel, ) -> Program
Sourcepub fn with_advice_map(self, advice_map: AdviceMap) -> Program
pub fn with_advice_map(self, advice_map: AdviceMap) -> Program
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) -> RpoDigest
pub fn hash(&self) -> RpoDigest
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: RpoDigest) -> Option<MastNodeId>
pub fn find_procedure_root(&self, digest: RpoDigest) -> 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>(source: &mut R) -> Result<Program, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<Program, 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 ProgramInfo
impl From<Program> for ProgramInfo
Source§fn from(program: Program) -> ProgramInfo
fn from(program: Program) -> 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>(&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.