示例#1
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);
        }
示例#2
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);
        }
示例#3
0
        public static EcmaValue[] CreateListFromArrayLike(EcmaValue value)
        {
            Guard.ArgumentIsObject(value);
            long len = value[WellKnownProperty.Length].ToLength();

            EcmaValue[] arr = new EcmaValue[len];
            for (long i = 0; i < len; i++)
            {
                arr[i] = value[i];
            }
            return(arr);
        }
示例#4
0
        private bool TryGetResult(EcmaPropertyKey propertyKey, EcmaValue value, out bool done, out EcmaValue result)
        {
            RuntimeObject method = target.GetMethod(propertyKey);

            if (method == null)
            {
                result = value;
                done   = true;
                return(false);
            }
            EcmaValue obj = method.Call(target, value);

            Guard.ArgumentIsObject(obj);
            done   = obj[WellKnownProperty.Done].ToBoolean();
            result = obj[WellKnownProperty.Value];
            return(true);
        }
示例#5
0
        public bool MoveNext(params EcmaValue[] value)
        {
            if (this.done)
            {
                return(false);
            }
            EcmaValue result = this.nextMethod.Call(this.iterator, value);

            Guard.ArgumentIsObject(result);
            if (result[WellKnownProperty.Done])
            {
                this.done = true;
                return(false);
            }
            this.Current = result[WellKnownProperty.Value];
            return(true);
        }