Skip to content

Commit f609c22

Browse files
Merge pull request #35 from feliam/dev-fixinstrospection1
Fix mem read/write introspection
2 parents d27daf1 + 0a02e6d commit f609c22

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pyevmasm/evmasm.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -270,42 +270,42 @@ def writes_to_stack(self):
270270
@property
271271
def writes_to_memory(self):
272272
""" True if the instruction writes to memory """
273-
return self.semantics in ('MSTORE', 'MSTORE8', 'CALLDATACOPY', 'CODECOPY', 'EXTCODECOPY')
273+
return self.semantics in {'MSTORE', 'MSTORE8', 'CALLDATACOPY', 'CODECOPY', 'EXTCODECOPY', 'RETURNDATACOPY', 'CALL', 'STATICCALL', 'DELEGATECALL', 'CALLCODE'}
274274

275275
@property
276276
def reads_from_memory(self):
277277
""" True if the instruction reads from memory """
278-
return self.semantics in ('MLOAD', 'CREATE', 'CALL', 'CALLCODE', 'RETURN', 'DELEGATECALL', 'REVERT')
278+
return self.semantics in {'MLOAD', 'CREATE', 'CALL', 'STATICCALL', 'DELEGATECALL', 'CALLCODE', 'RETURN', 'REVERT'}
279279

280280
@property
281281
def writes_to_storage(self):
282282
""" True if the instruction writes to the storage """
283-
return self.semantics in 'SSTORE'
283+
return self.semantics == 'SSTORE'
284284

285285
@property
286286
def reads_from_storage(self):
287287
""" True if the instruction reads from the storage """
288-
return self.semantics in 'SLOAD'
288+
return self.semantics == 'SLOAD'
289289

290290
@property
291291
def is_terminator(self):
292292
""" True if the instruction is a basic block terminator """
293-
return self.semantics in ('RETURN', 'STOP', 'INVALID', 'JUMP', 'JUMPI', 'SELFDESTRUCT', 'REVERT')
293+
return self.semantics in {'RETURN', 'STOP', 'INVALID', 'JUMP', 'JUMPI', 'SELFDESTRUCT', 'REVERT'}
294294

295295
@property
296296
def is_endtx(self):
297297
""" True if the instruction is a transaction terminator """
298-
return self.semantics in ('RETURN', 'STOP', 'INVALID', 'SELFDESTRUCT', 'REVERT')
298+
return self.semantics in {'RETURN', 'STOP', 'INVALID', 'SELFDESTRUCT', 'REVERT'}
299299

300300
@property
301301
def is_starttx(self):
302302
""" True if the instruction is a transaction initiator """
303-
return self.semantics in ('CREATE', 'CREATE2', 'CALL', 'CALLCODE', 'DELEGATECALL')
303+
return self.semantics in {'CREATE', 'CREATE2', 'CALL', 'CALLCODE', 'DELEGATECALL', 'STATICCALL'}
304304

305305
@property
306306
def is_branch(self):
307307
""" True if the instruction is a jump """
308-
return self.semantics in ('JUMP', 'JUMPI')
308+
return self.semantics in {'JUMP', 'JUMPI'}
309309

310310
@property
311311
def is_environmental(self):
@@ -325,8 +325,8 @@ def uses_block_info(self):
325325
@property
326326
def is_arithmetic(self):
327327
""" True if the instruction is an arithmetic operation """
328-
return self.semantics in (
329-
'ADD', 'MUL', 'SUB', 'DIV', 'SDIV', 'MOD', 'SMOD', 'ADDMOD', 'MULMOD', 'EXP', 'SIGNEXTEND', 'SHL', 'SHR', 'SAR')
328+
return self.semantics in {
329+
'ADD', 'MUL', 'SUB', 'DIV', 'SDIV', 'MOD', 'SMOD', 'ADDMOD', 'MULMOD', 'EXP', 'SIGNEXTEND', 'SHL', 'SHR', 'SAR'}
330330

331331

332332
def assemble_one(asmcode, pc=0, fork=DEFAULT_FORK):

0 commit comments

Comments
 (0)