pub struct EvmInstruction {
pub opcode: EvmOpcode,
pub data: Option<Vec<u8>>,
pub comment: Option<String>,
}Expand description
A single EVM instruction, consisting of an opcode and optional immediate data.
For PUSH1..PUSH32 opcodes the data field holds the bytes to push.
For all other opcodes data is None.
Fields§
§opcode: EvmOpcodeThe opcode for this instruction.
data: Option<Vec<u8>>Optional immediate data bytes (used by PUSH instructions).
comment: Option<String>Optional human-readable comment for assembly output.
Implementations§
Source§impl EvmInstruction
impl EvmInstruction
Sourcepub fn push(bytes: Vec<u8>) -> Option<Self>
pub fn push(bytes: Vec<u8>) -> Option<Self>
Create a PUSH instruction with the given byte vector.
Automatically selects the correct PUSH1..PUSH32 opcode.
Sourcepub fn push4(val: u32) -> Self
pub fn push4(val: u32) -> Self
Create a PUSH4 instruction for a 4-byte value (used for function selectors).
Sourcepub fn with_comment(self, comment: impl Into<String>) -> Self
pub fn with_comment(self, comment: impl Into<String>) -> Self
Attach a comment to this instruction (for assembly output).
Trait Implementations§
Source§impl Clone for EvmInstruction
impl Clone for EvmInstruction
Source§fn clone(&self) -> EvmInstruction
fn clone(&self) -> EvmInstruction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EvmInstruction
impl Debug for EvmInstruction
Source§impl Display for EvmInstruction
impl Display for EvmInstruction
Source§impl PartialEq for EvmInstruction
impl PartialEq for EvmInstruction
impl StructuralPartialEq for EvmInstruction
Auto Trait Implementations§
impl Freeze for EvmInstruction
impl RefUnwindSafe for EvmInstruction
impl Send for EvmInstruction
impl Sync for EvmInstruction
impl Unpin for EvmInstruction
impl UnsafeUnpin for EvmInstruction
impl UnwindSafe for EvmInstruction
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
Mutably borrows from an owned value. Read more