Represents a property name and value.
コード例 #1
0
ファイル: TypedArrayInstance.cs プロジェクト: jmdjr/jurassic
        /// <summary>
        /// Creates the TypedArray prototype object.
        /// </summary>
        /// <param name="engine"> The script environment. </param>
        /// <param name="constructor"> A reference to the constructor that owns the prototype. </param>
        internal static ObjectInstance CreatePrototype(ScriptEngine engine, TypedArrayConstructor constructor)
        {
            var result     = engine.Object.Construct();
            var properties = GetDeclarativeProperties(engine);

            properties.Add(new PropertyNameAndValue("constructor", constructor, PropertyAttributes.NonEnumerable));

            // From the spec: the initial value of the @@iterator property is the same function
            // object as the initial value of the %TypedArray%.prototype.values property.
            PropertyNameAndValue valuesProperty = properties.Find(p => "values".Equals(p.Key));

            if (valuesProperty == null)
            {
                throw new InvalidOperationException("Expected values property.");
            }
            properties.Add(new PropertyNameAndValue(Symbol.Iterator, valuesProperty.Value, PropertyAttributes.NonEnumerable));

            result.InitializeProperties(properties);
            return(result);
        }
コード例 #2
0
ファイル: MapInstance.cs プロジェクト: xinqinglhj/jurassic
        /// <summary>
        /// Creates the Map prototype object.
        /// </summary>
        /// <param name="engine"> The script environment. </param>
        /// <param name="constructor"> A reference to the constructor that owns the prototype. </param>
        internal static ObjectInstance CreatePrototype(ScriptEngine engine, MapConstructor constructor)
        {
            var result     = engine.Object.Construct();
            var properties = GetDeclarativeProperties(engine);

            properties.Add(new PropertyNameAndValue("constructor", constructor, PropertyAttributes.NonEnumerable));
            properties.Add(new PropertyNameAndValue(engine.Symbol.ToStringTag, "Map", PropertyAttributes.Configurable));

            // From the spec: the initial value of the @@iterator property is the same function
            // object as the initial value of the Map.prototype.entries property.
            PropertyNameAndValue entriesProperty = properties.Find(p => "entries".Equals(p.Key));

            if (entriesProperty == null)
            {
                throw new InvalidOperationException("Expected entries property.");
            }
            properties.Add(new PropertyNameAndValue(engine.Symbol.Iterator, entriesProperty.Value, PropertyAttributes.NonEnumerable));

            result.FastSetProperties(properties);
            return(result);
        }