Skip to content

Commit a225bcb

Browse files
Use the upstream llvm_interpret function (#2723)
* Refactor interpreter function to streamline GST data interpretation - Simplified the `interpret` function by removing error handling for subprocess calls and directly utilizing `llvm_interpret`. - Updated the `interpret` function to improve clarity and efficiency by integrating the filtering and conversion of GST data into a single line. - Enhanced documentation to clarify the purpose of the `interpret` function. * Update kevm-pyk/src/kevm_pyk/interpreter.py Co-authored-by: Tamás Tóth <[email protected]> --------- Co-authored-by: Tamás Tóth <[email protected]>
1 parent fdd14c1 commit a225bcb

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

Diff for: kevm-pyk/src/kevm_pyk/interpreter.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,17 @@
33
from typing import TYPE_CHECKING
44

55
from pyk.kdist import kdist
6-
from pyk.kore.parser import KoreParser
7-
from pyk.utils import run_process_2
6+
from pyk.ktool.krun import llvm_interpret
87

98
from .gst_to_kore import filter_gst_keys, gst_to_kore
109

1110
if TYPE_CHECKING:
12-
from subprocess import CompletedProcess
1311
from typing import Any
1412

1513
from pyk.kore.syntax import Pattern
1614

1715

1816
def interpret(gst_data: Any, schedule: str, mode: str, chainid: int, usegas: bool, *, check: bool = True) -> Pattern:
19-
proc_res = _interpret(gst_data, schedule, mode, chainid, usegas)
20-
21-
if check:
22-
proc_res.check_returncode()
23-
24-
kore = KoreParser(proc_res.stdout).pattern()
25-
return kore
26-
27-
28-
def _interpret(gst_data: Any, schedule: str, mode: str, chainid: int, usegas: bool) -> CompletedProcess:
29-
gst_data_filtered = filter_gst_keys(gst_data)
30-
interpreter = kdist.get('evm-semantics.llvm') / 'interpreter'
31-
init_kore = gst_to_kore(gst_data_filtered, schedule, mode, chainid, usegas)
32-
proc_res = run_process_2([str(interpreter), '/dev/stdin', '-1', '/dev/stdout'], input=init_kore.text, check=False)
33-
return proc_res
17+
"""Interpret the given GST data using the LLVM backend."""
18+
init_kore = gst_to_kore(filter_gst_keys(gst_data), schedule, mode, chainid, usegas)
19+
return llvm_interpret(kdist.get('evm-semantics.llvm'), init_kore, check=check)

0 commit comments

Comments
 (0)