Skip to content

Commit

Permalink
Add the modifies_memory macro (#1270)
Browse files Browse the repository at this point in the history
* feat: add modifies_memory macro

* refactor
  • Loading branch information
h3lio5 committed Apr 7, 2024
1 parent c1eb0e6 commit 11e819c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/interpreter/src/instructions/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,28 @@ impl OpCode {
pub const fn get(self) -> u8 {
self.0
}

/// Returns true if the opcode modifies memory.
/// <https://bluealloy.github.io/revm/crates/interpreter/memory.html#opcodes>
/// <https://github.com/crytic/evm-opcodes>
#[inline]
pub const fn modifies_memory(&self) -> bool {
matches!(
*self,
OpCode::EXTCODECOPY
| OpCode::MLOAD
| OpCode::MSTORE
| OpCode::MSTORE8
| OpCode::MCOPY
| OpCode::CODECOPY
| OpCode::CALLDATACOPY
| OpCode::RETURNDATACOPY
| OpCode::CALL
| OpCode::CALLCODE
| OpCode::DELEGATECALL
| OpCode::STATICCALL
)
}
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down

0 comments on commit 11e819c

Please sign in to comment.