Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1256)

Unified Diff: runtime/vm/object.cc

Issue 110703002: Add an instance view page to the vmservice. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 31070)
+++ runtime/vm/object.cc (working copy)
@@ -5896,8 +5896,14 @@
return chars;
}
+void Field::PrintToJSONStream(JSONStream* stream, bool ref) const {
+ PrintToJSONStreamWithInstance(stream, Object::null_instance(), ref);
+}
-void Field::PrintToJSONStream(JSONStream* stream, bool ref) const {
+
+void Field::PrintToJSONStreamWithInstance(JSONStream* stream,
+ const Instance& instance,
+ bool ref) const {
JSONObject jsobj(stream);
const char* internal_field_name = String::Handle(name()).ToCString();
const char* field_name = String::Handle(UserVisibleName()).ToCString();
@@ -5910,6 +5916,9 @@
if (is_static()) {
const Object& valueObj = Object::Handle(value());
jsobj.AddProperty("value", valueObj);
+ } else if (!instance.IsNull()) {
+ const Object& valueObj = Object::Handle(instance.GetField(*this));
+ jsobj.AddProperty("value", valueObj);
}
Class& cls = Class::Handle(owner());
jsobj.AddProperty("owner", cls);
@@ -11422,16 +11431,36 @@
jsobj.AddProperty("type", JSONType(ref));
jsobj.AddProperty("id", id);
+ Class& cls = Class::Handle(this->clazz());
+ jsobj.AddProperty("class", cls);
+
// Set the "preview" property for this instance.
if (IsNull()) {
jsobj.AddProperty("preview", "null");
- } else if (raw() == Object::sentinel().raw() ||
- raw() == Object::transition_sentinel().raw()) {
- jsobj.AddProperty("preview", "<uninitialized>");
} else {
- // TODO(turnidge): Handle special characters? Truncate?
- jsobj.AddProperty("preview", ToCString());
+ jsobj.AddProperty("preview", ToUserCString(40));
}
+ if (ref) {
+ return;
+ }
+
+ // Walk the superclass chain, adding all instance fields.
+ {
+ JSONArray jsarr(&jsobj, "fields");
+ while (!cls.IsNull()) {
+ const Array& field_array = Array::Handle(cls.fields());
+ Field& field = Field::Handle();
+ if (!field_array.IsNull()) {
+ for (intptr_t i = 0; i < field_array.Length(); i++) {
+ field ^= field_array.At(i);
+ if (!field.is_static()) {
+ jsarr.AddValue(field, *this);
+ }
+ }
+ }
+ cls = cls.SuperClass();
+ }
+ }
}
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698