[pypy-svn] r25359 - pypy/branch/explicit-exceptions/translator/c

mwh at codespeak.net mwh at codespeak.net
Wed Apr 5 13:13:13 CEST 2006


Author: mwh
Date: Wed Apr  5 13:13:09 2006
New Revision: 25359

Modified:
   pypy/branch/explicit-exceptions/translator/c/stackless.py
Log:
merging of http://codespeak.net/svn/pypy/dist/pypy/translator/c/stackless.py
revisions 24785 to 25354:

    ------------------------------------------------------------------------
    r25330 | tismer | 2006-04-04 23:33:08 +0200 (Tue, 04 Apr 2006) | 1 line
    
    argh. When do I learn that getattr without default is not helpful!
    ------------------------------------------------------------------------
    r25329 | tismer | 2006-04-04 23:23:22 +0200 (Tue, 04 Apr 2006) | 1 line
    
    do not rely on graphs always having a 'func' attribute
    ------------------------------------------------------------------------
    r25266 | hpk | 2006-04-03 19:42:08 +0200 (Mon, 03 Apr 2006) | 2 lines
    
    clarify code a bit while trying to understand it 
    
    ------------------------------------------------------------------------


Modified: pypy/branch/explicit-exceptions/translator/c/stackless.py
==============================================================================
--- pypy/branch/explicit-exceptions/translator/c/stackless.py	(original)
+++ pypy/branch/explicit-exceptions/translator/c/stackless.py	Wed Apr  5 13:13:09 2006
@@ -69,35 +69,35 @@
         for caller, callee in translator.callgraph.values():
             # ignore calls issued suggested_primitives -- they are not
             # compiled in, and they typically contain pseudo-recursions
-            try:
-                suggprim = caller.func.suggested_primitive
-            except AttributeError:
-                suggprim = False
-            if not suggprim:
+            func = getattr(caller, 'func', None)
+            # there are graphs without funcs
+            if not getattr(func, 'suggested_primitive', False): 
                 callers[caller].append(callee)
         # check all callees if they can reach unwind
-        seen = self.can_reach_unwind
+        can_reach_unwind = self.can_reach_unwind
         
         pending = {}
-        ext = self.database.externalfuncs
         def check_unwind(graph):
             if graph in pending:
-                seen[graph] = True
+                can_reach_unwind[graph] = True
                 return True
             pending[graph] = graph
             for callee in callers[graph]:
-                if callee in seen:
-                    ret = seen[callee]
+                if callee in can_reach_unwind:
+                    ret = can_reach_unwind[callee]
                 else:
                     ret = check_unwind(callee)
                 if ret:
                     break
             else:
-                ret = graph.func in self.stackless_roots
+                func = getattr(graph, 'func', None)
+                ret = func in self.stackless_roots
             del pending[graph]
-            seen[graph] = ret
+            can_reach_unwind[graph] = ret
             return ret
-        [check_unwind(caller) for caller in callers if caller not in seen]
+        for caller in callers: 
+            if caller not in can_reach_unwind:
+                check_unwind(caller) 
 
     def registerunwindable(self, functionname, FUNC, resume_points):
         if resume_points >= 1:



More information about the Pypy-commit mailing list