Skip to content

Commit 20e6319

Browse files
committed
review suggestions
1 parent ee8213b commit 20e6319

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

kevm-pyk/src/kevm_pyk/kevm.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import TYPE_CHECKING
4+
from typing import TYPE_CHECKING, NamedTuple
55

66
from pyk.cterm import CTerm
77
from pyk.kast import KInner
@@ -48,18 +48,12 @@
4848
_LOGGER: Final = logging.getLogger(__name__)
4949

5050

51-
class CustomStep:
51+
class CustomStep(NamedTuple):
5252
"""Encapsulates a custom step definition consisting of an abstract pattern and its execution function."""
5353

5454
pattern: KSequence
5555
exec_fn: Callable[[Subst, CTerm, CTermSymbolic], KCFGExtendResult | None]
5656

57-
def __init__(
58-
self, pattern: KSequence, exec_fn: Callable[[Subst, CTerm, CTermSymbolic], KCFGExtendResult | None]
59-
) -> None:
60-
self.pattern = pattern
61-
self.exec_fn = exec_fn
62-
6357
def check_pattern_match(self, cterm: CTerm) -> bool:
6458
return self.pattern.match(cterm.cell('K_CELL')) is not None
6559

@@ -76,13 +70,13 @@ def try_execute(self, cterm: CTerm, cterm_symbolic: CTermSymbolic) -> KCFGExtend
7670
class KEVMSemantics(DefaultSemantics):
7771
auto_abstract_gas: bool
7872
allow_symbolic_program: bool
79-
_custom_steps: tuple[CustomStep]
73+
_custom_steps: tuple[CustomStep, ...]
8074

8175
def __init__(
8276
self,
8377
auto_abstract_gas: bool = False,
8478
allow_symbolic_program: bool = False,
85-
custom_step_definitions: tuple[CustomStep] = None,
79+
custom_step_definitions: tuple[CustomStep] | None = None,
8680
) -> None:
8781
self.auto_abstract_gas = auto_abstract_gas
8882
self.allow_symbolic_program = allow_symbolic_program
@@ -249,7 +243,7 @@ def _exec_load_custom_step(self, subst: Subst, cterm: CTerm, _c: CTermSymbolic)
249243
return Step(new_cterm, 1, (), ['EVM.program.load'], cut=True)
250244

251245
def can_make_custom_step(self, cterm: CTerm) -> bool:
252-
return any(c_step.check_pattern_match() for c_step in self._custom_steps)
246+
return any(c_step.check_pattern_match(cterm) for c_step in self._custom_steps)
253247

254248
def is_mergeable(self, ct1: CTerm, ct2: CTerm) -> bool:
255249
"""Given two CTerms of Edges' targets, check if they are mergeable.

0 commit comments

Comments
 (0)