[pypy-svn] r18038 - pypy/dist/pypy/translator/tool

pedronis at codespeak.net pedronis at codespeak.net
Sat Oct 1 04:31:33 CEST 2005


Author: pedronis
Date: Sat Oct  1 04:31:31 2005
New Revision: 18038

Modified:
   pypy/dist/pypy/translator/tool/graphpage.py
Log:
TranslatorPage should fall back to LocalizedCallGraphpPage if there are too many functions



Modified: pypy/dist/pypy/translator/tool/graphpage.py
==============================================================================
--- pypy/dist/pypy/translator/tool/graphpage.py	(original)
+++ pypy/dist/pypy/translator/tool/graphpage.py	Sat Oct  1 04:31:31 2005
@@ -264,6 +264,9 @@
         return name
 
     def followlink(self, name):
+        if name.endswith('...'):
+            obj = self.object_by_name[name]
+            return LocalizedCallGraphPage(self.translator, obj)
         obj = self.object_by_name[name]
         if isinstance(obj, ClassDef):
             return ClassDefPage(self.translator, obj)
@@ -274,14 +277,19 @@
     """A GraphPage showing a the call graph between functions
     as well as the class hierarchy."""
 
-    def graph_name(self):
+    def graph_name(self, huge=0):
         return 'translator'
 
-    def do_compute(self, dotgen):
+    def do_compute(self, dotgen, huge=100):
         translator = self.translator
 
         # show the call graph
         functions = translator.functions
+
+        if len(functions) > huge:
+            LocalizedCallGraphPage.do_compute.im_func(self, dotgen, translator.entrypoint)
+            return
+
         blocked_functions = self.get_blocked_functions(functions)
 
         highlight_functions = getattr(translator, 'highlight_functions', {}) # XXX
@@ -300,7 +308,8 @@
             else:
                 kw = {}
             dotgen.emit_node(nameof(func), label=data, shape="box", **kw)
-        dotgen.emit_edge('entry', nameof(functions[0]), color="green")
+        if functions:
+            dotgen.emit_edge('entry', nameof(functions[0]), color="green")
         for f1, f2 in translator.callgraph.itervalues():
             dotgen.emit_edge(nameof(f1), nameof(f2))
 
@@ -354,12 +363,6 @@
                 self.links[label] = 'go to its localized call graph'
                 self.object_by_name[label] = func
 
-    def followlink(self, name):
-        if name.endswith('...'):
-            obj = self.object_by_name[name]
-            return LocalizedCallGraphPage(self.translator, obj)
-        return BaseTranslatorPage.followlink(self, name)
-
 class ClassHierarchyPage(BaseTranslatorPage):
     """A GraphPage showing the class hierarchy."""
 



More information about the Pypy-commit mailing list