[pypy-svn] r77649 - in pypy/trunk/pypy/interpreter: . astcompiler/test
afa at codespeak.net
afa at codespeak.net
Wed Oct 6 15:19:53 CEST 2010
Author: afa
Date: Wed Oct 6 15:19:52 2010
New Revision: 77649
Modified:
pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py
pypy/trunk/pypy/interpreter/pycode.py
pypy/trunk/pypy/interpreter/pyframe.py
Log:
very partial merge of r75516 from branch/fast-forward:
allow these tests to run on top of CPython 2.7
(better identification of pypy and cpython bytecodes)
Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original)
+++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Oct 6 15:19:52 2010
@@ -41,7 +41,7 @@
co_expr = compile(evalexpr, '<evalexpr>', 'eval')
space = self.space
pyco_expr = PyCode._from_code(space, co_expr)
- w_res = pyco_expr.exec_code(space, w_dict, w_dict)
+ w_res = pyco_expr.exec_host_bytecode(space, w_dict, w_dict)
res = space.str_w(space.repr(w_res))
if not isinstance(expected, float):
assert res == repr(expected)
Modified: pypy/trunk/pypy/interpreter/pycode.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pycode.py (original)
+++ pypy/trunk/pypy/interpreter/pycode.py Wed Oct 6 15:19:52 2010
@@ -253,6 +253,12 @@
tuple(self.co_freevars),
tuple(self.co_cellvars) )
+ def exec_host_bytecode(self, w_dict, w_globals, w_locals):
+ from pypy.interpreter.pyframe import CPythonFrame
+ frame = CPythonFrame(self.space, self, w_globals, None)
+ frame.setdictscope(w_locals)
+ return frame.run()
+
def dump(self):
"""A dis.dis() dump of the code object."""
co = self._to_code()
Modified: pypy/trunk/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyframe.py (original)
+++ pypy/trunk/pypy/interpreter/pyframe.py Wed Oct 6 15:19:52 2010
@@ -13,6 +13,7 @@
from pypy.rlib.rarithmetic import intmask
from pypy.rlib import jit, rstack
from pypy.tool import stdlib_opcode
+from pypy.tool.stdlib_opcode import host_bytecode_spec
# Define some opcodes used
g = globals()
@@ -140,7 +141,8 @@
# the following 'assert' is an annotation hint: it hides from
# the annotator all methods that are defined in PyFrame but
# overridden in the {,Host}FrameClass subclasses of PyFrame.
- assert isinstance(self, self.space.FrameClass)
+ assert (isinstance(self, self.space.FrameClass) or
+ not self.space.config.translating)
executioncontext = self.space.getexecutioncontext()
executioncontext.enter(self)
try:
@@ -634,6 +636,18 @@
return space.wrap(self.builtin is not space.builtin)
return space.w_False
+class CPythonFrame(PyFrame):
+ """
+ Execution of host (CPython) opcodes.
+ """
+
+ bytecode_spec = host_bytecode_spec
+ opcode_method_names = host_bytecode_spec.method_names
+ opcodedesc = host_bytecode_spec.opcodedesc
+ opdescmap = host_bytecode_spec.opdescmap
+ HAVE_ARGUMENT = host_bytecode_spec.HAVE_ARGUMENT
+
+
# ____________________________________________________________
def get_block_class(opname):
More information about the Pypy-commit
mailing list