More COME_FROM's in Python 3...

Need this to find boundaries of simple if better
This commit is contained in:
rocky
2017-02-20 04:08:51 -05:00
parent 8ef5e5d12b
commit 9491c67779
4 changed files with 31 additions and 3 deletions

Binary file not shown.

View File

@@ -0,0 +1,11 @@
# From 2.6.9 cmd.py
try:
if __file__:
x = 2
x = 3
finally:
if x and __file__:
try:
x = 1
except:
pass

View File

@@ -44,6 +44,10 @@ class Python3Parser(PythonParser):
list_for ::= expr FOR_ITER designator list_iter jb_or_c list_for ::= expr FOR_ITER designator list_iter jb_or_c
# This is seen in PyPy, but possibly it appears on other Python 3?
list_if ::= expr jmp_false list_iter COME_FROM
list_if_not ::= expr jmp_true list_iter COME_FROM
jb_or_c ::= JUMP_BACK jb_or_c ::= JUMP_BACK
jb_or_c ::= CONTINUE jb_or_c ::= CONTINUE
@@ -52,6 +56,9 @@ class Python3Parser(PythonParser):
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
JUMP_BACK RETURN_VALUE RETURN_LAST JUMP_BACK RETURN_VALUE RETURN_LAST
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER designator comp_iter
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
comp_body ::= dict_comp_body comp_body ::= dict_comp_body
comp_body ::= set_comp_body comp_body ::= set_comp_body
dict_comp_body ::= expr expr MAP_ADD dict_comp_body ::= expr expr MAP_ADD
@@ -113,9 +120,11 @@ class Python3Parser(PythonParser):
classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1 classdefdeco1 ::= expr classdefdeco1 CALL_FUNCTION_1
classdefdeco1 ::= expr classdefdeco2 CALL_FUNCTION_1 classdefdeco1 ::= expr classdefdeco2 CALL_FUNCTION_1
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 COME_FROM
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1 assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2 RAISE_VARARGS_1 COME_FROM
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr
RAISE_VARARGS_2 COME_FROM
assert_expr ::= expr assert_expr ::= expr
assert_expr ::= assert_expr_or assert_expr ::= assert_expr_or
@@ -329,6 +338,9 @@ class Python3Parser(PythonParser):
forelselaststmtl ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitel forelselaststmtl ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitel
COME_FROM_LOOP COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
COME_FROM_LOOP COME_FROM_LOOP

View File

@@ -893,6 +893,11 @@ class Scanner3(Scanner):
else: else:
self.fixed_jumps[offset] = rtarget self.fixed_jumps[offset] = rtarget
self.not_continue.add(pre_rtarget) self.not_continue.add(pre_rtarget)
else:
# For now, we'll only tag forward jump.
if rtarget > offset:
self.fixed_jumps[offset] = rtarget
self.not_continue.add(pre_rtarget)
elif op == self.opc.SETUP_EXCEPT: elif op == self.opc.SETUP_EXCEPT: