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
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)
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
def func(interp, f): w_res = utility.wrap_float(math.exp(f)) return w_res
def func(interp, f): if f < 0.0: raise PrimitiveFailedError w_res = utility.wrap_float(math.sqrt(f)) return w_res
def func(interp, rcvr, arg): w_res = utility.wrap_float(math.ldexp(rcvr, arg)) return w_res
def func(interp, v1, v2): w_res = utility.wrap_float(op(v1, v2)) return w_res