[pypy-commit] pypy framestate: move all the SETUP_XXX

rlamy noreply at buildbot.pypy.org
Mon Dec 1 16:59:19 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74776:ec616f23ec15
Date: 2014-11-26 17:18 +0100
http://bitbucket.org/pypy/pypy/changeset/ec616f23ec15/

Log:	move all the SETUP_XXX

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -507,6 +507,36 @@
         block = ExceptBlock(ctx.stackdepth, self.arg)
         ctx.blockstack.append(block)
 
+ at bc_reader.register_opcode
+class SETUP_LOOP(BCInstruction):
+    def eval(self, ctx):
+        from rpython.flowspace.flowcontext import LoopBlock
+        block = LoopBlock(ctx.stackdepth, self.arg)
+        ctx.blockstack.append(block)
+
+ at bc_reader.register_opcode
+class SETUP_FINALLY(BCInstruction):
+    def eval(self, ctx):
+        from rpython.flowspace.flowcontext import FinallyBlock
+        block = FinallyBlock(ctx.stackdepth, self.arg)
+        ctx.blockstack.append(block)
+
+ at bc_reader.register_opcode
+class SETUP_WITH(BCInstruction):
+    def eval(self, ctx):
+        from rpython.flowspace.flowcontext import WithBlock
+        # A simpler version than the 'real' 2.7 one:
+        # directly call manager.__enter__(), don't use special lookup functions
+        # which don't make sense on the RPython type system.
+        w_manager = ctx.peekvalue()
+        w_exit = op.getattr(w_manager, const("__exit__")).eval(ctx)
+        ctx.settopvalue(w_exit)
+        w_enter = op.getattr(w_manager, const('__enter__')).eval(ctx)
+        w_result = op.simple_call(w_enter).eval(ctx)
+        block = WithBlock(ctx.stackdepth, self.arg)
+        ctx.blockstack.append(block)
+        ctx.pushvalue(w_result)
+
 _unary_ops = [
     ('UNARY_POSITIVE', op.pos),
     ('UNARY_NEGATIVE', op.neg),
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -702,27 +702,6 @@
         w_iterator = op.iter(w_iterable).eval(self)
         self.pushvalue(w_iterator)
 
-    def SETUP_LOOP(self, target):
-        block = LoopBlock(self.stackdepth, target)
-        self.blockstack.append(block)
-
-    def SETUP_FINALLY(self, target):
-        block = FinallyBlock(self.stackdepth, target)
-        self.blockstack.append(block)
-
-    def SETUP_WITH(self, target):
-        # A simpler version than the 'real' 2.7 one:
-        # directly call manager.__enter__(), don't use special lookup functions
-        # which don't make sense on the RPython type system.
-        w_manager = self.peekvalue()
-        w_exit = op.getattr(w_manager, const("__exit__")).eval(self)
-        self.settopvalue(w_exit)
-        w_enter = op.getattr(w_manager, const('__enter__')).eval(self)
-        w_result = op.simple_call(w_enter).eval(self)
-        block = WithBlock(self.stackdepth, target)
-        self.blockstack.append(block)
-        self.pushvalue(w_result)
-
     def WITH_CLEANUP(self, oparg):
         # Note: RPython context managers receive None in lieu of tracebacks
         # and cannot suppress the exception.


More information about the pypy-commit mailing list