public static ScriptObject ToObject(Environment env, BoxedValue v) { switch (v.Tag) { case TypeTags.Object: case TypeTags.Function: return v.Object; case TypeTags.SuffixString: return env.NewString(v.Clr.ToString()); case TypeTags.String: return env.NewString(v.String); case TypeTags.Bool: return env.NewBoolean(v.Bool); case TypeTags.Clr: case TypeTags.Undefined: return env.RaiseTypeError<ScriptObject>("Can't convert Undefined, Null or CLR to Object"); default: return env.NewNumber(v.Number); } }
public static ScriptObject ToObject(Environment env, double n) { return env.NewNumber(n); }