Esempio n. 1
0
 def define_hash_varsized(self):
     S = lltype.GcStruct('S', ('abc', lltype.Signed),
                              ('def', lltype.Array(lltype.Signed)))
     s = lltype.malloc(S, 3, zero=True)
     h_s = lltype.identityhash(s)
     def f():
         return lltype.identityhash(s) - h_s    # != 0 (so far),
                             # because S is a varsized structure.
     return f
Esempio n. 2
0
 def define_hash_varsized(self):
     S = lltype.GcStruct('S', ('abc', lltype.Signed),
                              ('def', lltype.Array(lltype.Signed)))
     s = lltype.malloc(S, 3, zero=True)
     h_s = lltype.identityhash(s)
     def f():
         return lltype.identityhash(s) - h_s    # != 0 (so far),
                             # because S is a varsized structure.
     return f
Esempio n. 3
0
def hash_whatever(TYPE, x):
    # Hash of lltype or ootype object.
    # Only supports strings, unicodes and regular instances,
    # as well as primitives that can meaningfully be cast to Signed.
    if isinstance(TYPE, lltype.Ptr) and TYPE.TO._gckind == 'gc':
        if TYPE.TO is rstr.STR or TYPE.TO is rstr.UNICODE:
            return rstr.LLHelpers.ll_strhash(x)  # assumed not null
        else:
            if x:
                return lltype.identityhash(x)
            else:
                return 0
    elif TYPE is ootype.String or TYPE is ootype.Unicode:
        return x.ll_hash()
    elif isinstance(TYPE, ootype.OOType):
        if x:
            return ootype.identityhash(x)
        else:
            return 0
    else:
        return rffi.cast(lltype.Signed, x)
Esempio n. 4
0
def hash_whatever(TYPE, x):
    # Hash of lltype or ootype object.
    # Only supports strings, unicodes and regular instances,
    # as well as primitives that can meaningfully be cast to Signed.
    if isinstance(TYPE, lltype.Ptr) and TYPE.TO._gckind == 'gc':
        if TYPE.TO is rstr.STR or TYPE.TO is rstr.UNICODE:
            return rstr.LLHelpers.ll_strhash(x)    # assumed not null
        else:
            if x:
                return lltype.identityhash(x)
            else:
                return 0
    elif TYPE is ootype.String or TYPE is ootype.Unicode:
        return x.ll_hash()
    elif isinstance(TYPE, ootype.OOType):
        if x:
            return ootype.identityhash(x)
        else:
            return 0
    else:
        return rffi.cast(lltype.Signed, x)
Esempio n. 5
0
def _ll_1_gc_identityhash(x):
    return lltype.identityhash(x)
Esempio n. 6
0
 def f():
     return lltype.identityhash(s) - h_s    # != 0 (so far),
Esempio n. 7
0
 def _get_hash_(self):
     if self.value:
         return lltype.identityhash(self.value)
     else:
         return 0
Esempio n. 8
0
 def f():
     return lltype.identityhash(s) - h_s    # != 0 (so far),
Esempio n. 9
0
 def f():
     obj1 = lltype.malloc(A)
     obj2 = lltype.malloc(A)
     return lltype.identityhash(obj1) == lltype.identityhash(obj2)
Esempio n. 10
0
def rd_hash(ref):
    assert ref
    return lltype.identityhash(ref)
Esempio n. 11
0
 def _get_hash_(self):
     if self.value:
         return lltype.identityhash(self.value)
     else:
         return 0
Esempio n. 12
0
def _ll_1_gc_identityhash(x):
    return lltype.identityhash(x)
Esempio n. 13
0
def ll_inst_hash(ins):
    if not ins:
        return 0    # for None
    else:
        from pypy.rpython.lltypesystem import lltype
        return lltype.identityhash(ins)     # also works for ootype
Esempio n. 14
0
def ll_inst_hash(ins):
    if not ins:
        return 0    # for None
    else:
        from pypy.rpython.lltypesystem import lltype
        return lltype.identityhash(ins)     # also works for ootype
Esempio n. 15
0
 def f():
     obj1 = lltype.malloc(A)
     obj2 = lltype.malloc(A)
     return lltype.identityhash(obj1) == lltype.identityhash(obj2)