Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r74777:13de37f01288
Date: 2014-11-26 17:36 +0100
http://bitbucket.org/pypy/pypy/changeset/13de37f01288/
Log: create a base class for the SETUP_XXX opcodes
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -499,30 +499,36 @@
else:
raise
+class SetupInstruction(BCInstruction):
+ def bc_flow(self, reader):
+ reader.curr_block.operations.append(self)
+ self.target = reader.get_block_at(self.arg)
+
+ def eval(self, ctx):
+ block = self.make_block(ctx)
+ ctx.blockstack.append(block)
+
@bc_reader.register_opcode
-class SETUP_EXCEPT(BCInstruction):
- def eval(self, ctx):
+class SETUP_EXCEPT(SetupInstruction):
+ def make_block(self, ctx):
from rpython.flowspace.flowcontext import ExceptBlock
- block = ExceptBlock(ctx.stackdepth, self.arg)
- ctx.blockstack.append(block)
+ return ExceptBlock(ctx.stackdepth, self.arg)
@bc_reader.register_opcode
-class SETUP_LOOP(BCInstruction):
- def eval(self, ctx):
+class SETUP_LOOP(SetupInstruction):
+ def make_block(self, ctx):
from rpython.flowspace.flowcontext import LoopBlock
- block = LoopBlock(ctx.stackdepth, self.arg)
- ctx.blockstack.append(block)
+ return LoopBlock(ctx.stackdepth, self.arg)
@bc_reader.register_opcode
-class SETUP_FINALLY(BCInstruction):
- def eval(self, ctx):
+class SETUP_FINALLY(SetupInstruction):
+ def make_block(self, ctx):
from rpython.flowspace.flowcontext import FinallyBlock
- block = FinallyBlock(ctx.stackdepth, self.arg)
- ctx.blockstack.append(block)
+ return FinallyBlock(ctx.stackdepth, self.arg)
@bc_reader.register_opcode
-class SETUP_WITH(BCInstruction):
+class SETUP_WITH(SetupInstruction):
def eval(self, ctx):
from rpython.flowspace.flowcontext import WithBlock
# A simpler version than the 'real' 2.7 one:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit