You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
WIP deal with JUMP_IF_{TRUE,FALSE} vs with POP version
This commit is contained in:
@@ -179,6 +179,9 @@ class Python2Parser(PythonParser):
|
||||
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
try_middle else_suitel COME_FROM
|
||||
|
||||
trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
try_middle COME_FROM
|
||||
|
||||
except_stmts ::= except_stmts except_stmt
|
||||
except_stmts ::= except_stmt
|
||||
|
||||
|
@@ -38,11 +38,21 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
"""
|
||||
|
||||
def p_whilestmt(self, args):
|
||||
"""
|
||||
whilestmt ::= SETUP_LOOP
|
||||
testexpr
|
||||
l_stmts_opt jb_pop
|
||||
POP_BLOCK _come_from
|
||||
|
||||
"""
|
||||
|
||||
def p_misc26(self, args):
|
||||
"""
|
||||
jmp_true ::= JUMP_IF_TRUE POP_TOP
|
||||
jmp_false ::= JUMP_IF_FALSE POP_TOP
|
||||
jf_pop ::= JUMP_FORWARD POP_TOP
|
||||
jb_pop ::= JUMP_BACK POP_TOP
|
||||
|
||||
_ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM
|
||||
"""
|
||||
|
@@ -10,9 +10,6 @@ class Python27Parser(Python2Parser):
|
||||
|
||||
def p_try27(self, args):
|
||||
"""
|
||||
trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
try_middle COME_FROM
|
||||
|
||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts
|
||||
END_FINALLY COME_FROM
|
||||
try_middle ::= jmp_abs COME_FROM except_stmts
|
||||
|
@@ -704,6 +704,10 @@ class Scanner2(scan.Scanner):
|
||||
if op in (self.opc.JUMP_IF_FALSE_OR_POP, self.opc.JUMP_IF_TRUE_OR_POP):
|
||||
if (oparg > i):
|
||||
label = oparg
|
||||
elif self.version < 2.7 and op in self.opc.hasjabs:
|
||||
if op in (self.opc.JUMP_IF_FALSE, self.opc.JUMP_IF_TRUE):
|
||||
if (oparg > i):
|
||||
label = oparg
|
||||
|
||||
if label is not None and label != -1:
|
||||
targets[label] = targets.get(label, []) + [i]
|
||||
|
Reference in New Issue
Block a user