Пример #1
0
        public static ArrayPrototype CreatePrototypeObject(Engine engine, ArrayConstructor arrayConstructor)
        {
            var obj = new ArrayPrototype(engine)
            {
                _prototype        = engine.Object.PrototypeObject,
                _length           = new PropertyDescriptor(JsNumber.PositiveZero, PropertyFlag.Writable),
                _arrayConstructor = arrayConstructor,
            };

            return(obj);
        }
Пример #2
0
 internal ArrayConstructor(
     Engine engine,
     Realm realm,
     FunctionPrototype functionPrototype,
     ObjectPrototype objectPrototype)
     : base(engine, realm, _functionName)
 {
     _prototype           = functionPrototype;
     PrototypeObject      = new ArrayPrototype(engine, realm, this, objectPrototype);
     _length              = new PropertyDescriptor(1, PropertyFlag.Configurable);
     _prototypeDescriptor = new PropertyDescriptor(PrototypeObject, PropertyFlag.AllForbidden);
 }
Пример #3
0
        public static ArrayPrototype CreatePrototypeObject(Engine engine, ArrayConstructor arrayConstructor)
        {
            var obj = new ArrayPrototype(engine)
                {
                    Extensible = true, 
                    Prototype = engine.Object.PrototypeObject
                };

            obj.FastAddProperty("length", 0, true, false, false);
            obj.FastAddProperty("constructor", arrayConstructor, true, false, true);

            return obj;
        }
Пример #4
0
        public static ArrayPrototype CreatePrototypeObject(Engine engine, ArrayConstructor arrayConstructor)
        {
            var obj = new ArrayPrototype(engine)
            {
                Extensible = true,
                Prototype  = engine.Object.PrototypeObject
            };

            obj.FastAddProperty("length", 0, true, false, false);
            obj.FastAddProperty("constructor", arrayConstructor, true, false, true);

            return(obj);
        }
Пример #5
0
        public static ArrayPrototype CreatePrototypeObject(Engine engine, ArrayConstructor arrayConstructor)
        {
            var obj = new ArrayPrototype(engine)
            {
                Extensible = true,
                Prototype  = engine.Object.PrototypeObject
            };

            obj.FastAddProperty("length", 0, true, false, false);
            obj.SetOwnProperty("constructor", new PropertyDescriptor(arrayConstructor, PropertyFlag.NonEnumerable));

            return(obj);
        }
Пример #6
0
        public static ArrayConstructor CreateArrayConstructor(Engine engine)
        {
            var obj = new ArrayConstructor(engine);

            obj.Extensible = true;

            // The value of the [[Prototype]] internal property of the Array constructor is the Function prototype object
            obj.Prototype       = engine.Function.PrototypeObject;
            obj.PrototypeObject = ArrayPrototype.CreatePrototypeObject(engine, obj);

            obj.FastAddProperty("length", 1, false, false, false);

            // The initial value of Array.prototype is the Array prototype object
            obj.FastAddProperty("prototype", obj.PrototypeObject, false, false, false);

            return(obj);
        }
        public static ArrayConstructor CreateArrayConstructor(Engine engine)
        {
            var obj = new ArrayConstructor(engine)
            {
                _prototype = engine.Function.PrototypeObject
            };

            // The value of the [[Prototype]] internal property of the Array constructor is the Function prototype object
            obj.PrototypeObject = ArrayPrototype.CreatePrototypeObject(engine, obj);

            obj._length = new PropertyDescriptor(1, PropertyFlag.Configurable);

            // The initial value of Array.prototype is the Array prototype object
            obj._prototypeDescriptor = new PropertyDescriptor(obj.PrototypeObject, PropertyFlag.AllForbidden);

            return(obj);
        }
Пример #8
0
        public static ArrayConstructor CreateArrayConstructor(Engine engine)
        {
            var obj = new ArrayConstructor(engine);

            obj.Extensible = true;

            // The value of the [[Prototype]] internal property of the Array constructor is the Function prototype object
            obj.Prototype       = engine.Function.PrototypeObject;
            obj.PrototypeObject = ArrayPrototype.CreatePrototypeObject(engine, obj);

            obj.SetOwnProperty("length", new PropertyDescriptor(1, PropertyFlag.AllForbidden));

            // The initial value of Array.prototype is the Array prototype object
            obj.SetOwnProperty("prototype", new PropertyDescriptor(obj.PrototypeObject, PropertyFlag.AllForbidden));

            obj.SetOwnProperty(GlobalSymbolRegistry.Species._value,
                               new GetSetPropertyDescriptor(
                                   get: new ClrFunctionInstance(engine, "get [Symbol.species]", Species, 0, PropertyFlag.Configurable),
                                   set: Undefined,
                                   flags: PropertyFlag.Configurable));

            return(obj);
        }