Пример #1
0
 def _get_list(self, i):
     from pycket.values import W_Fixnum
     if i == 0:
         return W_Fixnum(self.vals_fixed_0)
     else:
         assert i == 1
         return W_Fixnum(self.vals_fixed_1)
Пример #2
0
def make_known_char_range_list(args):
    all_known = [None] * LEN_CHAR_RANGES
    for i, (start, end, same_props) in enumerate(known_char_ranges):
        all_known[i] = to_list(
            [W_Fixnum(start),
             W_Fixnum(end),
             W_Bool.make(same_props)])
    return to_list(all_known)
Пример #3
0
def to_num(value):
    if value[0] == "+":
        value = value[1:]

    if value == "inf.0":
        return W_Flonum.INF
    elif value == "-inf.0":
        return W_Flonum.NEGINF
    elif value == "nan.0":
        return W_Flonum.NAN

    if "/" in value:
        if len(re.findall('/', value)) > 1:
            raise Exception(
                "Something's wrong with this rational number : %s" % value)

        sides = value.split("/")
        numer = sides[0]
        denom = sides[1]
        return W_Rational.make(to_num(numer), to_num(denom))

    v = float(value)

    if "." in value:
        return W_Flonum(v)

    else:
        try:
            return W_Fixnum.make(string_to_int(value))
        except ParseStringOverflowError:
            val = rbigint.fromdecimalstr(value)
            return W_Bignum(val)

    raise Exception("Didn't know what to do with this number : %s" % value)
Пример #4
0
 def wrap(self, val):
     assert isinstance(val, float)
     bits = float2longlong(val)
     if is_int32_from_longlong_nan(bits):
         bits = decode_int32_from_longlong_nan(bits)
         return W_Fixnum(bits)
     return W_Flonum(val)
Пример #5
0
 def _get_list(self, i):
     from pycket.values import W_Fixnum
     assert i == 0
     return W_Fixnum(self.vals_fixed_0)
Пример #6
0
 def ref_all(self, w_vector):
     unwrapped = self._storage(w_vector)
     return [W_Fixnum.make_or_interned(i) for i in unwrapped]
Пример #7
0
 def ref_all(self, w_vector):
     unwrapped = self._storage(w_vector)
     return [W_Fixnum.make_or_interned(i) for i in unwrapped]
Пример #8
0
 def wrap(self, val):
     assert isinstance(val, int)
     return W_Fixnum(val)