def _become(self, w_other): if not isinstance(w_other, W_LargeIntegerWord): raise error.PrimitiveFailedError self.value, w_other.value = w_other.value, self.value self._exposed_size, w_other._exposed_size = (w_other._exposed_size, self._exposed_size) W_AbstractObjectWithClassReference._become(self, w_other)
def fillin(self, space, g_self): W_AbstractObjectWithClassReference.fillin(self, space, g_self) bytes = g_self.get_bytes() value = rbigint.rbigint.frombytes(''.join(bytes), 'little', False) if self.getclass(space).is_same_object(space.w_LargePositiveInteger): self.value = value else: self.value = value.neg() self._exposed_size = len(bytes)
def __init__(self, space, w_cls, bytes): """ Initialize immutable bytes object and store its bytes in `self.immutable_bytes` slot. `W_BytesObject.__init__(self, space, w_class, size)` not called, because there is no need to `self.mutate()` and set `self.bytes`. """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_bytes = bytes
def __init__(self, space, w_cls, words): """ Initialize immutable words object and store its words in `self.immutable_words` slot. `W_Immutable_WordsObject.__init__(self, space, w_class, size)` not called, because there is no need to initialize `self.words`. """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_words = words
def invariant(self): if not W_AbstractObjectWithClassReference.invariant(self): return False for c in self._bytes(): if not isinstance(c, str) or len(c) != 1: return False return True
def fillin(self, space, g_self): W_AbstractObjectWithClassReference.fillin(self, space, g_self) bytes = g_self.get_bytes() value = rbigint.rbigint.frombytes(''.join(bytes), 'little', False) self.value = value.touint() self._exposed_size = len(bytes)
def _become(self, w_other): if not isinstance(w_other, W_WordsObject): raise error.PrimitiveFailedError self.words, w_other.words = w_other.words, self.words W_AbstractObjectWithClassReference._become(self, w_other)
def invariant(self): return (W_AbstractObjectWithClassReference.invariant(self) and isinstance(self._words(), list))
def fillin(self, space, g_self): W_AbstractObjectWithClassReference.fillin(self, space, g_self) self.mutate() self.bytes = g_self.get_bytes()
def fillin(self, space, g_self): W_AbstractObjectWithClassReference.fillin(self, space, g_self) self.words = g_self.get_ruints()
def __init__(self, space, w_class, size): W_AbstractObjectWithClassReference.__init__(self, space, w_class) self.words = [r_uint(0)] * size
def _become(self, w_other): if not isinstance(w_other, W_BytesObject): raise error.PrimitiveFailedError self.bytes, w_other.bytes = w_other.bytes, self.bytes self.mutate() W_AbstractObjectWithClassReference._become(self, w_other)
def __init__(self, space, w_class, size): W_AbstractObjectWithClassReference.__init__(self, space, w_class) assert isinstance(size, int) self.mutate() self.bytes = ['\x00'] * size