[pypy-commit] pypy translation-cleanup: Move replace_in_stack() to FSFrame

rlamy noreply at buildbot.pypy.org
Thu Sep 20 19:38:57 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57414:616e3a5b7a98
Date: 2012-09-07 05:24 +0100
http://bitbucket.org/pypy/pypy/changeset/616e3a5b7a98/

Log:	Move replace_in_stack() to FSFrame

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -310,19 +310,6 @@
             operr = OperationError(operr.w_type, w_value)
         return operr
 
-    # hack for unrolling iterables, don't use this
-    def replace_in_stack(self, oldvalue, newvalue):
-        w_new = Constant(newvalue)
-        f = self.frame
-        stack_items_w = f.locals_stack_w
-        for i in range(f.valuestackdepth-1, f.pycode.co_nlocals-1, -1):
-            w_v = stack_items_w[i]
-            if isinstance(w_v, Constant):
-                if w_v.value is oldvalue:
-                    # replace the topmost item of the stack that is equal
-                    # to 'oldvalue' with 'newvalue'.
-                    stack_items_w[i] = w_new
-                    break
 
 class FlowSpaceFrame(pyframe.CPythonFrame):
 
@@ -431,6 +418,19 @@
             prevblock = parent
         return recorder
 
+    # hack for unrolling iterables, don't use this
+    def replace_in_stack(self, oldvalue, newvalue):
+        w_new = Constant(newvalue)
+        stack_items_w = self.locals_stack_w
+        for i in range(self.valuestackdepth-1, self.pycode.co_nlocals-1, -1):
+            w_v = stack_items_w[i]
+            if isinstance(w_v, Constant):
+                if w_v.value is oldvalue:
+                    # replace the topmost item of the stack that is equal
+                    # to 'oldvalue' with 'newvalue'.
+                    stack_items_w[i] = w_new
+                    break
+
     def handle_bytecode(self, next_instr):
         try:
             next_instr = self.dispatch_bytecode(next_instr)
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -315,7 +315,7 @@
                 except IndexError:
                     raise OperationError(self.w_StopIteration, self.w_None)
                 else:
-                    context.replace_in_stack(it, next_unroller)
+                    context.frame.replace_in_stack(it, next_unroller)
                     return self.wrap(v)
         w_item = self.do_operation("next", w_iter)
         outcome, w_exc_cls, w_exc_value = context.guessexception(StopIteration,


More information about the pypy-commit mailing list