Ejemplo n.º 1
0
        public static EcmaValue GetOwnPropertyDescriptor(EcmaValue target, EcmaValue property)
        {
            EcmaPropertyDescriptor descriptor = target.ToObject().GetOwnProperty(EcmaPropertyKey.FromValue(property));

            if (descriptor == null)
            {
                return(default);
Ejemplo n.º 2
0
 public override bool DefineOwnProperty(EcmaPropertyKey propertyKey, EcmaPropertyDescriptor descriptor)
 {
     if (propertyKey.IsCanonicalNumericIndex)
     {
         if (IsValidIndex(propertyKey, out int index))
         {
             if (descriptor.IsAccessorDescriptor)
             {
                 return(false);
             }
             if ((descriptor.HasConfigurable && descriptor.Configurable) ||
                 (descriptor.HasEnumerable && !descriptor.Enumerable) ||
                 (descriptor.HasWritable && !descriptor.Writable))
             {
                 return(false);
             }
             if (descriptor.HasValue)
             {
                 SetValueInBuffer(index, descriptor.Value);
             }
             return(true);
         }
         return(false);
     }
     return(base.DefineOwnProperty(propertyKey, descriptor));
 }
Ejemplo n.º 3
0
        public static EcmaValue DefineProperty(EcmaValue target, EcmaValue property, EcmaValue attributes)
        {
            Guard.ArgumentIsObject(target);
            RuntimeObject obj = target.ToObject();

            obj.DefinePropertyOrThrow(EcmaPropertyKey.FromValue(property), EcmaPropertyDescriptor.FromValue(attributes));
            return(target);
        }
Ejemplo n.º 4
0
        public static EcmaValue DefineProperties(EcmaValue target, EcmaValue properties)
        {
            Guard.ArgumentIsObject(target);
            RuntimeObject dst = target.ToObject();

            foreach (EcmaPropertyEntry e in properties.ToObject().GetEnumerableOwnProperties(true))
            {
                dst.DefinePropertyOrThrow(e.Key, EcmaPropertyDescriptor.FromValue(e.Value));
            }
            return(target);
        }
Ejemplo n.º 5
0
 public override bool DefineOwnProperty(EcmaPropertyKey propertyKey, EcmaPropertyDescriptor descriptor)
 {
     if (IsBoundedVariable(propertyKey))
     {
         int index = (int)propertyKey.ToArrayIndex();
         EnsureTainted();
         if (taintedLevel[index] != TaintLevel.BindingTainted)
         {
             if (descriptor.HasValue)
             {
                 arguments[index] = descriptor.Value;
             }
             taintedLevel[index] = !descriptor.IsAccessorDescriptor && (!descriptor.HasWritable || descriptor.Writable) ? TaintLevel.AttributeTainted : TaintLevel.BindingTainted;
         }
     }
     return(base.DefineOwnProperty(propertyKey, descriptor));
 }
Ejemplo n.º 6
0
        public override EcmaPropertyDescriptor GetOwnProperty(EcmaPropertyKey propertyKey)
        {
            EcmaPropertyDescriptor current = base.GetOwnProperty(propertyKey);

            if (EcmaValueUtility.TryIndexByPropertyKey(arguments, propertyKey, out EcmaValue value))
            {
                if (taintedLevel == null)
                {
                    return(new EcmaPropertyDescriptor(value, EcmaPropertyAttributes.DefaultDataProperty));
                }
                if (taintedLevel[propertyKey.ToArrayIndex()] == TaintLevel.AttributeTainted)
                {
                    current.Value = value;
                }
            }
            return(current);
        }