[pypy-svn] rev 2207 - pypy/trunk/src/pypy/objspace/flow

arigo at codespeak.net arigo at codespeak.net
Mon Nov 17 20:26:32 CET 2003


Author: arigo
Date: Mon Nov 17 20:26:29 2003
New Revision: 2207

Modified:
   pypy/trunk/src/pypy/objspace/flow/flowcontext.py
   pypy/trunk/src/pypy/objspace/flow/model.py
Log:
Finally fixed the variables in EggBlocks, which are no longer shared with 
other blocks.


Modified: pypy/trunk/src/pypy/objspace/flow/flowcontext.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/flowcontext.py	(original)
+++ pypy/trunk/src/pypy/objspace/flow/flowcontext.py	Mon Nov 17 20:26:29 2003
@@ -152,4 +152,16 @@
             if w_result is not None:
                 link = Link([w_result], self.graph.returnblock)
                 self.crnt_block.closeblock(link)
+        self.fixeggblocks()
 
+    def fixeggblocks(self):
+        # EggBlocks reuse the variables of their previous block,
+        # which is deemed not acceptable for simplicity of the operations
+        # that will be performed later on the flow graph.
+        def fixegg(node):
+            if isinstance(node, EggBlock):
+                mapping = {}
+                for a in node.inputargs:
+                    mapping[a] = Variable()
+                node.renamevariables(mapping)
+        traverse(fixegg, self.graph)

Modified: pypy/trunk/src/pypy/objspace/flow/model.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/model.py	(original)
+++ pypy/trunk/src/pypy/objspace/flow/model.py	Mon Nov 17 20:26:29 2003
@@ -40,6 +40,12 @@
             result.append(op.result)
         return uniqueitems([w for w in result if isinstance(w, Variable)])
 
+    def renamevariables(self, mapping):
+        self.inputargs[:] = [mapping.get(a, a) for a in self.inputargs]
+        for op in self.operations:
+            op.args[:] = [mapping.get(a, a) for a in op.args]
+            op.result = mapping.get(op.result, op.result)
+
     def closeblock(self, *exits):
         assert self.exits == [], "block already closed"
         self.recloseblock(*exits)


More information about the Pypy-commit mailing list