You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Back off of previous refactor a little bit
This commit is contained in:
@@ -250,19 +250,23 @@ class Python2Parser(PythonParser):
|
|||||||
JUMP_BACK
|
JUMP_BACK
|
||||||
""", nop_func)
|
""", nop_func)
|
||||||
|
|
||||||
# For a rough break out on the first word. This may
|
# # For a rough break out on the first word. This may
|
||||||
# include instructions that don't need customization,
|
# # include instructions that don't need customization,
|
||||||
# but we'll do a finer check after the rough breakout.
|
# # but we'll do a finer check after the rough breakout.
|
||||||
customize_instruction_basenames = frozenset(
|
# customize_instruction_basenames = frozenset(
|
||||||
('BUILD', 'CALL', 'CONTINUE',
|
# ('BUILD', 'CALL', 'CONTINUE',
|
||||||
'DELETE', 'DUP', 'EXEC', 'JUMP',
|
# 'DELETE', 'DUP', 'EXEC', 'JUMP',
|
||||||
'LOAD', 'LOOKUP', 'MAKE', 'SETUP',
|
# 'LOAD', 'LOOKUP', 'MAKE', 'SETUP',
|
||||||
'RAISE', 'UNPACK'))
|
# 'RAISE', 'UNPACK'))
|
||||||
|
|
||||||
for i, token in enumerate(tokens):
|
for i, token in enumerate(tokens):
|
||||||
|
|
||||||
opname = token.kind
|
opname = token.kind
|
||||||
if opname[:opname.find('_')] not in customize_instruction_basenames:
|
|
||||||
|
# FIXME
|
||||||
|
# if (opname[:opname.find('_')]
|
||||||
|
# not in customize_instruction_basenames):
|
||||||
|
|
||||||
|
if opname not in customize:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
opname_base = opname[:opname.rfind('_')]
|
opname_base = opname[:opname.rfind('_')]
|
||||||
|
@@ -98,8 +98,7 @@ class Scanner2(Scanner):
|
|||||||
# list of tokens/instructions
|
# list of tokens/instructions
|
||||||
tokens = []
|
tokens = []
|
||||||
|
|
||||||
# "customize" is ny pretty much legacy.
|
# "customize" is in the process of going away here
|
||||||
# We still use it though to signal we have a PyPy program
|
|
||||||
customize = {}
|
customize = {}
|
||||||
|
|
||||||
if self.is_pypy:
|
if self.is_pypy:
|
||||||
@@ -246,6 +245,17 @@ class Scanner2(Scanner):
|
|||||||
op_name = 'BUILD_MAP_n'
|
op_name = 'BUILD_MAP_n'
|
||||||
else:
|
else:
|
||||||
op_name = '%s_%d' % (op_name, oparg)
|
op_name = '%s_%d' % (op_name, oparg)
|
||||||
|
customize[op_name] = oparg
|
||||||
|
elif self.is_pypy and op_name in frozenset(
|
||||||
|
"""LOOKUP_METHOD JUMP_IF_NOT_DEBUG SETUP_EXCEPT SETUP_FINALLY""".split()):
|
||||||
|
# The value in the dict is in special cases in semantic actions, such
|
||||||
|
# as CALL_FUNCTION. The value is not used in these cases, so we put
|
||||||
|
# in arbitrary value 0.
|
||||||
|
customize[op_name] = 0
|
||||||
|
elif op_name in """
|
||||||
|
CONTINUE_LOOP EXEC_STMT LOAD_LISTCOMP LOAD_SETCOMP
|
||||||
|
""".split():
|
||||||
|
customize[op_name] = 0
|
||||||
elif op == self.opc.JUMP_ABSOLUTE:
|
elif op == self.opc.JUMP_ABSOLUTE:
|
||||||
# Further classify JUMP_ABSOLUTE into backward jumps
|
# Further classify JUMP_ABSOLUTE into backward jumps
|
||||||
# which are used in loops, and "CONTINUE" jumps which
|
# which are used in loops, and "CONTINUE" jumps which
|
||||||
|
Reference in New Issue
Block a user