From 1e4dc5219741862999ac04ac865bdccb6f35b71e Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Nov 2016 07:27:13 -0500 Subject: [PATCH] WIP remove COME_FROMs around ignore_if's --- uncompyle6/parsers/parse26.py | 31 +++++++++++++++---------------- uncompyle6/scanners/scanner2.py | 6 +++--- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 630ad784..511cc2bf 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -23,15 +23,15 @@ class Python26Parser(Python2Parser): JUMP_IF_FALSE POP_TOP POP_TOP designator POP_TOP try_middle ::= JUMP_FORWARD COME_FROM except_stmts - come_from_pop END_FINALLY COME_FROM + POP_TOP END_FINALLY COME_FROM try_middle ::= jmp_abs COME_FROM except_stmts POP_TOP END_FINALLY try_middle ::= jmp_abs COME_FROM except_stmts - come_from_pop END_FINALLY + POP_TOP END_FINALLY - trystmt ::= SETUP_EXCEPT suite_stmts_opt come_from_pop + trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_TOP try_middle # Sometimes we don't put in COME_FROM to the next statement @@ -47,7 +47,7 @@ class Python26Parser(Python2Parser): _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM POP_TOP - except_suite ::= c_stmts_opt JUMP_FORWARD come_from_pop + except_suite ::= c_stmts_opt JUMP_FORWARD POP_TOP # Python 3 also has this. come_froms ::= come_froms COME_FROM @@ -70,9 +70,9 @@ class Python26Parser(Python2Parser): jmp_true ::= JUMP_IF_TRUE POP_TOP jmp_false ::= JUMP_IF_FALSE POP_TOP - jf_pop ::= JUMP_FORWARD come_from_pop - jf_pop ::= JUMP_ABSOLUTE come_from_pop - jb_pop ::= JUMP_BACK come_from_pop + jf_pop ::= JUMP_FORWARD POP_TOP + jf_pop ::= JUMP_ABSOLUTE POP_TOP + jb_pop ::= JUMP_BACK POP_TOP jb_cont ::= JUMP_BACK jb_cont ::= CONTINUE @@ -85,13 +85,12 @@ class Python26Parser(Python2Parser): jb_bp_come_from ::= JUMP_BACK bp_come_from _ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM - _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop + _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM POP_TOP _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms POP_TOP COME_FROM # This is what happens after a jump where # we start a new block. For reasons I don't fully # understand, there is also a value on the top of the stack - come_from_pop ::= COME_FROM POP_TOP come_froms_pop ::= come_froms POP_TOP """ @@ -145,12 +144,12 @@ class Python26Parser(Python2Parser): whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_pop POP_BLOCK else_suite COME_FROM - return_stmt ::= ret_expr RETURN_END_IF come_from_pop - return_stmt ::= ret_expr RETURN_VALUE come_from_pop - return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop + return_stmt ::= ret_expr RETURN_END_IF POP_TOP + return_stmt ::= ret_expr RETURN_VALUE POP_TOP + return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP - iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop - iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop + iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK POP_TOP + iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE POP_TOP while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM @@ -186,7 +185,7 @@ class Python26Parser(Python2Parser): # Make sure we keep indices the same as 2.7 setup_loop_lf ::= SETUP_LOOP LOAD_FAST genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter jb_bp_come_from - genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK come_from_pop jb_bp_come_from + genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK POP_TOP jb_bp_come_from genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 COME_FROM ''' @@ -208,7 +207,7 @@ class Python26Parser(Python2Parser): def p_except26(self, args): ''' - except_suite ::= c_stmts_opt jmp_abs come_from_pop + except_suite ::= c_stmts_opt jmp_abs POP_TOP ''' def p_misc26(self, args): diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 2af66a98..ad6fb22a 100644 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -879,9 +879,9 @@ class Scanner2(scan.Scanner): and self.code[offset+4] == self.opc.END_FINALLY))): # FIXME: rocky: I think we need something like this... - # if offset not in set(self.ignore_if): - # targets[label] = targets.get(label, []) + [offset] - targets[label] = targets.get(label, []) + [offset] + if offset not in set(self.ignore_if): + targets[label] = targets.get(label, []) + [offset] + # targets[label] = targets.get(label, []) + [offset] pass pass