protected override void WriteObjectBody(RuntimeObject obj) { foreach (EcmaPropertyKey propertyKey in obj.GetOwnPropertyKeys()) { EcmaPropertyDescriptor descriptor = obj.GetOwnProperty(propertyKey); if (descriptor != null && descriptor.IsDataDescriptor && descriptor.Enumerable) { WriteProperty(propertyKey, descriptor); } } }
protected virtual void WriteArray(RuntimeObject obj) { WriteToken(InspectorTokenType.ArrayStart); try { long length = obj[WellKnownProperty.Length].ToLength(); long prevIndex = -1; foreach (EcmaPropertyKey propertyKey in obj.GetOwnPropertyKeys()) { EcmaPropertyDescriptor descriptor = obj.GetOwnProperty(propertyKey); if (descriptor == null) { continue; } long index = propertyKey.IsArrayIndex ? propertyKey.ToArrayIndex() : -1; if (index >= 0 && index < length) { if (index > prevIndex + 1) { WriteArrayElision(index - prevIndex - 1); } WriteArrayItem(propertyKey, descriptor); prevIndex = index; } else { if (length > prevIndex + 1) { WriteArrayElision(length - prevIndex - 1); } prevIndex = length; if (descriptor.Enumerable) { WriteProperty(propertyKey, descriptor); } } if (this.LastToken == InspectorTokenType.Ellipsis) { prevIndex = length; break; } } if (length > prevIndex + 1) { WriteArrayElision(length - prevIndex - 1); } } catch { WriteToken(InspectorTokenType.Ellipsis); } WriteToken(InspectorTokenType.ArrayEnd); }
public InspectorMetaObject(RuntimeObject obj) { Guard.ArgumentNotNull(obj, "obj"); this.EnumerableProperties = new InspectorMetaObjectEntryCollection(); this.NonEnumerableProperties = new InspectorMetaObjectEntryCollection(); if (!(obj is RuntimeObjectProxy)) { this.Prototype = new EcmaValue(obj.GetPrototypeOf()); if (this.Prototype.IsNullOrUndefined) { this.Prototype = EcmaValue.Null; } for (RuntimeObject cur = obj; cur != null; cur = cur.GetPrototypeOf()) { foreach (EcmaPropertyKey property in cur.GetOwnPropertyKeys()) { EcmaPropertyDescriptor descriptor = cur.GetOwnProperty(property); if (descriptor == null || (descriptor.IsDataDescriptor && cur != obj)) { continue; } EcmaValue value; if (descriptor.IsDataDescriptor) { value = descriptor.Value; } else { try { value = descriptor.Get.Call(obj); } catch (EcmaException ex) { value = String.Format("{0}: {1}", ex.ErrorType, ex.Message); } catch (Exception ex) { value = ex.Message; } if (cur == obj) { if (descriptor.Get) { NonEnumerableProperties.Add("get " + property, descriptor.Get); } if (descriptor.Set) { NonEnumerableProperties.Add("set " + property, descriptor.Get); } } } if (descriptor.Enumerable) { EnumerableProperties.Add(property, value); } else { NonEnumerableProperties.Add(property, value); } } } } if (obj is IInspectorMetaProvider provider) { try { provider.FillInInspectorMetaObject(this); } catch { } } }