mirror of
https://github.com/syssec-utd/pylingual.git
synced 2026-05-10 18:39:03 -07:00
Merge branch 'cflow-refactor' of https://github.com/XinlongCS/pylingual into cflow-refactor
This commit is contained in:
@@ -3,3 +3,4 @@ from .remove_extended_arg import remove_extended_arg
|
||||
from .remove_docstrings import remove_docstrings
|
||||
from .remove_nop import remove_nop
|
||||
from .fix_indirect_jump import fix_indirect_jump
|
||||
from .replace_firstlno import replace_firstlno
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from ..EditableBytecode import EditableBytecode
|
||||
|
||||
import itertools
|
||||
|
||||
|
||||
def replace_firstlno(bytecode: EditableBytecode):
|
||||
to_replace = next((load_const for load_const, store_name in itertools.pairwise(bytecode.instructions) if load_const.opname == "LOAD_CONST" and store_name.opname == "STORE_NAME" and store_name.argval == "__firstlineno__"), None)
|
||||
if to_replace is not None:
|
||||
to_replace.argval = 0
|
||||
to_replace.argrepr = "0"
|
||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
import networkx as nx
|
||||
from pylingual.control_flow_reconstruction.cfg import CFG
|
||||
from pylingual.editable_bytecode import EditableBytecode, Inst, PYCFile
|
||||
from pylingual.editable_bytecode.bytecode_patches import fix_indirect_jump, fix_unreachable, remove_extended_arg, remove_nop
|
||||
from pylingual.editable_bytecode.bytecode_patches import fix_indirect_jump, fix_unreachable, remove_extended_arg, remove_nop, replace_firstlno
|
||||
from pylingual.editable_bytecode.control_flow_graph import bytecode_to_control_flow_graph
|
||||
|
||||
|
||||
@@ -191,8 +191,8 @@ def compare_pyc(pyc_a: PYCFile | Path, pyc_b: PYCFile | Path) -> list[TestResult
|
||||
pyc_a = pyc_a.copy() if isinstance(pyc_a, PYCFile) else PYCFile(pyc_a)
|
||||
pyc_b = pyc_b.copy() if isinstance(pyc_b, PYCFile) else PYCFile(pyc_b)
|
||||
|
||||
pyc_a.apply_patches([remove_extended_arg, remove_nop, fix_indirect_jump, fix_unreachable, remove_extended_arg])
|
||||
pyc_b.apply_patches([remove_extended_arg, remove_nop, fix_indirect_jump, fix_unreachable, remove_extended_arg])
|
||||
pyc_a.apply_patches([remove_extended_arg, remove_nop, fix_indirect_jump, fix_unreachable, remove_extended_arg, replace_firstlno])
|
||||
pyc_b.apply_patches([remove_extended_arg, remove_nop, fix_indirect_jump, fix_unreachable, remove_extended_arg, replace_firstlno])
|
||||
|
||||
results = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user