コード例 #1
0
        public static EcmaValue GetOwnPropertyDescriptor(EcmaValue target, EcmaValue property)
        {
            EcmaPropertyDescriptor descriptor = target.ToObject().GetOwnProperty(EcmaPropertyKey.FromValue(property));

            if (descriptor == null)
            {
                return(default);
コード例 #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);
        }
コード例 #3
0
 public EcmaObject(Hashtable properties)
     : this()
 {
     foreach (DictionaryEntry entry in properties)
     {
         this.CreateDataProperty(EcmaPropertyKey.FromValue(new EcmaValue(entry.Key)), new EcmaValue(entry.Value));
     }
 }
コード例 #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)));
 }
コード例 #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);
        }