def test_large_positive_integer_1word_at_put(): target = model.W_LargePositiveInteger1Word(0) source = model.W_LargePositiveInteger1Word(-1) for i in range(4): target.atput0(space, i, source.at0(space, i)) assert target.at0(space, i) == source.at0(space, i) assert hex(r_uint(target.value)) == hex(r_uint(source.value))
def test_large_positive_integer_1word_at(): b = model.W_LargePositiveInteger1Word(-1) for i in range(4): r = b.at0(space, i) assert isinstance(r, model.W_SmallInteger) assert space.unwrap_int(r) == 0xff assert b.value == -1
def wrap_positive_32bit_int(self, val): # This will always return a positive value. # XXX: For now, we assume that val is at most 32bit, i.e. overflows are # checked for before wrapping. Also, we ignore tagging. if int_between(0, val, constants.MAXINT): return model.W_SmallInteger(val) else: return model.W_LargePositiveInteger1Word(val)
def new(self, extrasize=0): w_cls = self.w_self() if self.instance_kind == POINTERS: size = self.instsize() + extrasize w_new = model.W_PointersObject(self.space, w_cls, size) elif self.instance_kind == WORDS: w_new = model.W_WordsObject(self.space, w_cls, extrasize) elif self.instance_kind == BYTES: w_new = model.W_BytesObject(self.space, w_cls, extrasize) elif self.instance_kind == COMPILED_METHOD: w_new = model.W_CompiledMethod(self.space, extrasize) elif self.instance_kind == FLOAT: w_new = model.W_Float(0) # Squeak gives a random piece of memory elif self.instance_kind == LARGE_POSITIVE_INTEGER: if extrasize <= 4: w_new = model.W_LargePositiveInteger1Word(0, extrasize) else: w_new = model.W_BytesObject(self.space, w_cls, extrasize) elif self.instance_kind == WEAK_POINTERS: size = self.instsize() + extrasize w_new = model.W_PointersObject(self.space, w_cls, size, weak=True) else: raise NotImplementedError(self.instance_kind) return w_new
def w_l(largeInteger): if largeInteger >= 0 and largeInteger <= constants.TAGGED_MAXINT: return space.wrap_int(intmask(largeInteger)) else: return model.W_LargePositiveInteger1Word(intmask(largeInteger))