Commits

Armin Rigo committed df5cadc

Support translator.viewcg() with an argument now:
the graph to display at the start.

  • Participants
  • Parent commits 3f51c6c

Comments (0)

Files changed (3)

dotviewer/graphpage.py

     """
     save_tmp_file = None
 
-    def __init__(self, *args):
+    def __init__(self, *args, **kwds):
         self.args = args
+        self.kwds = kwds
 
     def content(self):
         """Compute the content of the page.
             new = self.__class__()
             new.source = ''  # '''dot source'''
             new.links  = {}  # {'word': 'statusbar text'}
-            new.compute(*self.args)   # defined in subclasses
+            new.compute(*self.args, **self.kwds)   # defined in subclasses
             return new
 
     def followlink(self, word):

pypy/translator/tool/graphpage.py

     def graph_name(self, huge=0):
         return 'translator'
 
-    def do_compute(self, dotgen, huge=100):
+    def do_compute(self, dotgen, huge=100, center_graph=None):
         translator = self.translator
 
         # show the call graph
 
         if len(graphs) > huge:
             assert graphs, "no graph to show!"
-            LocalizedCallGraphPage.do_compute.im_func(self, dotgen, [graphs[0]])
+            graphs = [center_graph or graphs[0]]
+            LocalizedCallGraphPage.do_compute.im_func(self, dotgen, graphs)
             return
 
         blocked_graphs = self.get_blocked_graphs(graphs)

pypy/translator/translator.py

         from pypy.translator.tool.graphpage import FlowGraphPage
         FlowGraphPage(self).display()
 
-    def viewcg(self):
+    def viewcg(self, center_graph=None):
         """Shows the whole call graph and the class hierarchy, based on
         the computed annotations."""
         from pypy.translator.tool.graphpage import TranslatorPage
-        TranslatorPage(self).display()
+        TranslatorPage(self, center_graph).display()