internal void Add(JsSymbol symbol)
 {
     if (_customSymbolLookup == null)
     {
         _customSymbolLookup = new Dictionary <JsValue, JsSymbol>();
     }
     _customSymbolLookup[symbol._value] = symbol;
 }
Esempio n. 2
0
        protected void SetIntrinsicValue(JsSymbol symbol, JsValue value, bool writable, bool enumerable, bool configurable)
        {
            if (_intrinsicProperties == null)
            {
                _intrinsicProperties = new Dictionary <string, PropertyDescriptor>();
            }

            _intrinsicProperties[symbol.AsSymbol()] = new PropertyDescriptor(value, writable, enumerable, configurable);
        }
Esempio n. 3
0
        public SymbolInstance Construct(JsSymbol symbol)
        {
            var instance = new SymbolInstance(Engine)
            {
                _prototype = PrototypeObject,
                SymbolData = symbol
            };

            return(instance);
        }
Esempio n. 4
0
        public SymbolInstance Construct(JsSymbol symbol)
        {
            var instance = new SymbolInstance(Engine)
            {
                Prototype  = PrototypeObject,
                SymbolData = symbol,
                Extensible = true
            };

            return(instance);
        }
Esempio n. 5
0
        public JsValue For(JsValue thisObj, JsValue[] arguments)
        {
            var stringKey = TypeConverter.ToString(arguments.At(0));

            // 2. ReturnIfAbrupt(stringKey).

            JsSymbol symbol;

            if (!Engine.GlobalSymbolRegistry.TryGetValue(stringKey, out symbol))
            {
                symbol = new JsSymbol(stringKey);
                Engine.GlobalSymbolRegistry.Add(stringKey, symbol);
            }

            return(symbol);
        }
Esempio n. 6
0
        /// <summary>
        /// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-symbol-description
        /// </summary>
        public override JsValue Call(JsValue thisObject, JsValue[] arguments)
        {
            var description = arguments.At(0);
            var descString  = description.IsUndefined()
                ? Undefined
                : TypeConverter.ToString(description);

            if (ReturnOnAbruptCompletion(ref descString))
            {
                return(descString);
            }

            var value = new JsSymbol(TypeConverter.ToString(description));

            return(value);
        }
Esempio n. 7
0
        protected bool TryGetIntrinsicValue(JsSymbol symbol, out JsValue value)
        {
            PropertyDescriptor descriptor;

            if (_intrinsicProperties != null && _intrinsicProperties.TryGetValue(symbol.AsSymbol(), out descriptor))
            {
                value = descriptor.Value;
                return(true);
            }

            if (ReferenceEquals(Prototype, null))
            {
                value = Undefined;
                return(false);
            }

            return(Prototype.TryGetIntrinsicValue(symbol, out value));
        }
 internal bool TryGetSymbol(JsValue key, out JsSymbol symbol)
 {
     symbol = null;
     return(_customSymbolLookup != null &&
            _customSymbolLookup.TryGetValue(key, out symbol));
 }
Esempio n. 9
0
 public SymbolInstance Construct(JsSymbol symbol)
 {
     return(new SymbolInstance(Engine, PrototypeObject, symbol));
 }
Esempio n. 10
0
 private static string SymbolDescriptiveString(JsSymbol symbol) => symbol.ToString();
Esempio n. 11
0
 public string SymbolDescriptiveString(JsSymbol sym)
 {
     return($"Symbol({sym.AsSymbol()})");
 }
Esempio n. 12
0
 internal SymbolInstance(Engine engine, SymbolPrototype prototype, JsSymbol symbol)
     : base(engine, ObjectClass.Symbol)
 {
     _prototype = prototype;
     SymbolData = symbol;
 }
Esempio n. 13
0
 internal void Add(JsSymbol symbol)
 {
     _customSymbolLookup ??= new Dictionary <JsValue, JsSymbol>();
     _customSymbolLookup[symbol._value] = symbol;
 }