pub struct OpCode(/* private fields */);Expand description
An EVM opcode
This is always a valid opcode, as declared in the opcode module or the
OPCODE_INFO constant.
Implementations§
Source§impl OpCode
impl OpCode
Sourcepub const fn new(opcode: u8) -> Option<OpCode>
pub const fn new(opcode: u8) -> Option<OpCode>
Instantiates a new opcode from a u8.
Returns None if the opcode is not valid.
Sourcepub const fn is_jumpdest(&self) -> bool
pub const fn is_jumpdest(&self) -> bool
Returns true if the opcode is a jump destination.
Sourcepub const fn is_jumpdest_by_op(opcode: u8) -> bool
pub const fn is_jumpdest_by_op(opcode: u8) -> bool
Takes a u8 and returns true if it is a jump destination.
Sourcepub const fn is_jump_by_op(opcode: u8) -> bool
pub const fn is_jump_by_op(opcode: u8) -> bool
Takes a u8 and returns true if it is a jump instruction.
Sourcepub fn is_push_by_op(opcode: u8) -> bool
pub fn is_push_by_op(opcode: u8) -> bool
Takes a u8 and returns true if it is a push instruction.
Sourcepub unsafe fn new_unchecked(opcode: u8) -> OpCode
pub unsafe fn new_unchecked(opcode: u8) -> OpCode
Instantiates a new opcode from a u8 without checking if it is valid.
§Safety
All code using Opcode values assume that they are valid opcodes, so providing an invalid
opcode may cause undefined behavior.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
Returns the opcode as a string. This is the inverse of parse.
Sourcepub const fn name_by_op(opcode: u8) -> &'static str
pub const fn name_by_op(opcode: u8) -> &'static str
Returns the opcode name.
Sourcepub const fn io_diff(&self) -> i16
pub const fn io_diff(&self) -> i16
Calculates the difference between the number of input and output stack elements.
Sourcepub const fn info_by_op(opcode: u8) -> Option<OpCodeInfo>
pub const fn info_by_op(opcode: u8) -> Option<OpCodeInfo>
Returns the opcode information for the given opcode. Check OpCodeInfo for more information.
Sourcepub const fn info(&self) -> OpCodeInfo
pub const fn info(&self) -> OpCodeInfo
Returns the opcode information.
Sourcepub const fn input_output(&self) -> (u8, u8)
pub const fn input_output(&self) -> (u8, u8)
Returns the number of both input and output stack elements.
Can be slightly faster than calling inputs and outputs separately.
Sourcepub const fn modifies_memory(&self) -> bool
pub const fn modifies_memory(&self) -> bool
Returns true if the opcode modifies memory.
https://docs.rs/revm-interpreter/latest/revm_interpreter/instructions/index.html
Source§impl OpCode
impl OpCode
Sourcepub const SIGNEXTEND: OpCode
pub const SIGNEXTEND: OpCode
The 0x0B (“SIGNEXTEND”) opcode.
Sourcepub const CALLDATALOAD: OpCode
pub const CALLDATALOAD: OpCode
The 0x35 (“CALLDATALOAD”) opcode.
Sourcepub const CALLDATASIZE: OpCode
pub const CALLDATASIZE: OpCode
The 0x36 (“CALLDATASIZE”) opcode.
Sourcepub const CALLDATACOPY: OpCode
pub const CALLDATACOPY: OpCode
The 0x37 (“CALLDATACOPY”) opcode.
Sourcepub const EXTCODESIZE: OpCode
pub const EXTCODESIZE: OpCode
The 0x3B (“EXTCODESIZE”) opcode.
Sourcepub const EXTCODECOPY: OpCode
pub const EXTCODECOPY: OpCode
The 0x3C (“EXTCODECOPY”) opcode.
Sourcepub const RETURNDATASIZE: OpCode
pub const RETURNDATASIZE: OpCode
The 0x3D (“RETURNDATASIZE”) opcode.
Sourcepub const RETURNDATACOPY: OpCode
pub const RETURNDATACOPY: OpCode
The 0x3E (“RETURNDATACOPY”) opcode.
Sourcepub const EXTCODEHASH: OpCode
pub const EXTCODEHASH: OpCode
The 0x3F (“EXTCODEHASH”) opcode.
Sourcepub const DIFFICULTY: OpCode
pub const DIFFICULTY: OpCode
The 0x44 (“DIFFICULTY”) opcode.
Sourcepub const SELFBALANCE: OpCode
pub const SELFBALANCE: OpCode
The 0x47 (“SELFBALANCE”) opcode.
Sourcepub const BLOBBASEFEE: OpCode
pub const BLOBBASEFEE: OpCode
The 0x4A (“BLOBBASEFEE”) opcode.
Sourcepub const DELEGATECALL: OpCode
pub const DELEGATECALL: OpCode
The 0xF4 (“DELEGATECALL”) opcode.
Sourcepub const STATICCALL: OpCode
pub const STATICCALL: OpCode
The 0xFA (“STATICCALL”) opcode.
Sourcepub const SELFDESTRUCT: OpCode
pub const SELFDESTRUCT: OpCode
The 0xFF (“SELFDESTRUCT”) opcode.
Trait Implementations§
Source§impl Ord for OpCode
impl Ord for OpCode
Source§impl PartialOrd for OpCode
impl PartialOrd for OpCode
impl Copy for OpCode
impl Eq for OpCode
impl StructuralPartialEq for OpCode
Auto Trait Implementations§
impl Freeze for OpCode
impl RefUnwindSafe for OpCode
impl Send for OpCode
impl Sync for OpCode
impl Unpin for OpCode
impl UnwindSafe for OpCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.