Skip to content

Commit e7498c3

Browse files
committed
Refactor stack functions to use opcode parameter instead of opcode_id
- Updated the `stack_added`, `stack_needed`, and `stack_delta` functions to accept `opcode` as a parameter instead of `opcode_id`, improving clarity and consistency in the codebase.
1 parent 3e0ea64 commit e7498c3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kevm-pyk/src/kevm_pyk/summarizer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ def get_todo_list() -> list[str]:
289289
return todo_list
290290

291291

292-
def stack_added(opcode_id: str) -> int:
292+
def stack_added(opcode: str) -> int:
293293
"""
294294
Return the stack size added for the opcode, corresponding `#stackAdded` in the semantics.
295295
"""
296-
if opcode_id in [
296+
if opcode in [
297297
'CALLDATACOPY',
298298
'RETURNDATACOPY',
299299
'CODECOPY',
@@ -318,11 +318,11 @@ def stack_added(opcode_id: str) -> int:
318318
return 1
319319

320320

321-
def stack_needed(opcode_id: str) -> int:
321+
def stack_needed(opcode: str) -> int:
322322
"""
323323
Return the stack size needed for the opcode, corresponding `#stackNeeded` in the semantics.
324324
"""
325-
opcode = OPCODES[opcode_id].label.name
325+
opcode = OPCODES[opcode].label.name
326326
if 'CallOp' in opcode:
327327
return 7
328328
elif 'CallSixOp' in opcode:
@@ -342,16 +342,16 @@ def stack_needed(opcode_id: str) -> int:
342342
return 0
343343

344344

345-
def stack_delta(opcode_id: str) -> int | None:
345+
def stack_delta(opcode: str) -> int | None:
346346
"""
347347
Return the stack delta for the opcode, corresponding `#stackDelta` in the semantics.
348348
"""
349-
if opcode_id == 'DUP':
349+
if opcode == 'DUP':
350350
return 1
351-
elif opcode_id in ['LOG', 'SWAP']:
351+
elif opcode in ['LOG', 'SWAP']:
352352
return None
353353
else:
354-
delta = stack_added(opcode_id) - stack_needed(opcode_id)
354+
delta = stack_added(opcode) - stack_needed(opcode)
355355
return delta if delta > 0 else None
356356

357357

0 commit comments

Comments
 (0)