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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 5878 matching lines...) Expand 10 before | Expand all | Expand 10 after
5889 const char* field_name = String::Handle(name()).ToCString(); 5889 const char* field_name = String::Handle(name()).ToCString();
5890 const Class& cls = Class::Handle(owner()); 5890 const Class& cls = Class::Handle(owner());
5891 const char* cls_name = String::Handle(cls.Name()).ToCString(); 5891 const char* cls_name = String::Handle(cls.Name()).ToCString();
5892 intptr_t len = 5892 intptr_t len =
5893 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; 5893 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1;
5894 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 5894 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
5895 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); 5895 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2);
5896 return chars; 5896 return chars;
5897 } 5897 }
5898 5898
5899 void Field::PrintToJSONStream(JSONStream* stream, bool ref) const {
5900 PrintToJSONStreamWithInstance(stream, Object::null_instance(), ref);
5901 }
5899 5902
5900 void Field::PrintToJSONStream(JSONStream* stream, bool ref) const { 5903
5904 void Field::PrintToJSONStreamWithInstance(JSONStream* stream,
5905 const Instance& instance,
5906 bool ref) const {
5901 JSONObject jsobj(stream); 5907 JSONObject jsobj(stream);
5902 const char* internal_field_name = String::Handle(name()).ToCString(); 5908 const char* internal_field_name = String::Handle(name()).ToCString();
5903 const char* field_name = String::Handle(UserVisibleName()).ToCString(); 5909 const char* field_name = String::Handle(UserVisibleName()).ToCString();
5904 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 5910 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
5905 intptr_t id = ring->GetIdForObject(raw()); 5911 intptr_t id = ring->GetIdForObject(raw());
5906 jsobj.AddProperty("type", JSONType(ref)); 5912 jsobj.AddProperty("type", JSONType(ref));
5907 jsobj.AddProperty("id", id); 5913 jsobj.AddProperty("id", id);
5908 jsobj.AddProperty("name", internal_field_name); 5914 jsobj.AddProperty("name", internal_field_name);
5909 jsobj.AddProperty("user_name", field_name); 5915 jsobj.AddProperty("user_name", field_name);
5910 if (is_static()) { 5916 if (is_static()) {
5911 const Object& valueObj = Object::Handle(value()); 5917 const Object& valueObj = Object::Handle(value());
5912 jsobj.AddProperty("value", valueObj); 5918 jsobj.AddProperty("value", valueObj);
5919 } else if (!instance.IsNull()) {
5920 const Object& valueObj = Object::Handle(instance.GetField(*this));
5921 jsobj.AddProperty("value", valueObj);
5913 } 5922 }
5914 Class& cls = Class::Handle(owner()); 5923 Class& cls = Class::Handle(owner());
5915 jsobj.AddProperty("owner", cls); 5924 jsobj.AddProperty("owner", cls);
5916 AbstractType& declared_type = AbstractType::Handle(type()); 5925 AbstractType& declared_type = AbstractType::Handle(type());
5917 cls = declared_type.type_class(); 5926 cls = declared_type.type_class();
5918 jsobj.AddProperty("declared_type", cls); 5927 jsobj.AddProperty("declared_type", cls);
5919 jsobj.AddProperty("static", is_static()); 5928 jsobj.AddProperty("static", is_static());
5920 jsobj.AddProperty("final", is_final()); 5929 jsobj.AddProperty("final", is_final());
5921 jsobj.AddProperty("const", is_const()); 5930 jsobj.AddProperty("const", is_const());
5922 if (ref) { 5931 if (ref) {
(...skipping 5492 matching lines...) Expand 10 before | Expand all | Expand 10 after
11415 11424
11416 11425
11417 void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const { 11426 void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const {
11418 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 11427 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
11419 intptr_t id = ring->GetIdForObject(raw()); 11428 intptr_t id = ring->GetIdForObject(raw());
11420 11429
11421 JSONObject jsobj(stream); 11430 JSONObject jsobj(stream);
11422 jsobj.AddProperty("type", JSONType(ref)); 11431 jsobj.AddProperty("type", JSONType(ref));
11423 jsobj.AddProperty("id", id); 11432 jsobj.AddProperty("id", id);
11424 11433
11434 Class& cls = Class::Handle(this->clazz());
11435 jsobj.AddProperty("class", cls);
11436
11425 // Set the "preview" property for this instance. 11437 // Set the "preview" property for this instance.
11426 if (IsNull()) { 11438 if (IsNull()) {
11427 jsobj.AddProperty("preview", "null"); 11439 jsobj.AddProperty("preview", "null");
11428 } else if (raw() == Object::sentinel().raw() ||
11429 raw() == Object::transition_sentinel().raw()) {
11430 jsobj.AddProperty("preview", "<uninitialized>");
11431 } else { 11440 } else {
11432 // TODO(turnidge): Handle special characters? Truncate? 11441 jsobj.AddProperty("preview", ToUserCString(40));
11433 jsobj.AddProperty("preview", ToCString()); 11442 }
11443 if (ref) {
11444 return;
11445 }
11446
11447 // Walk the superclass chain, adding all instance fields.
11448 {
11449 JSONArray jsarr(&jsobj, "fields");
11450 while (!cls.IsNull()) {
11451 const Array& field_array = Array::Handle(cls.fields());
11452 Field& field = Field::Handle();
11453 if (!field_array.IsNull()) {
11454 for (intptr_t i = 0; i < field_array.Length(); i++) {
11455 field ^= field_array.At(i);
11456 if (!field.is_static()) {
11457 jsarr.AddValue(field, *this);
11458 }
11459 }
11460 }
11461 cls = cls.SuperClass();
11462 }
11434 } 11463 }
11435 } 11464 }
11436 11465
11437 11466
11438 bool AbstractType::IsResolved() const { 11467 bool AbstractType::IsResolved() const {
11439 // AbstractType is an abstract class. 11468 // AbstractType is an abstract class.
11440 UNREACHABLE(); 11469 UNREACHABLE();
11441 return false; 11470 return false;
11442 } 11471 }
11443 11472
(...skipping 4714 matching lines...) Expand 10 before | Expand all | Expand 10 after
16158 return "_MirrorReference"; 16187 return "_MirrorReference";
16159 } 16188 }
16160 16189
16161 16190
16162 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 16191 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
16163 Instance::PrintToJSONStream(stream, ref); 16192 Instance::PrintToJSONStream(stream, ref);
16164 } 16193 }
16165 16194
16166 16195
16167 } // namespace dart 16196 } // namespace dart
OLDNEW
« 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