Small 3.7 steps

This commit is contained in:
rocky
2018-04-13 07:26:32 -04:00
parent 7237658f1f
commit 1890aad660
11 changed files with 18 additions and 4 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

@@ -35,6 +35,13 @@ class Python37Parser(Python36Parser):
# Is there a pattern here? # Is there a pattern here?
attributes ::= IMPORT_FROM ROT_TWO POP_TOP IMPORT_FROM attributes ::= IMPORT_FROM ROT_TWO POP_TOP IMPORT_FROM
# FIXME: generalize and specialize
attribute37 ::= LOAD_NAME LOAD_METHOD
expr ::= attribute37
# FIXME: generalize and specialize
call ::= expr CALL_METHOD_0
""" """
class Python37ParserSingle(Python37Parser, PythonParserSingle): class Python37ParserSingle(Python37Parser, PythonParserSingle):

View File

@@ -140,7 +140,7 @@ class Scanner3(Scanner):
self.opc.BUILD_MAP, self.opc.UNPACK_SEQUENCE, self.opc.BUILD_MAP, self.opc.UNPACK_SEQUENCE,
self.opc.RAISE_VARARGS]) self.opc.RAISE_VARARGS])
if is_pypy: if is_pypy or self.version >= 3.7:
varargs_ops.add(self.opc.CALL_METHOD) varargs_ops.add(self.opc.CALL_METHOD)
if self.version >= 3.5: if self.version >= 3.5:
varargs_ops |= set([self.opc.BUILD_SET_UNPACK, varargs_ops |= set([self.opc.BUILD_SET_UNPACK,
@@ -179,7 +179,7 @@ class Scanner3(Scanner):
bytecode = self.build_instructions(co) bytecode = self.build_instructions(co)
# show_asm = 'after' # show_asm = 'both'
if show_asm in ('both', 'before'): if show_asm in ('both', 'before'):
for instr in bytecode.get_instructions(co): for instr in bytecode.get_instructions(co):
print(instr.disassemble()) print(instr.disassemble())
@@ -347,9 +347,9 @@ class Scanner3(Scanner):
else: else:
opname = '%s_%d' % (opname, pos_args) opname = '%s_%d' % (opname, pos_args)
elif self.is_pypy and opname in ('CALL_METHOD', 'JUMP_IF_NOT_DEBUG'): elif self.is_pypy and opname == 'JUMP_IF_NOT_DEBUG':
# The value in the dict is in special cases in semantic actions, such # The value in the dict is in special cases in semantic actions, such
# as CALL_FUNCTION. The value is not used in these cases, so we put # as JUMP_IF_NOT_DEBUG. The value is not used in these cases, so we put
# in arbitrary value 0. # in arbitrary value 0.
customize[opname] = 0 customize[opname] = 0
elif opname == 'UNPACK_EX': elif opname == 'UNPACK_EX':

View File

@@ -879,6 +879,13 @@ def customize_for_version3(self, version):
self.prune() self.prune()
return return
self.n_return_closure = return_closure self.n_return_closure = return_closure
if version >= 3.7:
PRECEDENCE['attribute37'] = 2
TABLE_DIRECT.update({
'attribute37': ( '%c.%[1]{pattr}', 0 ),
})
pass
pass # version >= 3.6 pass # version >= 3.6
pass # version >= 3.4 pass # version >= 3.4
return return