From 11e819c3764f0ba85cb0f25c22bd7a446109b199 Mon Sep 17 00:00:00 2001 From: Akash S M Date: Sun, 7 Apr 2024 19:10:17 +0530 Subject: [PATCH] Add the modifies_memory macro (#1270) * feat: add modifies_memory macro * refactor --- crates/interpreter/src/instructions/opcode.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/interpreter/src/instructions/opcode.rs b/crates/interpreter/src/instructions/opcode.rs index 8896c9da27..58aea3172e 100644 --- a/crates/interpreter/src/instructions/opcode.rs +++ b/crates/interpreter/src/instructions/opcode.rs @@ -496,6 +496,28 @@ impl OpCode { pub const fn get(self) -> u8 { self.0 } + + /// Returns true if the opcode modifies memory. + /// + /// + #[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)]