Struct miden_core::stack::StackOutputs
source · pub struct StackOutputs { /* private fields */ }
Expand description
Output container for Miden VM programs.
Miden program outputs contain the full state of the stack at the end of execution as well as the addresses in the overflow table which are required to reconstruct the table (when combined with the overflow values from the stack state).
stack
is expected to be ordered as if the elements were popped off the stack one by one.
Thus, the value at the top of the stack is expected to be in the first position, and the order
of the rest of the output elements will also match the order on the stack.
overflow_addrs
is expected to start with the prev
address value from the first row in the
overflow table (the row representing the deepest element in the stack) and then be followed by
the address (clk
value) of each row in the table starting from the deepest element in the
stack and finishing with the row which was added to the table last.
Implementations§
source§impl StackOutputs
impl StackOutputs
sourcepub fn new(
stack: Vec<u64>,
overflow_addrs: Vec<u64>
) -> Result<Self, OutputError>
pub fn new( stack: Vec<u64>, overflow_addrs: Vec<u64> ) -> Result<Self, OutputError>
Constructs a new StackOutputs struct from the provided stack elements and overflow addresses.
Errors
- If any of the provided stack elements are invalid field elements.
- If any of the provided overflow addresses are invalid field elements.
- If the number of stack elements is greater than
STACK_TOP_SIZE
(16) andoverflow_addrs
does not contain exactlystack.len() + 1 - STACK_TOP_SIZE
elements.
pub fn from_elements( stack: Vec<Felt>, overflow_addrs: Vec<Felt> ) -> Result<Self, OutputError>
sourcepub fn stack(&self) -> &[u64]
pub fn stack(&self) -> &[u64]
Returns the stack outputs, which is state of the stack at the end of execution converted to integers.
sourcepub fn stack_truncated(&self, num_outputs: usize) -> &[u64]
pub fn stack_truncated(&self, num_outputs: usize) -> &[u64]
Returns the number of requested stack outputs or returns the full stack if fewer than the requested number of stack values exist.
sourcepub fn stack_top(&self) -> StackTopState
pub fn stack_top(&self) -> StackTopState
Returns the state of the top of the stack at the end of execution.
sourcepub fn overflow_addrs(&self) -> &[u64]
pub fn overflow_addrs(&self) -> &[u64]
Returns the overflow address outputs, which are the addresses required to reconstruct the overflow table (when combined with the stack overflow values) converted to integers.
sourcepub fn has_overflow(&self) -> bool
pub fn has_overflow(&self) -> bool
Returns true if the overflow table outputs are non-empty.
sourcepub fn overflow_prev(&self) -> Felt
pub fn overflow_prev(&self) -> Felt
Returns the previous address prev
for the first row in the stack overflow table
sourcepub fn stack_overflow(&self) -> Vec<(Felt, Felt)>
pub fn stack_overflow(&self) -> Vec<(Felt, Felt)>
Returns (address, value) for all rows which were on the overflow table at the end of execution in the order in which they were added to the table (deepest stack item first).
Trait Implementations§
source§impl Clone for StackOutputs
impl Clone for StackOutputs
source§fn clone(&self) -> StackOutputs
fn clone(&self) -> StackOutputs
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StackOutputs
impl Debug for StackOutputs
source§impl Default for StackOutputs
impl Default for StackOutputs
source§fn default() -> StackOutputs
fn default() -> StackOutputs
source§impl PartialEq for StackOutputs
impl PartialEq for StackOutputs
source§fn eq(&self, other: &StackOutputs) -> bool
fn eq(&self, other: &StackOutputs) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serializable for StackOutputs
impl Serializable for StackOutputs
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
.