Merge branch 'master' into python-2.4

This commit is contained in:
rocky
2017-12-04 09:41:49 -05:00
12 changed files with 33 additions and 23 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -269,7 +269,7 @@ class Python26Parser(Python2Parser):
return_stmt_lambda LAMBDA_MARKER return_stmt_lambda LAMBDA_MARKER
# conditional_true are for conditions which always evaluate true # conditional_true are for conditions which always evaluate true
# There is dead or non-optional remnants of the condition code though, # There is dead or non-optional remnants of the condition code though,
# and we use that to match on to reconstruct the source more accurately # and we use that to match on to reconstruct the source more accurately
expr ::= conditional_true expr ::= conditional_true
conditional_true ::= expr jf_pop expr COME_FROM conditional_true ::= expr jf_pop expr COME_FROM

View File

@@ -85,7 +85,7 @@ class Python27Parser(Python2Parser):
compare_chained2 ::= expr COMPARE_OP RETURN_VALUE compare_chained2 ::= expr COMPARE_OP RETURN_VALUE
# conditional_true are for conditions which always evaluate true # conditional_true are for conditions which always evaluate true
# There is dead or non-optional remnants of the condition code though, # There is dead or non-optional remnants of the condition code though,
# and we use that to match on to reconstruct the source more accurately # and we use that to match on to reconstruct the source more accurately
expr ::= conditional_true expr ::= conditional_true
conditional_true ::= expr JUMP_FORWARD expr COME_FROM conditional_true ::= expr JUMP_FORWARD expr COME_FROM

View File

@@ -39,6 +39,8 @@ class Python3Parser(PythonParser):
comp_for ::= expr _for store comp_iter CONTINUE comp_for ::= expr _for store comp_iter CONTINUE
comp_for ::= expr _for store comp_iter JUMP_BACK comp_for ::= expr _for store comp_iter JUMP_BACK
list_comp ::= BUILD_LIST_0 list_iter
lc_body ::= expr LIST_APPEND
list_for ::= expr FOR_ITER store list_iter jb_or_c list_for ::= expr FOR_ITER store list_iter jb_or_c
# This is seen in PyPy, but possibly it appears on other Python 3? # This is seen in PyPy, but possibly it appears on other Python 3?
@@ -402,6 +404,12 @@ class Python3Parser(PythonParser):
# a JUMP_FORWARD to another JUMP_FORWARD can get turned into # a JUMP_FORWARD to another JUMP_FORWARD can get turned into
# a JUMP_ABSOLUTE with no COME_FROM # a JUMP_ABSOLUTE with no COME_FROM
conditional ::= expr jmp_false expr jump_absolute_else expr conditional ::= expr jmp_false expr jump_absolute_else expr
# conditional_true are for conditions which always evaluate true
# There is dead or non-optional remnants of the condition code though,
# and we use that to match on to reconstruct the source more accurately
expr ::= conditional_true
conditional_true ::= expr JUMP_FORWARD expr COME_FROM
""" """
@staticmethod @staticmethod
@@ -752,20 +760,25 @@ class Python3Parser(PythonParser):
('kwarg ' * args_kw) + ('kwarg ' * args_kw) +
'expr ' * nak + opname) 'expr ' * nak + opname)
self.add_unique_rule(rule, opname, token.attr, customize) self.add_unique_rule(rule, opname, token.attr, customize)
elif opname == 'DELETE_DEREF':
self.addRule("""
stmt ::= del_deref_stmt
del_deref_stmt ::= DELETE_DEREF
""", nop_func)
elif opname == 'JUMP_IF_NOT_DEBUG': elif opname == 'JUMP_IF_NOT_DEBUG':
v = token.attr v = token.attr
self.add_unique_rule( self.addRule("""
"stmt ::= assert_pypy", opname, v, customize) stmt ::= assert_pypy
self.add_unique_rule( stmt ::= assert2_pypy", nop_func)
"stmt ::= assert2_pypy", opname_base, v, customize) assert_pypy ::= JUMP_IF_NOT_DEBUG assert_expr jmp_true
self.add_unique_rule( LOAD_ASSERT RAISE_VARARGS_1 COME_FROM
"assert_pypy ::= JUMP_IF_NOT_DEBUG assert_expr jmp_true " assert2_pypy ::= JUMP_IF_NOT_DEBUG assert_expr jmp_true
"LOAD_ASSERT RAISE_VARARGS_1 COME_FROM", LOAD_ASSERT expr CALL_FUNCTION_1
opname, token.attr, customize) RAISE_VARARGS_1 COME_FROM
self.add_unique_rule( assert2_pypy ::= JUMP_IF_NOT_DEBUG assert_expr jmp_true
"assert2_pypy ::= JUMP_IF_NOT_DEBUG assert_expr jmp_true " LOAD_ASSERT expr CALL_FUNCTION_1
"LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1 COME_FROM", RAISE_VARARGS_1 COME_FROM,
opname_base, v, customize) """, nop_func)
continue continue
elif opname == 'LOAD_BUILD_CLASS': elif opname == 'LOAD_BUILD_CLASS':
seen_LOAD_BUILD_CLASS = True seen_LOAD_BUILD_CLASS = True

View File

@@ -45,11 +45,6 @@ class Python32Parser(Python3Parser):
_ifstmts_jump ::= c_stmts_opt _ifstmts_jump ::= c_stmts_opt
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms
stmt ::= del_deref_stmt
del_deref_stmt ::= DELETE_DEREF
list_comp ::= BUILD_LIST_0 list_iter
lc_body ::= expr LIST_APPEND
kv3 ::= expr expr STORE_MAP kv3 ::= expr expr STORE_MAP
""" """
pass pass

View File

@@ -1082,9 +1082,10 @@ class SourceWalker(GenericASTTraversal, object):
assert n == 'list_iter' assert n == 'list_iter'
# find innermost node # Find the list comprehension body. It is the inner-most
# node.
while n == 'list_iter': while n == 'list_iter':
n = n[0] # recurse one step n = n[0] # iterate one nesting deeper
if n == 'list_for': n = n[3] if n == 'list_for': n = n[3]
elif n == 'list_if': n = n[2] elif n == 'list_if': n = n[2]
elif n == 'list_if_not': n= n[2] elif n == 'list_if_not': n= n[2]
@@ -1140,9 +1141,10 @@ class SourceWalker(GenericASTTraversal, object):
assert n == 'list_iter' assert n == 'list_iter'
assert store == 'store' assert store == 'store'
# find innermost node # Find the list comprehension body. It is the inner-most
# node.
while n == 'list_iter': while n == 'list_iter':
n = n[0] # recurse one step n = n[0] # iterate one nesting deeper
if n == 'list_for': n = n[3] if n == 'list_for': n = n[3]
elif n == 'list_if': n = n[2] elif n == 'list_if': n = n[2]
elif n == 'list_if_not': n= n[2] elif n == 'list_if_not': n= n[2]