PyPy BUILD_MAP_n. Reinstate bytecode tests

This commit is contained in:
rocky
2016-07-25 21:53:56 -04:00
parent 281f429223
commit 04cc80b0d6
10 changed files with 32 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -280,13 +280,17 @@ class Python2Parser(PythonParser):
opname_base, v, customize)
continue
elif opname_base == 'BUILD_MAP':
if v == 0: # and self.is_pypy:
if opname == 'BUILD_MAP_n':
# PyPy sometimes has no count. Sigh.
rule = ('dictcomp_func ::= BUILD_MAP_n LOAD_FAST FOR_ITER designator '
'comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST')
self.add_unique_rule(rule, 'dictomp_func', 1, customize)
kvlist_n = 'kvlist_n'
rule = 'kvlist_n ::= kvlist_n kv3'
self.add_unique_rule(rule, opname_base, v, customize)
self.add_unique_rule(rule, 'kvlist_n', 0, customize)
rule = 'kvlist_n ::='
self.add_unique_rule(rule, opname_base, v, customize)
self.add_unique_rule(rule, 'kvlist_n', 1, customize)
else:
kvlist_n = "kvlist_%s" % v
rule = kvlist_n + ' ::= ' + ' kv3' * v

View File

@@ -477,7 +477,19 @@ class Python3Parser(PythonParser):
continue
elif opname_base == 'BUILD_MAP':
kvlist_n = "kvlist_%s" % token.attr
if self.version >= 3.5:
if opname == 'BUILD_MAP_n':
# PyPy sometimes has no count. Sigh.
rule = ('dictcomp_func ::= BUILD_MAP_n LOAD_FAST FOR_ITER designator '
'comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST')
self.add_unique_rule(rule, 'dictomp_func', 1, customize)
kvlist_n = 'kvlist_n'
rule = 'kvlist_n ::= kvlist_n kv3'
self.add_unique_rule(rule, 'kvlist_n', 0, customize)
rule = 'kvlist_n ::='
self.add_unique_rule(rule, 'kvlist_n', 1, customize)
rule = "mapexpr ::= BUILD_MAP_n kvlist_n"
elif self.version >= 3.5:
rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2)
self.add_unique_rule(rule, opname, token.attr, customize)
rule = "mapexpr ::= %s %s" % (kvlist_n, opname)

View File

@@ -189,7 +189,10 @@ class Scanner2(scan.Scanner):
self.code[self.prev[offset]] == self.opc.LOAD_CLOSURE:
continue
else:
opname = '%s_%d' % (opname, oparg)
if self.is_pypy and not oparg and opname == 'BUILD_MAP':
opname = 'BUILD_MAP_n'
else:
opname = '%s_%d' % (opname, oparg)
if op != self.opc.BUILD_SLICE:
customize[opname] = oparg
elif self.is_pypy and opname in ('LOOKUP_METHOD', 'JUMP_IF_NOT_DEBUG'):

View File

@@ -238,7 +238,10 @@ class Scanner3(scan.Scanner):
continue
elif op in self.varargs_ops:
pos_args = inst.argval
opname = '%s_%d' % (opname, pos_args)
if self.is_pypy and not pos_args and opname == 'BUILD_MAP':
opname = 'BUILD_MAP_n'
else:
opname = '%s_%d' % (opname, pos_args)
elif self.is_pypy and opname in ('CALL_METHOD', 'JUMP_IF_NOT_DEBUG'):
customize['CALL_METHOD'] = argval
elif opname == 'UNPACK_EX':

View File

@@ -59,7 +59,9 @@ class Token:
if self.op in self.opc.hasjrel:
pattr = "to " + self.pattr
elif self.op in self.opc.hasjabs:
pattr = "to " + self.pattr
self.pattr= str(self.pattr)
if not self.pattr.startswith('to '):
pattr = "to " + str(self.pattr)
pass
# And so on. See xdis/bytecode.py
pass

View File

@@ -1519,7 +1519,7 @@ class SourceWalker(GenericASTTraversal, object):
sep = INDENT_PER_LEVEL[:-1]
self.write('{')
if self.version >= 3.0:
if self.version >= 3.0 and not self.is_pypy:
if node[0].type.startswith('kvlist'):
# Python 3.5+ style key/value list in mapexpr
kv_node = node[0]