pub struct OpStack {
pub stack: Vec<BFieldElement>,
/* private fields */
}
Expand description
The operational stack of Triton VM.
It always contains at least OpStackElement::COUNT
elements. Initially, the bottom-most
Digest::LEN
elements equal the digest of the program being executed.
The remaining elements are initially 0.
The OpStack is represented as one contiguous piece of memory, and Triton VM uses it as such.
For reasons of arithmetization, however, there is a distinction between the op-stack registers
and the op-stack underflow memory. The op-stack registers are the first
OpStackElement::COUNT
elements of the op-stack, and the op-stack underflow memory is the
remaining elements.
Fields§
§stack: Vec<BFieldElement>
The underlying, actual stack. When manually accessing, be aware of reversed indexing:
while op_stack[0]
is the top of the stack, op_stack.stack[0]
is the lowest element in
the stack.
Implementations§
Source§impl OpStack
impl OpStack
pub fn new(program_digest: Digest) -> Self
pub fn len(&self) -> usize
pub fn push(&mut self, element: BFieldElement)
pub fn pop(&mut self) -> Result<BFieldElement, OpStackError>
pub fn insert(&mut self, index: OpStackElement, element: BFieldElement)
pub fn remove(&mut self, index: OpStackElement) -> BFieldElement
pub fn start_recording_underflow_io_sequence(&mut self)
pub fn stop_recording_underflow_io_sequence(&mut self) -> Vec<UnderflowIO>
pub fn push_extension_field_element(&mut self, element: XFieldElement)
pub fn pop_extension_field_element( &mut self, ) -> Result<XFieldElement, OpStackError>
pub fn is_u32(&self, stack_element: OpStackElement) -> Result<(), OpStackError>
pub fn get_u32( &self, stack_element: OpStackElement, ) -> Result<u32, OpStackError>
pub fn pop_u32(&mut self) -> Result<u32, OpStackError>
pub fn pop_multiple<const N: usize>( &mut self, ) -> Result<[BFieldElement; N], OpStackError>
pub fn peek_at_top_extension_field_element(&self) -> XFieldElement
pub fn would_be_too_shallow(&self, stack_delta: i32) -> bool
Sourcepub fn pointer(&self) -> BFieldElement
pub fn pointer(&self) -> BFieldElement
The address of the next free address of the op-stack. Equivalent to the current length of the op-stack.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for OpStack
impl<'arbitrary> Arbitrary<'arbitrary> for OpStack
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for OpStack
impl<'de> Deserialize<'de> for OpStack
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Index<OpStackElement> for OpStack
impl Index<OpStackElement> for OpStack
Source§type Output = BFieldElement
type Output = BFieldElement
Source§impl IndexMut<OpStackElement> for OpStack
impl IndexMut<OpStackElement> for OpStack
Source§impl IntoIterator for OpStack
impl IntoIterator for OpStack
impl Eq for OpStack
impl StructuralPartialEq for OpStack
Auto Trait Implementations§
impl Freeze for OpStack
impl RefUnwindSafe for OpStack
impl Send for OpStack
impl Sync for OpStack
impl Unpin for OpStack
impl UnwindSafe for OpStack
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more