[pypy-svn] r18039 - in pypy/dist/pypy/translator: . backendopt

pedronis at codespeak.net pedronis at codespeak.net
Sat Oct 1 04:34:21 CEST 2005


Author: pedronis
Date: Sat Oct  1 04:34:19 2005
New Revision: 18039

Modified:
   pypy/dist/pypy/translator/backendopt/tailrecursion.py
   pypy/dist/pypy/translator/simplify.py
Log:
invert strange import dependecy. Was also breaking fork before rtype!



Modified: pypy/dist/pypy/translator/backendopt/tailrecursion.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/tailrecursion.py	(original)
+++ pypy/dist/pypy/translator/backendopt/tailrecursion.py	Sat Oct  1 04:34:19 2005
@@ -1,34 +1,14 @@
 import sys
+from pypy.translator.simplify import get_graph
 from pypy.translator.unsimplify import copyvar, split_block
 from pypy.objspace.flow.model import Variable, Constant, Block, Link
 from pypy.objspace.flow.model import SpaceOperation, last_exception
 from pypy.objspace.flow.model import traverse, mkentrymap, checkgraph, flatten
 from pypy.annotation import model as annmodel
 from pypy.rpython.lltype import Bool, typeOf, FuncType, _ptr
-from pypy.rpython import rmodel
 
 # this transformation is very academical -- I had too much time
 
-def get_graph(arg, translator):
-    if isinstance(arg, Variable):
-        return None
-    f = arg.value
-    if not isinstance(f, _ptr):
-        return None
-    try:
-        callable = f._obj._callable
-        #external function calls don't have a real graph
-        if getattr(callable, "suggested_primitive", False):
-            return None
-        if callable in translator.flowgraphs:
-            return translator.flowgraphs[callable]
-    except AttributeError, KeyError:
-        pass
-    try:
-        return f._obj.graph
-    except AttributeError:
-        return None
-
 def _remove_tail_call(translator, graph, block):
     print "removing tail call"
     assert len(block.exits) == 1

Modified: pypy/dist/pypy/translator/simplify.py
==============================================================================
--- pypy/dist/pypy/translator/simplify.py	(original)
+++ pypy/dist/pypy/translator/simplify.py	Sat Oct  1 04:34:19 2005
@@ -9,7 +9,29 @@
 from pypy.objspace.flow.model import Variable, Constant, Block, Link
 from pypy.objspace.flow.model import last_exception
 from pypy.objspace.flow.model import checkgraph, traverse, mkentrymap
-from pypy.translator.backendopt.tailrecursion import get_graph
+
+def get_graph(arg, translator):
+    if isinstance(arg, Variable):
+        return None
+    f = arg.value
+    from pypy.rpython import lltype
+    if not isinstance(f, lltype._ptr):
+        return None
+    try:
+        callable = f._obj._callable
+        #external function calls don't have a real graph
+        if getattr(callable, "suggested_primitive", False):
+            return None
+        if callable in translator.flowgraphs:
+            return translator.flowgraphs[callable]
+    except AttributeError, KeyError:
+        pass
+    try:
+        return f._obj.graph
+    except AttributeError:
+        return None
+
+
 # ____________________________________________________________
 
 def eliminate_empty_blocks(graph):



More information about the Pypy-commit mailing list