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 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) -> Self
pub unsafe fn new_unchecked(opcode: u8) -> Self
Instantiate 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.
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 that 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://bluealloy.github.io/revm/crates/interpreter/memory.html#opcodes https://github.com/crytic/evm-opcodes
Source§impl OpCode
impl OpCode
Sourcepub const SIGNEXTEND: Self = _
pub const SIGNEXTEND: Self = _
The 0x0B
(“SIGNEXTEND”) opcode.
Sourcepub const CALLDATALOAD: Self = _
pub const CALLDATALOAD: Self = _
The 0x35
(“CALLDATALOAD”) opcode.
Sourcepub const CALLDATASIZE: Self = _
pub const CALLDATASIZE: Self = _
The 0x36
(“CALLDATASIZE”) opcode.
Sourcepub const CALLDATACOPY: Self = _
pub const CALLDATACOPY: Self = _
The 0x37
(“CALLDATACOPY”) opcode.
Sourcepub const EXTCODESIZE: Self = _
pub const EXTCODESIZE: Self = _
The 0x3B
(“EXTCODESIZE”) opcode.
Sourcepub const EXTCODECOPY: Self = _
pub const EXTCODECOPY: Self = _
The 0x3C
(“EXTCODECOPY”) opcode.
Sourcepub const RETURNDATASIZE: Self = _
pub const RETURNDATASIZE: Self = _
The 0x3D
(“RETURNDATASIZE”) opcode.
Sourcepub const RETURNDATACOPY: Self = _
pub const RETURNDATACOPY: Self = _
The 0x3E
(“RETURNDATACOPY”) opcode.
Sourcepub const EXTCODEHASH: Self = _
pub const EXTCODEHASH: Self = _
The 0x3F
(“EXTCODEHASH”) opcode.
Sourcepub const DIFFICULTY: Self = _
pub const DIFFICULTY: Self = _
The 0x44
(“DIFFICULTY”) opcode.
Sourcepub const SELFBALANCE: Self = _
pub const SELFBALANCE: Self = _
The 0x47
(“SELFBALANCE”) opcode.
Sourcepub const BLOBBASEFEE: Self = _
pub const BLOBBASEFEE: Self = _
The 0x4A
(“BLOBBASEFEE”) opcode.
Sourcepub const RETURNCONTRACT: Self = _
pub const RETURNCONTRACT: Self = _
The 0xEE
(“RETURNCONTRACT”) opcode.
Sourcepub const DELEGATECALL: Self = _
pub const DELEGATECALL: Self = _
The 0xF4
(“DELEGATECALL”) opcode.
Sourcepub const RETURNDATALOAD: Self = _
pub const RETURNDATALOAD: Self = _
The 0xF7
(“RETURNDATALOAD”) opcode.
Sourcepub const EXTDELEGATECALL: Self = _
pub const EXTDELEGATECALL: Self = _
The 0xF9
(“EXTDELEGATECALL”) opcode.
Sourcepub const STATICCALL: Self = _
pub const STATICCALL: Self = _
The 0xFA
(“STATICCALL”) opcode.
Sourcepub const EXTSTATICCALL: Self = _
pub const EXTSTATICCALL: Self = _
The 0xFB
(“EXTSTATICCALL”) opcode.
Sourcepub const SELFDESTRUCT: Self = _
pub const SELFDESTRUCT: Self = _
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.