def test_cast_adr_to_int(self): class someaddr(object): def _cast_to_int(self): return sys.maxint / 2 * 3 res = cast_adr_to_int(someaddr()) assert isinstance(res, int) assert res == -sys.maxint / 2 - 3
def test_cast_adr_to_int(self): class someaddr(object): def _cast_to_int(self): return sys.maxint/2 * 3 res = cast_adr_to_int(someaddr()) assert isinstance(res, int) assert res == -sys.maxint/2 - 3
def convert_to_imm(self, c): if isinstance(c, ConstInt): return imm(c.value) elif isinstance(c, ConstPtr): if we_are_translated() and c.value and rgc.can_move(c.value): print "convert_to_imm: ConstPtr needs special care" raise AssertionError return imm(rffi.cast(lltype.Signed, c.value)) elif isinstance(c, ConstAddr): return imm(ll2ctypes.cast_adr_to_int(c.value)) else: print "convert_to_imm: got a %s" % c raise AssertionError