Struct revm_interpreter::Stack
source · pub struct Stack { /* private fields */ }
Expand description
EVM stack.
Implementations§
source§impl Stack
impl Stack
pub fn reduce_one(&mut self) -> Option<InstructionResult>
sourcepub fn pop(&mut self) -> Result<U256, InstructionResult>
pub fn pop(&mut self) -> Result<U256, InstructionResult>
Pop a value from the stack. If the stack is already empty, returns the
StackUnderflow
error.
sourcepub unsafe fn pop_unsafe(&mut self) -> U256
pub unsafe fn pop_unsafe(&mut self) -> U256
Pops a value from the stack, returning it.
Safety
The caller is responsible to check length of array
sourcepub unsafe fn top_unsafe(&mut self) -> &mut U256
pub unsafe fn top_unsafe(&mut self) -> &mut U256
sourcepub unsafe fn pop_top_unsafe(&mut self) -> (U256, &mut U256)
pub unsafe fn pop_top_unsafe(&mut self) -> (U256, &mut U256)
Pop the topmost value, returning the value and the new topmost value.
Safety
The caller is responsible to check length of array
sourcepub unsafe fn pop2_top_unsafe(&mut self) -> (U256, U256, &mut U256)
pub unsafe fn pop2_top_unsafe(&mut self) -> (U256, U256, &mut U256)
Pops 2 values from the stack and returns them, in addition to the new topmost value.
Safety
The caller is responsible to check length of array
sourcepub unsafe fn pop2_unsafe(&mut self) -> (U256, U256)
pub unsafe fn pop2_unsafe(&mut self) -> (U256, U256)
sourcepub unsafe fn pop3_unsafe(&mut self) -> (U256, U256, U256)
pub unsafe fn pop3_unsafe(&mut self) -> (U256, U256, U256)
sourcepub unsafe fn pop4_unsafe(&mut self) -> (U256, U256, U256, U256)
pub unsafe fn pop4_unsafe(&mut self) -> (U256, U256, U256, U256)
sourcepub fn push_b256(&mut self, value: B256) -> Result<(), InstructionResult>
pub fn push_b256(&mut self, value: B256) -> Result<(), InstructionResult>
Push a new value into the stack. If it will exceed the stack limit,
returns StackOverflow
error and leaves the stack unchanged.
sourcepub fn push(&mut self, value: U256) -> Result<(), InstructionResult>
pub fn push(&mut self, value: U256) -> Result<(), InstructionResult>
Push a new value into the stack. If it will exceed the stack limit,
returns StackOverflow
error and leaves the stack unchanged.
sourcepub fn peek(&self, no_from_top: usize) -> Result<U256, InstructionResult>
pub fn peek(&self, no_from_top: usize) -> Result<U256, InstructionResult>
Peek a value at given index for the stack, where the top of
the stack is at index 0
. If the index is too large,
StackError::Underflow
is returned.
pub fn dup<const N: usize>(&mut self) -> Option<InstructionResult>
pub fn swap<const N: usize>(&mut self) -> Option<InstructionResult>
sourcepub fn push_slice<const N: usize>(
&mut self,
slice: &[u8]
) -> Option<InstructionResult>
pub fn push_slice<const N: usize>(
&mut self,
slice: &[u8]
) -> Option<InstructionResult>
push slice onto memory it is expected to be max 32 bytes and be contains inside B256