def fn(): s = lltype.malloc(S) s.u = lltype.malloc(U) a = lltype.malloc(A, 1000) s2 = lltype.malloc(S) gcref1 = lltype.cast_opaque_ptr(llmemory.GCREF, s) int1 = rgc.get_rpy_type_index(gcref1) gcref2 = lltype.cast_opaque_ptr(llmemory.GCREF, s.u) int2 = rgc.get_rpy_type_index(gcref2) gcref3 = lltype.cast_opaque_ptr(llmemory.GCREF, a) int3 = rgc.get_rpy_type_index(gcref3) gcref4 = lltype.cast_opaque_ptr(llmemory.GCREF, s2) int4 = rgc.get_rpy_type_index(gcref4) assert int1 != int2 assert int1 != int3 assert int2 != int3 assert int1 == int4 return 0
def get_rpy_type_index(space, w_obj): """Return an integer identifying the RPython type of the given object or GcRef. The number starts at 1; it is an index in the file typeids.txt produced at translation.""" gcref = unwrap(space, w_obj) index = rgc.get_rpy_type_index(gcref) if index < 0: raise missing_operation(space) return space.wrap(index)