pub struct PCMut<'a, P: Patch> { /* private fields */ }
Expand description
Represents a mutable program counter in EVM.
Implementations
sourceimpl<'a, P: Patch> PCMut<'a, P>
impl<'a, P: Patch> PCMut<'a, P>
sourcepub fn code(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
pub fn code(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Get the code bytearray.
sourcepub fn opcode_position(&self) -> usize
pub fn opcode_position(&self) -> usize
Get the current opcode position. Should only be used when debugging.
sourcepub fn is_valid(&self, position: usize) -> bool
pub fn is_valid(&self, position: usize) -> bool
Returns true
if the position is a valid jump destination. If
not, returns false
.
sourcepub fn is_end(&self) -> bool
pub fn is_end(&self) -> bool
Check whether the PC is ended. Next read
on this PC would
result in PCError::PCOverflow
.
sourcepub fn peek_opcode(&self) -> Result<Opcode, OnChainError>
pub fn peek_opcode(&self) -> Result<Opcode, OnChainError>
Peek the next opcode.
sourcepub fn peek(&self) -> Result<Instruction, OnChainError>
pub fn peek(&self) -> Result<Instruction, OnChainError>
Peek the next instruction.
sourceimpl<'a, P: Patch> PCMut<'a, P>
impl<'a, P: Patch> PCMut<'a, P>
sourcepub fn new(code: &'a [u8], valids: &'a Valids, position: &'a mut usize) -> Self
pub fn new(code: &'a [u8], valids: &'a Valids, position: &'a mut usize) -> Self
Create a new program counter from the given code.
sourcepub fn jump(&mut self, position: usize) -> Result<(), OnChainError>
pub fn jump(&mut self, position: usize) -> Result<(), OnChainError>
Jump to a position in the code. The destination must be valid to jump.
sourcepub fn read(&mut self) -> Result<Instruction, OnChainError>
pub fn read(&mut self) -> Result<Instruction, OnChainError>
Read the next instruction and step the program counter.
Auto Trait Implementations
impl<'a, P> RefUnwindSafe for PCMut<'a, P>where
P: RefUnwindSafe,
impl<'a, P> Send for PCMut<'a, P>where
P: Send,
impl<'a, P> Sync for PCMut<'a, P>where
P: Sync,
impl<'a, P> Unpin for PCMut<'a, P>where
P: Unpin,
impl<'a, P> !UnwindSafe for PCMut<'a, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more