public StringConstructor(FunctionPrototype prototype, Realm realm)
        {
            this.prototype = prototype;
            DefinePropertyOrThrow("prototype", new PropertyDescriptor(prototype, true, false, false));

            DefinePropertyOrThrow("fromCharCode", new PropertyDescriptor(Utils.CreateBuiltinFunction(fromCharCode, realm: realm), true, false, false));
        }
示例#2
0
        public ErrorConstructor(FunctionPrototype prototype, string name)
        {
            this.prototype = prototype;
            Name           = name;
            DefinePropertyOrThrow("prototype", new PropertyDescriptor(prototype, true, false, false));
            DefinePropertyOrThrow("name", new PropertyDescriptor(new StringValue(name), false, false, true));

            dispatchPrototype = name switch
            {
                "RangeError" => i => i.RangeErrorPrototype,
                "ReferenceError" => i => i.ReferenceErrorPrototype,
                "SyntaxError" => i => i.SyntaxErrorPrototype,
                "TypeError" => i => i.TypeErrorPrototype,
                "URIError" => i => i.URIErrorPrototype,
                "Error" => i => i.ErrorPrototype,
                _ => throw new InvalidOperationException($"Invalid error constructor name {name}")
            };
        }
        public NumberConstructor(FunctionPrototype prototype, Realm realm)
        {
            this.prototype = prototype;
            DefinePropertyOrThrow("prototype", new PropertyDescriptor(prototype, true, false, false));

            DefinePropertyOrThrow("isFinite", new PropertyDescriptor(Utils.CreateBuiltinFunction(isFinite, realm), true, false, false));
            DefinePropertyOrThrow("isInteger", new PropertyDescriptor(Utils.CreateBuiltinFunction(isInteger, realm), true, false, false));
            DefinePropertyOrThrow("isNaN", new PropertyDescriptor(Utils.CreateBuiltinFunction(isNaN, realm), true, false, false));
            DefinePropertyOrThrow("isSafeInteger", new PropertyDescriptor(Utils.CreateBuiltinFunction(isSafeInteger, realm), true, false, false));
            DefinePropertyOrThrow("parseFloat", new PropertyDescriptor(Utils.CreateBuiltinFunction(GlobalObjectProperties.parseFloat, realm), true, false, false));
            DefinePropertyOrThrow("parseInt", new PropertyDescriptor(Utils.CreateBuiltinFunction(GlobalObjectProperties.parseInt, realm), true, false, false));

            DefinePropertyOrThrow("EPSILON", new PropertyDescriptor(new NumberValue(2.2204460492503130808472633361816E-16), false, false, false));
            DefinePropertyOrThrow("MAX_SAFE_INTEGER", new PropertyDescriptor(new NumberValue((1 << 53) - 1), false, false, false));
            DefinePropertyOrThrow("MAX_VALUE", new PropertyDescriptor(new NumberValue(double.MaxValue), false, false, false));
            DefinePropertyOrThrow("MIN_SAFE_INTEGER", new PropertyDescriptor(new NumberValue(-((1 << 53) - 1)), false, false, false));
            DefinePropertyOrThrow("MIN_VALUE", new PropertyDescriptor(new NumberValue(double.Epsilon), false, false, false));
            DefinePropertyOrThrow("NaN", new PropertyDescriptor(new NumberValue(double.NaN), false, false, false));
            DefinePropertyOrThrow("NEGATIVE_INFINITY", new PropertyDescriptor(new NumberValue(double.NegativeInfinity), false, false, false));
            DefinePropertyOrThrow("POSITIVE_INFINITY", new PropertyDescriptor(new NumberValue(double.PositiveInfinity), false, false, false));
        }
示例#4
0
 public DateConstructor(FunctionPrototype prototype)
 {
     this.prototype = prototype;
     DefinePropertyOrThrow("prototype", new PropertyDescriptor(prototype, true, false, false));
 }
示例#5
0
 public RegExpConstructor(FunctionPrototype prototype, Realm realm)
 {
     this.prototype = prototype;
     DefinePropertyOrThrow("@@species", new PropertyDescriptor(Utils.CreateBuiltinFunction((a, b) => Completion.NormalCompletion(this), realm), null, false, false));
 }
示例#6
0
 public BooleanConstructor(FunctionPrototype prototype)
 {
     this.prototype = prototype;
 }
 public FunctionConstructor(ObjectPrototype objectPrototype)
 {
     prototype = new FunctionPrototype(objectPrototype);
     DefinePropertyOrThrow("prototype", new PropertyDescriptor(prototype, true, false, false));
 }
示例#8
0
 public ArrayConstructor(FunctionPrototype prototype)
 {
     this.prototype = prototype;
 }