From 63820c4300e0a38cbb7727bf0683b37bc115f89d Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 14 Dec 2017 04:00:22 -0500 Subject: [PATCH] Continue parse2/scanner2 refactor --- uncompyle6/parsers/parse2.py | 22 +++++++++++----------- uncompyle6/scanners/scanner2.py | 10 ---------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 36d24a7a..8fdf7ab0 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -250,23 +250,23 @@ class Python2Parser(PythonParser): JUMP_BACK """, nop_func) - # # For a rough break out on the first word. This may - # # include instructions that don't need customization, - # # but we'll do a finer check after the rough breakout. - # customize_instruction_basenames = frozenset( - # ('BUILD', 'CALL', 'CONTINUE', - # 'DELETE', 'DUP', 'EXEC', 'JUMP', - # 'LOAD', 'LOOKUP', 'MAKE', 'SETUP', - # 'RAISE', 'UNPACK')) + # For a rough break out on the first word. This may + # include instructions that don't need customization, + # but we'll do a finer check after the rough breakout. + customize_instruction_basenames = frozenset( + ('BUILD', 'CALL', 'CONTINUE', + 'DELETE', 'DUP', 'EXEC', 'JUMP', + 'LOAD', 'LOOKUP', 'MAKE', 'SETUP', + 'RAISE', 'UNPACK')) for i, token in enumerate(tokens): opname = token.kind # FIXME - # if (opname[:opname.find('_')] - # not in customize_instruction_basenames): + if (opname[:opname.find('_')] + not in customize_instruction_basenames): - if opname not in customize: + # if opname not in customize: continue opname_base = opname[:opname.rfind('_')] diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 7d889ca6..63d01f27 100644 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -246,16 +246,6 @@ class Scanner2(Scanner): else: 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: # Further classify JUMP_ABSOLUTE into backward jumps # which are used in loops, and "CONTINUE" jumps which