示例#1
0
文件: reftracker.py 项目: njues/Sypy
    def compute(self, objectlist):
        assert objectlist[0] is MARKER
        self.objectlist = objectlist
        dotgen = DotGen('reftracker')
        id2typename = {}
        nodes = {}
        edges = {}

        def addedge(o1, o2):
            key = (uid(o1), uid(o2))
            edges[key] = self.edgelabel(o1, o2)

        for i in range(1, len(objectlist)):
            typename, s, linktext = self.formatobject(objectlist[i])
            word = '0x%x' % uid(objectlist[i])
            if linktext:
                self.links[word] = linktext
            s = '<%s> %s\\n%s' % (typename, word, s)
            nodename = 'node%d' % len(nodes)
            dotgen.emit_node(nodename, label=s, shape="box")
            nodes[uid(objectlist[i])] = nodename
            for o2 in self.get_referents(objectlist[i]):
                if o2 is None:
                    continue
                addedge(objectlist[i], o2)
                id2typename[uid(o2)] = self.shortrepr(o2)
                del o2
            for o2 in self.get_referrers(objectlist[i]):
                if o2 is None:
                    continue
                if type(o2) is list and o2 and o2[0] is MARKER:
                    continue
                addedge(o2, objectlist[i])
                id2typename[uid(o2)] = self.shortrepr(o2)
                del o2

        for ids, label in edges.items():
            for id1 in ids:
                if id1 not in nodes:
                    nodename = 'node%d' % len(nodes)
                    word = '0x%x' % id1
                    s = '<%s> %s' % (id2typename[id1], word)
                    dotgen.emit_node(nodename, label=s)
                    nodes[id1] = nodename
                    self.links[word] = s
            id1, id2 = ids
            dotgen.emit_edge(nodes[id1], nodes[id2], label=label)

        self.source = dotgen.generate(target=None)
示例#2
0
 def __repr__(self):
     """ representation for debugging purposes """
     if self.w_value is None:
         content = ""
     else:
         content = repr(self.w_value)
     return "<%s(%s) at 0x%x>" % (self.__class__.__name__, content, uid(self))
示例#3
0
文件: reftracker.py 项目: njues/Sypy
 def followlink(self, word):
     id1 = int(word, 16)
     found = None
     objectlist = self.objectlist
     for i in range(1, len(objectlist)):
         for o2 in self.get_referents(objectlist[i]):
             if uid(o2) == id1:
                 found = o2
         for o2 in self.get_referrers(objectlist[i]):
             if uid(o2) == id1:
                 found = o2
     if found is not None:
         objectlist = objectlist + [found]
     else:
         print '*** NOTE: object not found'
     return self.newpage(objectlist)
示例#4
0
 def __repr__(self):
     """ representation for debugging purposes """
     if self.w_value is None:
         content = ""
     else:
         content = repr(self.w_value)
     return "<%s(%s) at 0x%x>" % (self.__class__.__name__,
                                  content, uid(self))
示例#5
0
def nameof(obj, cache={}):
    # NB. the purpose of the cache is not performance, but to ensure that
    # two objects that compare equal get the same name
    try:
        return cache[obj]
    except KeyError:
        result = '%s__0x%x' % (getattr(obj, '__name__', ''), uid(obj))
        cache[obj] = result
        return result
示例#6
0
 def formatobject(self, o):
     lines = []
     for name, value in self.enum_content(o):
         if not isinstance(value, str):
             value = '0x%x' % uid(value)
         lines.append('%s = %s' % (name, value))
     s = '\n'.join(lines)
     t = shorttypename(lltype.typeOf(o))
     return t, s, ''
示例#7
0
 def formatobject(self, o):
     lines = []
     for name, value in self.enum_content(o):
         if not isinstance(value, str):
             value = '0x%x' % uid(value)
         lines.append('%s = %s' % (name, value))
     s = '\n'.join(lines)
     t = shorttypename(lltype.typeOf(o))
     return t, s, ''
示例#8
0
def nameof(obj, cache={}):
    # NB. the purpose of the cache is not performance, but to ensure that
    # two objects that compare equal get the same name
    try:
        return cache[obj]
    except KeyError:
        result = '%s__0x%x' % (getattr(obj, '__name__', ''), uid(obj))
        cache[obj] = result
        return result
示例#9
0
 def getfunctionname(self,func):
     # NB. the purpose of the cache is not performance, but to ensure that
     # two methods that compare equal get the same name.
     if inspect.ismethod(func) and func.im_self is None:
         func = func.im_func  # consider unbound methods as plain functions
     try:
         return self.namecache[func]
     except KeyError:
         assert inspect.isfunction(func) or inspect.ismethod(func)
         name = '%s__%x' % (func.__name__, uid(func))#self._hackname(func)
         self.namecache[func] = name
         return name
示例#10
0
 def __str__(self):
     return '%r inst at 0x%x' % (self._TYPE._name, uid(self))
示例#11
0
文件: escape.py 项目: Debug-Orz/Sypy
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s)" %
             (uid(self), self.TYPE, self.creation_method, self.escapes))
示例#12
0
文件: model.py 项目: purepython/pypy
 def __repr__(self):
     return '<FunctionGraph of %s at 0x%x>' % (self, uid(self))
示例#13
0
 def __repr__(self):
     try:
         return '<AddressAsInt %s>' % (self.adr.ptr,)
     except AttributeError:
         return '<AddressAsInt at 0x%x>' % (uid(self),)
示例#14
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r)" %
             (uid(self), self.TYPE))
示例#15
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s, cha=%s)" %
             (uid(self), self.lltype, self.creation_method, self.escapes, self.changes))
示例#16
0
文件: reftracker.py 项目: njues/Sypy
 def addedge(o1, o2):
     key = (uid(o1), uid(o2))
     edges[key] = self.edgelabel(o1, o2)
示例#17
0
 def getclassname(self,cls):
     assert isinstance(cls, ClassDef)
     name = cls.shortname
     if cls.issubclass(self.annotator.bookkeeper.getuniqueclassdef(Exception)):
         return name
     return '%s__%x' % (name, uid(cls))#self._hackname(cls)
示例#18
0
 def __repr__(self):
     return "<node [%s] at 0x%x>" % (self.name, uid(self))
示例#19
0
文件: unroll.py 项目: Debug-Orz/Sypy
 def __repr__(self):
     return '%s(0x%x)' % (self.__class__.__name__, uid(self))
示例#20
0
 def __repr__(self):
     return "<UnionDict at 0x%x>" % uid(self)
示例#21
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s)" %
             (uid(self), self.TYPE, self.creation_method, self.escapes))
示例#22
0
 def __repr__(self):
     return "<node [%s] at 0x%x>" % (self.name, uid(self))
示例#23
0
 def __repr__(self):
     return '%s(0x%x)' % (self.__class__.__name__, uid(self))
示例#24
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r)" % (uid(self), self.TYPE))
示例#25
0
文件: model.py 项目: alkorzt/pypy
 def __repr__(self):
     return '<FunctionGraph of %s at 0x%x>' % (self, uid(self))
示例#26
0
 def __repr__(self):
     return ("CreationPoint(<0x%x>, %r, %s, esc=%s, cha=%s)" %
             (uid(self), self.lltype, self.creation_method, self.escapes, self.changes))