Struct evmil::Disassembly
source · pub struct Disassembly<'a, T = ()> { /* private fields */ }
Expand description
Identifies all contiguous code blocks within the bytecode program.
Here, a block is a sequence of bytecodes terminated by either
STOP
, REVERT
, RETURN
or JUMP
. Observe that a JUMPDEST
can only appear as the first instruction of a block. In fact,
every reachable block (except the root block) begins with a
JUMPDEST
.
Implementations§
source§impl<'a, T> Disassembly<'a, T>where
T: AbstractState,
impl<'a, T> Disassembly<'a, T>where
T: AbstractState,
pub fn new(bytes: &'a [u8]) -> Self
sourcepub fn get_enclosing_block(&self, pc: usize) -> &Block
pub fn get_enclosing_block(&self, pc: usize) -> &Block
Get the enclosing block for a given bytecode location.
sourcepub fn is_block_reachable(&self, id: usize) -> bool
pub fn is_block_reachable(&self, id: usize) -> bool
Determine whether a given block is currently considered
reachable or not. Observe the root block (id=0
) is always
considered reachable.
sourcepub fn read_bytes(&self, start: usize, end: usize) -> Vec<u8>
pub fn read_bytes(&self, start: usize, end: usize) -> Vec<u8>
Read a slice of bytes from the bytecode program, padding with zeros as necessary.
sourcepub fn refine<S>(self) -> Disassembly<'a, S>where
S: AbstractState + From<T>,
pub fn refine<S>(self) -> Disassembly<'a, S>where
S: AbstractState + From<T>,
Refine this disassembly to something (ideally) more precise use a fixed point dataflow analysis. This destroys the original disassembly.
sourcepub fn to_vec(&self) -> Vec<Instruction>
pub fn to_vec(&self) -> Vec<Instruction>
Flattern the disassembly into a sequence of instructions.