def do_showg(self, arg): """showg obj show graph for obj, obj can be an expression or a dotted name (in which case prefixing with some packages in pypy is tried (see help pypyprefixes)). if obj is a function or method, the localized call graph is shown; if obj is a class or ClassDef the class definition graph is shown""" from rpython.annotator.classdesc import ClassDef from rpython.translator.tool import graphpage translator = self.translator obj = self._getobj(arg) if obj is None: return if hasattr(obj, 'im_func'): obj = obj.im_func if isinstance(obj, types.FunctionType): page = graphpage.LocalizedCallGraphPage(translator, self._allgraphs(obj)) elif isinstance(obj, FunctionGraph): page = graphpage.FlowGraphPage(translator, [obj]) elif isinstance(obj, (type, types.ClassType)): classdef = self._getcdef(obj) if classdef is None: return page = graphpage.ClassDefPage(translator, classdef) elif isinstance(obj, ClassDef): page = graphpage.ClassDefPage(translator, obj) else: print "*** Nothing to do" return self._show(page)
def do_flowg(self, arg): """flowg obj show flow graph for function obj, obj can be an expression or a dotted name (in which case prefixing with some packages in pypy is tried (see help pypyprefixes))""" from rpython.translator.tool import graphpage obj = self._getobj(arg) if obj is None: return if hasattr(obj, 'im_func'): obj = obj.im_func if isinstance(obj, types.FunctionType): graphs = self._allgraphs(obj) elif isinstance(obj, FunctionGraph): graphs = [obj] else: print "*** Not a function" return self._show(graphpage.FlowGraphPage(self.translator, graphs))