Esempio n. 1
0
 def lshift(self, space, shift):
     # shift > 0, therefore the highest bit of upperbound is not set,
     # i.e. upperbound is positive
     upperbound = intmask(r_uint(-1) >> shift)
     if 0 <= self.value <= upperbound:
         shifted = intmask(self.value << shift)
         return space.wrap_positive_32bit_int(shifted)
     else:
         raise error.PrimitiveFailedError()
Esempio n. 2
0
 def atput0(self, space, index0, w_value):
     if index0 < self.bytecodeoffset():
         if index0 % constants.BYTES_PER_WORD != 0:
             raise error.PrimitiveFailedError("improper store")
         self.literalatput0(space, index0 / constants.BYTES_PER_WORD, w_value)
     else:
         index0 = index0 - self.bytecodeoffset()
         assert index0 < len(self.bytes)
         self.setchar(index0, chr(space.unwrap_int(w_value)))
Esempio n. 3
0
 def lshift(self, space, shift):
     from rpython.rlib.rarithmetic import ovfcheck, intmask, r_uint
     # shift > 0, therefore the highest bit of upperbound is not set,
     # i.e. upperbound is positive
     upperbound = intmask(r_uint(-1) >> shift)
     if 0 <= self.value <= upperbound:
         shifted = intmask(self.value << shift)
         return space.wrap_positive_32bit_int(shifted)
     else:
         try:
             shifted = ovfcheck(self.value << shift)
         except OverflowError:
             raise error.PrimitiveFailedError()
         return space.wrap_int(shifted)
     raise PrimitiveFailedError
Esempio n. 4
0
def debugPrint(interp, s_frame, w_rcvr, w_string):
    if not isinstance(w_string, model.W_BytesObject):
        raise error.PrimitiveFailedError()
    print w_string.as_string().replace('\r', '\n')
    return w_rcvr
Esempio n. 5
0
 def rshift(self, space, shift):
     raise error.PrimitiveFailedError()
Esempio n. 6
0
 def call(self, name, interp, s_frame, argcount, s_method):
     func = self._find_prim(name)
     if not func:
         raise error.PrimitiveFailedError("Not implemented: %s" % name)
     else:
         return func(interp, s_frame, argcount, s_method)