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

            if (descriptor == null)
            {
                return(default);
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public EcmaObject(Hashtable properties)
     : this()
 {
     foreach (DictionaryEntry entry in properties)
     {
         this.CreateDataProperty(EcmaPropertyKey.FromValue(new EcmaValue(entry.Key)), new EcmaValue(entry.Value));
     }
 }
Exemplo n.º 4
0
 public static bool In(this EcmaValue thisValue, EcmaValue other)
 {
     if (other.Type != EcmaValueType.Object)
     {
         throw new EcmaTypeErrorException(InternalString.Error.NotObject);
     }
     return(other.HasProperty(EcmaPropertyKey.FromValue(thisValue)));
 }
Exemplo n.º 5
0
        public static EcmaValue FromEntries(EcmaValue iterator)
        {
            EcmaObject obj = new EcmaObject();

            foreach (EcmaValue entry in iterator.ForOf())
            {
                if (entry.Type != EcmaValueType.Object)
                {
                    throw new EcmaTypeErrorException(InternalString.Error.EntryNotObject);
                }
                EcmaValue key   = entry[0];
                EcmaValue value = entry[1];
                obj.CreateDataProperty(EcmaPropertyKey.FromValue(key), value);
            }
            return(obj);
        }