pub struct Stack { /* private fields */ }
Expand description
EVM stack.
Implementations§
Source§impl Stack
impl Stack
Sourcepub fn pop(&mut self) -> Result<U256, ExitException>
pub fn pop(&mut self) -> Result<U256, ExitException>
Pop a value from the stack.
If the stack is already empty, returns the StackUnderflow
error.
Sourcepub fn push(&mut self, value: U256) -> Result<(), ExitException>
pub fn push(&mut self, value: U256) -> Result<(), ExitException>
Push a new value into the stack.
If it exceeds the stack limit, returns StackOverflow
error and
leaves the stack unchanged.
Sourcepub fn check_pop_push(
&self,
pop: usize,
push: usize,
) -> Result<(), ExitException>
pub fn check_pop_push( &self, pop: usize, push: usize, ) -> Result<(), ExitException>
Check whether it’s possible to pop and push enough items in the stack.
Sourcepub fn peek(&self, no_from_top: usize) -> Result<U256, ExitException>
pub fn peek(&self, no_from_top: usize) -> Result<U256, ExitException>
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.
Sourcepub fn set(
&mut self,
no_from_top: usize,
val: U256,
) -> Result<(), ExitException>
pub fn set( &mut self, no_from_top: usize, val: U256, ) -> Result<(), ExitException>
Set 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.
Sourcepub fn perform_pop0_push1<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop0_push1<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop1_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop1_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop1_push1<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop1_push1<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop2_push1<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop2_push1<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop3_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop3_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop4_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop4_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop6_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop6_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.
Sourcepub fn perform_pop7_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
pub fn perform_pop7_push0<R, F>(&mut self, f: F) -> Result<R, ExitError>
Pop $pop_len values from the stack, and then push $push_len values into the stack.
If f
returns error, then the stack will not be changed.