[pypy-svn] r42091 - pypy/dist/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Mon Apr 16 14:47:05 CEST 2007


Author: arigo
Date: Mon Apr 16 14:47:05 2007
New Revision: 42091

Modified:
   pypy/dist/pypy/interpreter/generator.py
   pypy/dist/pypy/interpreter/pyframe.py
Log:
Support for 2.5-style YIELD_VALUE semantic.
The send() method of generators is not implemented yet, though.


Modified: pypy/dist/pypy/interpreter/generator.py
==============================================================================
--- pypy/dist/pypy/interpreter/generator.py	(original)
+++ pypy/dist/pypy/interpreter/generator.py	Mon Apr 16 14:47:05 2007
@@ -39,7 +39,7 @@
         self.running = True
         try:
             try:
-                w_result = self.frame.execute_frame()
+                w_result = self.frame.execute_generator_frame(space.w_None)
             except OperationError:
                 # errors finish a frame
                 self.frame.frame_finished_execution = True

Modified: pypy/dist/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyframe.py	(original)
+++ pypy/dist/pypy/interpreter/pyframe.py	Mon Apr 16 14:47:05 2007
@@ -92,6 +92,14 @@
         else:
             return self.execute_frame()
 
+    def execute_generator_frame(self, w_inputvalue):
+        # opcode semantic change in CPython 2.5: we must pass an input value
+        # when resuming a generator, which goes into the value stack.
+        # (it's always w_None for now - not implemented in generator.py)
+        if self.pycode.magic >= 0xa0df294 and self.last_instr != -1:
+            self.pushvalue(w_inputvalue)
+        return self.execute_frame()
+
     def execute_frame(self):
         """Execute this frame.  Main entry point to the interpreter."""
         executioncontext = self.space.getexecutioncontext()



More information about the Pypy-commit mailing list