Exemple #1
0
def wrap(x):
    if isinstance(x, int): return utility.wrap_int(x)
    if isinstance(x, float): return utility.wrap_float(x)
    if isinstance(x, model.W_Object): return x
    if isinstance(x, str) and len(x) == 1: return utility.wrap_char(x)
    if isinstance(x, str): return utility.wrap_string(x)
    raise NotImplementedError
Exemple #2
0
def func(interp, f):
    if f == 0:
        res = -rarithmetic.INFINITY
    elif f < 0:
        res = rarithmetic.NAN
    else:
        res = math.log(f)
    return utility.wrap_float(res)
Exemple #3
0
def func(interp, f): 
    if f == 0:
        res = -rarithmetic.INFINITY
    elif f < 0:
        res = rarithmetic.NAN
    else:
        res = math.log(f)
    return utility.wrap_float(res)
Exemple #4
0
def w(any): 
    if any is None:
        return objtable.w_nil
    if isinstance(any, str):
        # assume never have strings of length 1
        if len(any) == 1: 
            return utility.wrap_chr(any)
        else:
            return utility.wrap_string(any)
    if isinstance(any, int):    
        return utility.wrap_int(any)
    if isinstance(any, bool):
        return utility.wrap_bool(any)
    if isinstance(any, float):
        return utility.wrap_float(any)
    else:
        raise Exception    
Exemple #5
0
def w(any):
    if any is None:
        return objtable.w_nil
    if isinstance(any, str):
        # assume never have strings of length 1
        if len(any) == 1:
            return utility.wrap_chr(any)
        else:
            return utility.wrap_string(any)
    if isinstance(any, int):
        return utility.wrap_int(any)
    if isinstance(any, bool):
        return utility.wrap_bool(any)
    if isinstance(any, float):
        return utility.wrap_float(any)
    else:
        raise Exception
Exemple #6
0
def func(interp, f):
    w_res = utility.wrap_float(math.exp(f))
    return w_res
Exemple #7
0
def func(interp, f):
    if f < 0.0:
        raise PrimitiveFailedError
    w_res = utility.wrap_float(math.sqrt(f))
    return w_res
Exemple #8
0
def func(interp, rcvr, arg):
    w_res = utility.wrap_float(math.ldexp(rcvr, arg))
    return w_res
Exemple #9
0
 def func(interp, v1, v2):
     w_res = utility.wrap_float(op(v1, v2))
     return w_res
Exemple #10
0
def func(interp, f): 
    w_res = utility.wrap_float(math.exp(f))
    return w_res
Exemple #11
0
def func(interp, f): 
    if f < 0.0:
        raise PrimitiveFailedError
    w_res = utility.wrap_float(math.sqrt(f))
    return w_res
Exemple #12
0
def func(interp, rcvr, arg): 
    w_res = utility.wrap_float(math.ldexp(rcvr, arg))
    return w_res
Exemple #13
0
 def func(interp, v1, v2):
     w_res = utility.wrap_float(op(v1, v2))
     return w_res