Trait evmil::analysis::EvmStack

source ·
pub trait EvmStack: Debug {
    type Word: EvmWord;

    // Required methods
    fn size(&self) -> usize;
    fn peek(&self, n: usize) -> &Self::Word;
    fn push(&mut self, item: Self::Word);
    fn pop(&mut self) -> Self::Word;
    fn set(&mut self, n: usize, item: Self::Word) -> Self::Word;
    fn goto(&mut self, pc: usize);

    // Provided methods
    fn has_capacity(&self, n: usize) -> bool { ... }
    fn has_operands(&self, n: usize) -> bool { ... }
    fn swap(&mut self, n: usize) { ... }
    fn dup(&mut self, n: usize) { ... }
}
Expand description

Abstraction of the operand stack within an EVM. This provides the minimal set of operations required to implement the semantics of a given bytecode instruction. For example, pushing / popping items from the stack.

Required Associated Types§

source

type Word: EvmWord

Defines what constitutes a word in this EVM. For example, a concrete evm will use a w256 here whilst an abstract evm will use something that can, for example, describe unknown values.

Required Methods§

source

fn size(&self) -> usize

Get the size of the stack.

source

fn peek(&self, n: usize) -> &Self::Word

Peek nth item from stack (where n==0 is top element).

source

fn push(&mut self, item: Self::Word)

Push an item onto the stack.

source

fn pop(&mut self) -> Self::Word

Pop an item from the stack.

source

fn set(&mut self, n: usize, item: Self::Word) -> Self::Word

Set nth item from stack (where n==0 is top element), whilst returning the item previously at that position.

source

fn goto(&mut self, pc: usize)

Update internal position within code.

Provided Methods§

source

fn has_capacity(&self, n: usize) -> bool

Check capacity for n additional items on the stack.

source

fn has_operands(&self, n: usize) -> bool

Check at least n operands on the stack.

source

fn swap(&mut self, n: usize)

Swap top item on stack with nth item on stack (where n>0, and n==0 would be the top element).

source

fn dup(&mut self, n: usize)

Duplicate nth item on stack (where n==0 is the top element).

Implementors§