Exemplo n.º 1
0
        /// <summary>
        /// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-delete-p
        /// </summary>
        public override bool Delete(JsValue property)
        {
            if (!TryCallHandler(TrapDeleteProperty, new[] { _target, TypeConverter.ToPropertyKey(property) }, out var result))
            {
                return(_target.Delete(property));
            }

            var booleanTrapResult = TypeConverter.ToBoolean(result);

            if (!booleanTrapResult)
            {
                return(false);
            }

            var targetDesc = _target.GetOwnProperty(property);

            if (targetDesc == PropertyDescriptor.Undefined)
            {
                return(true);
            }

            if (!targetDesc.Configurable)
            {
                ExceptionHelper.ThrowTypeError(_engine.Realm, $"'deleteProperty' on proxy: trap returned truish for property '{property}' which is non-configurable in the proxy target");
            }

            if (!_target.Extensible)
            {
                ExceptionHelper.ThrowTypeError(_engine.Realm);
            }

            return(true);
        }
Exemplo n.º 2
0
        public override bool Delete(JsValue property)
        {
            if (!TryCallHandler(TrapDeleteProperty, new JsValue[] { _target, property }, out var result))
            {
                return(_target.Delete(property));
            }

            var success = TypeConverter.ToBoolean(result);

            if (success)
            {
                var targetDesc = _target.GetOwnProperty(property);
                if (targetDesc != PropertyDescriptor.Undefined && !targetDesc.Configurable)
                {
                    ExceptionHelper.ThrowTypeError(_engine, $"'deleteProperty' on proxy: trap returned truish for property '{property}' which is non-configurable in the proxy target");
                }
            }

            return(success);
        }
Exemplo n.º 3
0
        public JsValue Pop(JsValue thisObject, JsValue[] arguments)
        {
            ObjectInstance o = TypeConverter.ToObject(Engine, thisObject);
            var lenVal = TypeConverter.ToNumber(o.Get("length"));

            uint len = TypeConverter.ToUint32(lenVal);
            if (len == 0)
            {
                o.Put("length", 0, true);
                return Undefined.Instance;
            }
            else
            {
                len = len - 1;
                string indx = TypeConverter.ToString(len);
                JsValue element = o.Get(indx);
                o.Delete(indx, true);
                o.Put("length", len, true);
                return element;
            }
        }
 public override bool DeleteBinding(string name)
 {
     return(_bindingObject.Delete(name, false));
 }
Exemplo n.º 5
0
 public override void DeleteAt(uint index) => _instance.Delete(TypeConverter.ToString(index), true);