More explicit about 3.5 UNMAP_PACK

Have to reduce 3.5 bytecode testing for now, code is more solid.
This commit is contained in:
rocky
2017-05-20 07:40:59 -04:00
parent 2ab7aa2f48
commit d3794ec9af
5 changed files with 22 additions and 8 deletions

View File

@@ -625,6 +625,14 @@ class Python3Parser(PythonParser):
self.add_make_function_rule(rule_pat, opname, token.attr, customize)
elif opname == 'LOAD_BUILD_CLASS':
self.custom_build_class_rule(opname, i, token, tokens, customize)
elif opname.startswith('BUILD_LIST_UNPACK'):
v = token.attr
rule = ('build_list_unpack ::= ' + 'expr1024 ' * int(v//1024) +
'expr32 ' * int((v//32) % 32) +
'expr ' * (v % 32) + opname)
self.add_unique_rule(rule, opname, token.attr, customize)
rule = 'expr ::= build_list_unpack'
self.add_unique_rule(rule, opname, token.attr, customize)
elif opname_base in ('BUILD_LIST', 'BUILD_TUPLE', 'BUILD_SET'):
v = token.attr
rule = ('build_list ::= ' + 'expr1024 ' * int(v//1024) +
@@ -680,7 +688,7 @@ class Python3Parser(PythonParser):
self.add_unique_rule(rule, opname, token.attr, customize)
rule = ('unmap_dict ::= ' +
('mapexpr ' * token.attr) +
' BUILD_MAP_UNPACK')
'BUILD_MAP_UNPACK')
else:
rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2)
self.add_unique_rule(rule, opname, token.attr, customize)

View File

@@ -359,6 +359,9 @@ class SourceWalker(GenericASTTraversal, object):
self.prune()
self.n_async_call_function = n_async_call_function
self.n_build_list_unpack = self.n_build_list
def n_funcdef(node):
code_node = node[0][1]
if (code_node == 'LOAD_CONST' and iscode(code_node.attr)
@@ -1613,6 +1616,13 @@ class SourceWalker(GenericASTTraversal, object):
# will assume that if the text ends in *.
last_was_star = self.f.getvalue().endswith('*')
if lastnodetype.endswith('UNPACK'):
# FIXME: need to handle range of BUILD_LIST_UNPACK
have_star = True
# endchar = ''
else:
have_star = False
if lastnodetype.startswith('BUILD_LIST'):
self.write('['); endchar = ']'
elif lastnodetype.startswith('BUILD_TUPLE'):
@@ -1624,11 +1634,7 @@ class SourceWalker(GenericASTTraversal, object):
elif lastnodetype.startswith('ROT_TWO'):
self.write('('); endchar = ')'
else:
raise 'Internal Error: n_build_list expects list, tuple, set, or unpack'
have_star = False
if lastnodetype.endswith('UNPACK'):
# FIXME: need to handle range of BUILD_LIST_UNPACK
have_star = True
raise TypeError('Internal Error: n_build_list expects list, tuple, set, or unpack')
flat_elems = []
for elem in node:
@@ -1854,7 +1860,7 @@ class SourceWalker(GenericASTTraversal, object):
'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'):
if v == 0:
str = '%c(%C' # '%C' is a dummy here ...
p2 = (0, 0, None) # .. because of this
p2 = (0, -1, None) # .. because of this
else:
str = '%c(%C, '
p2 = (1, -2, ', ')
@@ -1866,7 +1872,7 @@ class SourceWalker(GenericASTTraversal, object):
str = '%c(*%C, %c)'
elif str == '%c(%C':
str = '%c(*%C)'
# p2 = (1, -1, 100)
p2 = (1, -1, 100)
else:
str += '*%c)'
entry = (str, 0, p2, -2)