Exemple #1
0
        private static EcmaValue InternalizeJsonProperty(RuntimeObject holder, EcmaPropertyKey property, EcmaValue reviver)
        {
            EcmaValue value = holder.Get(property);

            if (value.Type == EcmaValueType.Object)
            {
                RuntimeObject obj = value.ToObject();
                if (EcmaArray.IsArray(value))
                {
                    for (long i = 0, length = value[WellKnownProperty.Length].ToLength(); i < length; i++)
                    {
                        EcmaValue newValue = InternalizeJsonProperty(obj, i, reviver);
                        if (newValue.Type == EcmaValueType.Undefined)
                        {
                            obj.Delete(i);
                        }
                        else
                        {
                            obj.CreateDataProperty(i, newValue);
                        }
                    }
                }
                else
                {
                    foreach (EcmaPropertyKey key in obj.GetEnumerableOwnPropertyKeys().ToArray())
                    {
                        EcmaValue newValue = InternalizeJsonProperty(obj, key, reviver);
                        if (newValue.Type == EcmaValueType.Undefined)
                        {
                            obj.Delete(key);
                        }
                        else
                        {
                            obj.CreateDataProperty(key, newValue);
                        }
                    }
                }
            }
            return(reviver.Call(holder, property.ToValue(), value));
        }