示例#1
0
        public Completion SetDefaultGlobalBindings()
        {
            Completion comp;

            comp = GlobalObject.DefinePropertyOrThrow("Infinity", new PropertyDescriptor(new NumberValue(double.PositiveInfinity), false, false, false));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("NaN", new PropertyDescriptor(new NumberValue(double.NaN), false, false, false));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("undefined", new PropertyDescriptor(UndefinedValue.Instance, false, false, false));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("eval", new PropertyDescriptor(Intrinsics.Eval, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("isFinite", new PropertyDescriptor(Utils.CreateBuiltinFunction(GlobalObjectProperties.isFinite, realm: this), true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("isNaN", new PropertyDescriptor(Utils.CreateBuiltinFunction(GlobalObjectProperties.isNaN, realm: this), true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("parseFloat", new PropertyDescriptor(Utils.CreateBuiltinFunction(GlobalObjectProperties.parseFloat, realm: this), true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("parseInt", new PropertyDescriptor(Utils.CreateBuiltinFunction(GlobalObjectProperties.parseInt, realm: this), true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Function", new PropertyDescriptor(Intrinsics.FunctionConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Array", new PropertyDescriptor(Intrinsics.ArrayConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Boolean", new PropertyDescriptor(Intrinsics.BooleanConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Date", new PropertyDescriptor(Intrinsics.DateConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Error", new PropertyDescriptor(Intrinsics.ErrorConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("RangeError", new PropertyDescriptor(Intrinsics.RangeErrorConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("ReferenceError", new PropertyDescriptor(Intrinsics.ReferenceErrorConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("SyntaxError", new PropertyDescriptor(Intrinsics.SyntaxErrorConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("TypeError", new PropertyDescriptor(Intrinsics.TypeErrorConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("RegExp", new PropertyDescriptor(Intrinsics.RegExpConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }
            comp = GlobalObject.DefinePropertyOrThrow("URIError", new PropertyDescriptor(Intrinsics.URIErrorConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Math", new PropertyDescriptor(Intrinsics.Math, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Number", new PropertyDescriptor(Intrinsics.NumberConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("Object", new PropertyDescriptor(Intrinsics.ObjectConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            comp = GlobalObject.DefinePropertyOrThrow("String", new PropertyDescriptor(Intrinsics.StringConstructor, true, false, true));
            if (comp.IsAbrupt())
            {
                return(comp);
            }

            return(Completion.NormalCompletion());
        }