Example #1
0
File: rclass.py Project: sota/pypy
 def ll_str(self, i): # doesn't work for non-gc classes!
     from rpython.rtyper.lltypesystem.ll_str import ll_int2hex
     from rpython.rlib.rarithmetic import r_uint
     if not i:
         return rstr.null_str
     instance = cast_pointer(OBJECTPTR, i)
     # Two choices: the first gives a fast answer but it can change
     # (typically only once) during the life of the object.
     #uid = r_uint(cast_ptr_to_int(i))
     uid = r_uint(llop.gc_id(lltype.Signed, i))
     #
     res =                        rstr.instance_str_prefix
     res = rstr.ll_strconcat(res, instance.typeptr.name)
     res = rstr.ll_strconcat(res, rstr.instance_str_infix)
     res = rstr.ll_strconcat(res, ll_int2hex(uid, False))
     res = rstr.ll_strconcat(res, rstr.instance_str_suffix)
     return res
Example #2
0
 def ll_str(self, i):  # doesn't work for non-gc classes!
     from rpython.rtyper.lltypesystem.ll_str import ll_int2hex
     from rpython.rlib.rarithmetic import r_uint
     if not i:
         return rstr.conststr("NULL")
     instance = cast_pointer(OBJECTPTR, i)
     # Two choices: the first gives a fast answer but it can change
     # (typically only once) during the life of the object.
     #uid = r_uint(cast_ptr_to_int(i))
     uid = r_uint(llop.gc_id(lltype.Signed, i))
     #
     res = rstr.conststr("<")
     res = rstr.ll_strconcat(res, instance.typeptr.name)
     res = rstr.ll_strconcat(res, rstr.conststr(" object at 0x"))
     res = rstr.ll_strconcat(res, ll_int2hex(uid, False))
     res = rstr.ll_strconcat(res, rstr.conststr(">"))
     return res
Example #3
0
 def ll_str(self, i): # doesn't work for non-gc classes!
     from rpython.rtyper.lltypesystem import rstr
     from rpython.rtyper.lltypesystem.ll_str import ll_int2hex
     from rpython.rlib.rarithmetic import r_uint
     if not i:
         return rstr.null_str
     instance = cast_pointer(OBJECTPTR, i)
     uid = r_uint(cast_ptr_to_int(i))
     nameLen = len(instance.typeptr.name)
     nameString = rstr.mallocstr(nameLen-1)
     i = 0
     while i < nameLen - 1:
         nameString.chars[i] = instance.typeptr.name[i]
         i += 1
     res =                        rstr.instance_str_prefix
     res = rstr.ll_strconcat(res, nameString)
     res = rstr.ll_strconcat(res, rstr.instance_str_infix)
     res = rstr.ll_strconcat(res, ll_int2hex(uid, False))
     res = rstr.ll_strconcat(res, rstr.instance_str_suffix)
     return res