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

Unified Diff: runtime/vm/object.cc

Issue 24075002: Expose field data, use class id, and merge all collections into "objects" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months 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
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index bdfac3c04eebfd88df665dccbf890e9f3ad69cd0..5fd449e170f886281ae2545bb58e1f9a83922f70 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2926,15 +2926,49 @@ const char* Class::ToCString() const {
void Class::PrintToJSONStream(JSONStream* stream, bool ref) const {
- const char* class_name = String::Handle(UserVisibleName()).ToCString();
- ObjectIdRing* ring = Isolate::Current()->object_id_ring();
- intptr_t id = ring->GetIdForObject(raw());
JSONObject jsobj(stream);
+ if ((raw() == Class::null()) || (id() == kFreeListElement)) {
+ jsobj.AddProperty("type", "Null");
+ return;
+ }
+ const char* internal_class_name = "<no name>";
+ const char* user_visible_class_name = "<no name>";
+ internal_class_name = String::Handle(Name()).ToCString();
+ user_visible_class_name = String::Handle(UserVisibleName()).ToCString();
siva 2013/09/17 17:25:33 internal_class_name and user_visible_class_name ar
Cutch 2013/09/19 23:57:39 Done.
jsobj.AddProperty("type", JSONType(ref));
- jsobj.AddProperty("id", id);
- jsobj.AddProperty("name", class_name);
+ jsobj.AddProperty("id", id());
+ jsobj.AddProperty("name", internal_class_name);
+ jsobj.AddProperty("user_name", user_visible_class_name);
if (!ref) {
+ jsobj.AddProperty("implemented", is_implemented());
+ jsobj.AddProperty("abstract", is_abstract());
+ jsobj.AddProperty("patch", is_patch());
+ jsobj.AddProperty("finalized", is_finalized());
+ jsobj.AddProperty("const", is_const());
+ jsobj.AddProperty("super", Class::Handle(SuperClass()));
jsobj.AddProperty("library", Object::Handle(library()));
+ {
+ JSONArray fields_array(&jsobj, "fields");
+ const Array& field_array = Array::Handle(fields());
+ Field& field = Field::Handle();
+ if (!field_array.IsNull()) {
+ for (intptr_t i = 0; i < field_array.Length(); ++i) {
+ field ^= field_array.At(i);
+ fields_array.AddValue(field);
+ }
+ }
+ }
+ {
+ JSONArray functions_array(&jsobj, "functions");
+ const Array& function_array = Array::Handle(functions());
+ Function& function = Function::Handle();
+ if (!function_array.IsNull()) {
+ for (intptr_t i = 0; i < function_array.Length(); i++) {
+ function ^= function_array.At(i);
+ functions_array.AddValue(function);
siva 2013/09/17 17:25:33 Do we only want to list the user defined functions
Cutch 2013/09/19 23:57:39 We should provide the complete list of functions a
+ }
+ }
+ }
}
}
@@ -5090,6 +5124,7 @@ const char* Function::ToCString() const {
void Function::PrintToJSONStream(JSONStream* stream, bool ref) const {
+ const char* internal_function_name = String::Handle(name()).ToCString();
const char* function_name =
String::Handle(QualifiedUserVisibleName()).ToCString();
ObjectIdRing* ring = Isolate::Current()->object_id_ring();
@@ -5097,7 +5132,8 @@ void Function::PrintToJSONStream(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
jsobj.AddProperty("type", JSONType(ref));
jsobj.AddProperty("id", id);
- jsobj.AddProperty("name", function_name);
+ jsobj.AddProperty("name", internal_function_name);
+ jsobj.AddProperty("user_name", function_name);
if (ref) return;
jsobj.AddProperty("is_static", is_static());
jsobj.AddProperty("is_const", is_const());
@@ -5412,6 +5448,42 @@ const char* Field::ToCString() const {
void Field::PrintToJSONStream(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
+ const char* internal_field_name = String::Handle(name()).ToCString();
+ const char* field_name = String::Handle(UserVisibleName()).ToCString();
+ ObjectIdRing* ring = Isolate::Current()->object_id_ring();
+ intptr_t id = ring->GetIdForObject(raw());
+ jsobj.AddProperty("type", JSONType(ref));
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("name", internal_field_name);
+ jsobj.AddProperty("user_name", field_name);
+ if (ref) return;
siva 2013/09/17 17:25:33 Not sure if we have used this style elsewhere. if
Cutch 2013/09/19 23:57:39 Done.
+ Class& cls = Class::Handle(owner());
+ jsobj.AddProperty("type", "Field");
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("name", internal_field_name);
+ jsobj.AddProperty("user_name", field_name);
+ jsobj.AddProperty("class", cls);
+ jsobj.AddProperty("static", is_static());
+ jsobj.AddProperty("final", is_final());
+ jsobj.AddProperty("const", is_const());
+ jsobj.AddProperty("guard_nullable", is_nullable());
+ if (guarded_cid() == kIllegalCid) {
+ jsobj.AddProperty("guard_class", "unknown");
+ } else if (guarded_cid() == kDynamicCid) {
+ jsobj.AddProperty("guard_class", "dynamic");
+ } else {
+ ClassTable* table = Isolate::Current()->class_table();
+ ASSERT(table->IsValidIndex(guarded_cid()));
+ cls ^= table->At(guarded_cid());
+ jsobj.AddProperty("guard_class", cls);
+ }
+ if (guarded_list_length() == kUnknownFixedLength) {
+ jsobj.AddProperty("guard_length", "unknown");
+ } else if (guarded_list_length() == kNoFixedLength) {
+ jsobj.AddProperty("guard_length", "variable");
+ } else {
+ jsobj.AddProperty("guard_length", guarded_list_length());
+ }
}
« no previous file with comments | « runtime/vm/class_table.cc ('k') | runtime/vm/service.cc » ('j') | runtime/vm/service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698