コード例 #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)
コード例 #2
0
ファイル: numeric.py プロジェクト: HPI-SWA-Lab/RSqueak
 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)
コード例 #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)
コード例 #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
コード例 #5
0
ファイル: numeric.py プロジェクト: HPI-SWA-Lab/RSqueak
 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)
コード例 #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
コード例 #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
コード例 #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)
コード例 #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)
コード例 #10
0
 def invariant(self):
     return (W_AbstractObjectWithClassReference.invariant(self)
             and isinstance(self._words(), list))
コード例 #11
0
 def fillin(self, space, g_self):
     W_AbstractObjectWithClassReference.fillin(self, space, g_self)
     self.mutate()
     self.bytes = g_self.get_bytes()
コード例 #12
0
 def fillin(self, space, g_self):
     W_AbstractObjectWithClassReference.fillin(self, space, g_self)
     self.words = g_self.get_ruints()
コード例 #13
0
 def __init__(self, space, w_class, size):
     W_AbstractObjectWithClassReference.__init__(self, space, w_class)
     self.words = [r_uint(0)] * size
コード例 #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)
コード例 #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
コード例 #16
0
ファイル: numeric.py プロジェクト: HPI-SWA-Lab/RSqueak
 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)