Struct sputnikvm::PC
[−]
[src]
pub struct PC<P: Patch> { /* fields omitted */ }
Represents a program counter in EVM.
Methods
impl<P: Patch> PC<P>
[src]
fn new(code: &[u8]) -> Self
[src]
Create a new program counter from the given code.
fn code(&self) -> &[u8]
[src]
Get the code bytearray.
fn jump(&mut self, position: usize) -> Result<(), OnChainError>
[src]
Jump to a position in the code. The destination must be valid to jump.
fn position(&self) -> usize
[src]
Get the current program counter position.
fn is_valid(&self, position: usize) -> bool
[src]
Returns true
if the position is a valid jump destination. If
not, returns false
.
fn is_end(&self) -> bool
[src]
Check whether the PC is ended. Next read
on this PC would
result in PCError::PCOverflow
.
fn peek(&self) -> Result<Instruction, OnChainError>
[src]
Peek the next instruction.
fn read(&mut self) -> Result<Instruction, OnChainError>
[src]
Read the next instruction and step the program counter.