示例#1
0
        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);
            }
        }
示例#2
0
 public static ScriptObject ToObject(Environment env, double n)
 {
     return env.NewNumber(n);
 }