Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r57424:6a1bcd6cea95
Date: 2012-09-15 17:49 +0100
http://bitbucket.org/pypy/pypy/changeset/6a1bcd6cea95/
Log: Get rid of MergeBlock exception
Use FSFrame.record() to record operations and call
FSFrame.mergeblock() directly from there.
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
@@ -20,11 +20,6 @@
class StopFlowing(Exception):
pass
-class MergeBlock(Exception):
- def __init__(self, block, currentstate):
- self.block = block
- self.currentstate = currentstate
-
class SpamBlock(Block):
# make slots optional, for debugging
if hasattr(Block, '__slots__'):
@@ -97,9 +92,6 @@
self.enterspamblock = isinstance(block, SpamBlock)
def append(self, operation):
- if self.last_join_point is not None:
- # only add operations corresponding to the first bytecode
- raise MergeBlock(self.crnt_block, self.last_join_point)
self.crnt_block.operations.append(operation)
def bytecode_trace(self, frame):
@@ -317,6 +309,14 @@
prevblock = parent
return recorder
+ def record(self, spaceop):
+ """Record an operation into the active block"""
+ recorder = self.recorder
+ if getattr(recorder, 'last_join_point', None) is not None:
+ self.mergeblock(recorder.crnt_block, recorder.last_join_point)
+ raise StopFlowing
+ recorder.append(spaceop)
+
def guessbool(self, w_condition, **kwds):
return self.recorder.guessbool(self, w_condition, **kwds)
@@ -355,9 +355,6 @@
except StopFlowing:
pass
- except MergeBlock, e:
- self.mergeblock(e.block, e.currentstate)
-
except Return:
w_result = self.popvalue()
assert w_result is not None
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
@@ -269,7 +269,7 @@
def do_operation(self, name, *args_w):
spaceop = SpaceOperation(name, args_w, Variable())
spaceop.offset = self.frame.last_instr
- self.frame.recorder.append(spaceop)
+ self.frame.record(spaceop)
return spaceop.result
def do_operation_with_implicit_exceptions(self, name, *args_w):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit