Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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
Beispiel #5
0
 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)
Beispiel #6
0
 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
Beispiel #7
0
 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
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 def invariant(self):
     return (W_AbstractObjectWithClassReference.invariant(self)
             and isinstance(self._words(), list))
Beispiel #11
0
 def fillin(self, space, g_self):
     W_AbstractObjectWithClassReference.fillin(self, space, g_self)
     self.mutate()
     self.bytes = g_self.get_bytes()
Beispiel #12
0
 def fillin(self, space, g_self):
     W_AbstractObjectWithClassReference.fillin(self, space, g_self)
     self.words = g_self.get_ruints()
Beispiel #13
0
 def __init__(self, space, w_class, size):
     W_AbstractObjectWithClassReference.__init__(self, space, w_class)
     self.words = [r_uint(0)] * size
Beispiel #14
0
 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)
Beispiel #15
0
 def __init__(self, space, w_class, size):
     W_AbstractObjectWithClassReference.__init__(self, space, w_class)
     assert isinstance(size, int)
     self.mutate()
     self.bytes = ['\x00'] * size
Beispiel #16
0
 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)