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

Side by Side Diff: runtime/vm/object.cc

Issue 199363002: Rework library and class view pages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/service/service.dart ('k') | runtime/vm/service.cc » ('j') | 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 3755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 jsobj.AddProperty("type", "Null"); 3766 jsobj.AddProperty("type", "Null");
3767 return; 3767 return;
3768 } 3768 }
3769 const char* internal_class_name = String::Handle(Name()).ToCString(); 3769 const char* internal_class_name = String::Handle(Name()).ToCString();
3770 const char* user_visible_class_name = 3770 const char* user_visible_class_name =
3771 String::Handle(UserVisibleName()).ToCString(); 3771 String::Handle(UserVisibleName()).ToCString();
3772 jsobj.AddProperty("type", JSONType(ref)); 3772 jsobj.AddProperty("type", JSONType(ref));
3773 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); 3773 jsobj.AddPropertyF("id", "classes/%" Pd "", id());
3774 jsobj.AddProperty("name", internal_class_name); 3774 jsobj.AddProperty("name", internal_class_name);
3775 jsobj.AddProperty("user_name", user_visible_class_name); 3775 jsobj.AddProperty("user_name", user_visible_class_name);
3776 if (!ref) { 3776 if (ref) {
3777 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); 3777 return;
3778 if (!err.IsNull()) { 3778 }
3779 jsobj.AddProperty("error", err); 3779
3780 } 3780 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current()));
3781 jsobj.AddProperty("implemented", is_implemented()); 3781 if (!err.IsNull()) {
3782 jsobj.AddProperty("abstract", is_abstract()); 3782 jsobj.AddProperty("error", err);
3783 jsobj.AddProperty("patch", is_patch()); 3783 }
3784 jsobj.AddProperty("finalized", is_finalized()); 3784 jsobj.AddProperty("implemented", is_implemented());
3785 jsobj.AddProperty("const", is_const()); 3785 jsobj.AddProperty("abstract", is_abstract());
3786 jsobj.AddProperty("super", Class::Handle(SuperClass())); 3786 jsobj.AddProperty("patch", is_patch());
3787 jsobj.AddProperty("library", Object::Handle(library())); 3787 jsobj.AddProperty("finalized", is_finalized());
3788 { 3788 jsobj.AddProperty("const", is_const());
3789 JSONArray fields_array(&jsobj, "fields"); 3789 jsobj.AddProperty("super", Class::Handle(SuperClass()));
3790 const Array& field_array = Array::Handle(fields()); 3790 jsobj.AddProperty("library", Object::Handle(library()));
3791 Field& field = Field::Handle(); 3791 const Script& script = Script::Handle(this->script());
3792 if (!field_array.IsNull()) { 3792 intptr_t line_number = 0;
3793 for (intptr_t i = 0; i < field_array.Length(); ++i) { 3793 intptr_t column_number = 0;
3794 field ^= field_array.At(i); 3794 script.GetTokenLocation(token_pos(), &line_number, &column_number);
3795 fields_array.AddValue(field); 3795 jsobj.AddProperty("script", script);
3796 jsobj.AddProperty("line", line_number);
3797 jsobj.AddProperty("col", column_number);
3798 {
3799 JSONArray interfaces_array(&jsobj, "interfaces");
3800 const Array& interface_array = Array::Handle(interfaces());
3801 Type& interface_type = Type::Handle();
3802 Class& interface_cls = Class::Handle();
3803 if (!interface_array.IsNull()) {
3804 for (intptr_t i = 0; i < interface_array.Length(); ++i) {
3805 // TODO(turnidge): Use the Type directly once regis has added
3806 // types to the vmservice.
3807 interface_type ^= interface_array.At(i);
3808 if (interface_type.HasResolvedTypeClass()) {
3809 interface_cls = interface_type.type_class();
3810 interfaces_array.AddValue(interface_cls);
3796 } 3811 }
3797 } 3812 }
3798 } 3813 }
3799 { 3814 }
3800 JSONArray functions_array(&jsobj, "functions"); 3815 {
3801 const Array& function_array = Array::Handle(functions()); 3816 JSONArray fields_array(&jsobj, "fields");
3802 Function& function = Function::Handle(); 3817 const Array& field_array = Array::Handle(fields());
3803 if (!function_array.IsNull()) { 3818 Field& field = Field::Handle();
3804 for (intptr_t i = 0; i < function_array.Length(); i++) { 3819 if (!field_array.IsNull()) {
3805 function ^= function_array.At(i); 3820 for (intptr_t i = 0; i < field_array.Length(); ++i) {
3806 functions_array.AddValue(function); 3821 field ^= field_array.At(i);
3822 fields_array.AddValue(field);
3823 }
3824 }
3825 }
3826 {
3827 JSONArray functions_array(&jsobj, "functions");
3828 const Array& function_array = Array::Handle(functions());
3829 Function& function = Function::Handle();
3830 if (!function_array.IsNull()) {
3831 for (intptr_t i = 0; i < function_array.Length(); i++) {
3832 function ^= function_array.At(i);
3833 functions_array.AddValue(function);
3834 }
3835 }
3836 }
3837 {
3838 JSONArray subclasses_array(&jsobj, "subclasses");
3839 const GrowableObjectArray& subclasses =
3840 GrowableObjectArray::Handle(direct_subclasses());
3841 if (!subclasses.IsNull()) {
3842 Class& subclass = Class::Handle();
3843 if (!subclasses.IsNull()) {
3844 for (intptr_t i = 0; i < subclasses.Length(); ++i) {
3845 // TODO(turnidge): Use the Type directly once regis has added
3846 // types to the vmservice.
3847 subclass ^= subclasses.At(i);
3848 subclasses_array.AddValue(subclass);
3807 } 3849 }
3808 } 3850 }
3809 } 3851 }
3810 } 3852 }
3811 } 3853 }
3812 3854
3813 3855
3814 void Class::InsertCanonicalConstant(intptr_t index, 3856 void Class::InsertCanonicalConstant(intptr_t index,
3815 const Instance& constant) const { 3857 const Instance& constant) const {
3816 // The constant needs to be added to the list. Grow the list if it is full. 3858 // The constant needs to be added to the list. Grow the list if it is full.
(...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after
6076 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6118 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6077 OS::SNPrint(chars, len, kFormat, function_name, 6119 OS::SNPrint(chars, len, kFormat, function_name,
6078 static_str, abstract_str, kind_str, const_str); 6120 static_str, abstract_str, kind_str, const_str);
6079 return chars; 6121 return chars;
6080 } 6122 }
6081 6123
6082 6124
6083 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { 6125 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const {
6084 const char* internal_name = String::Handle(name()).ToCString(); 6126 const char* internal_name = String::Handle(name()).ToCString();
6085 const char* user_name = 6127 const char* user_name =
6086 String::Handle(QualifiedUserVisibleName()).ToCString(); 6128 String::Handle(UserVisibleName()).ToCString();
6087 Class& cls = Class::Handle(Owner()); 6129 Class& cls = Class::Handle(Owner());
6088 ASSERT(!cls.IsNull()); 6130 ASSERT(!cls.IsNull());
6089 Error& err = Error::Handle(); 6131 Error& err = Error::Handle();
6090 err ^= cls.EnsureIsFinalized(Isolate::Current()); 6132 err ^= cls.EnsureIsFinalized(Isolate::Current());
6091 ASSERT(err.IsNull()); 6133 ASSERT(err.IsNull());
6092 intptr_t id = -1; 6134 intptr_t id = -1;
6093 const char* selector = NULL; 6135 const char* selector = NULL;
6094 if (IsNonImplicitClosureFunction()) { 6136 if (IsNonImplicitClosureFunction()) {
6095 id = cls.FindClosureIndex(*this); 6137 id = cls.FindClosureIndex(*this);
6096 selector = "closures"; 6138 selector = "closures";
6097 } else if (IsImplicitClosureFunction()) { 6139 } else if (IsImplicitClosureFunction()) {
6098 id = cls.FindImplicitClosureFunctionIndex(*this); 6140 id = cls.FindImplicitClosureFunctionIndex(*this);
6099 selector = "implicit_closures"; 6141 selector = "implicit_closures";
6100 } else if (IsNoSuchMethodDispatcher() || IsInvokeFieldDispatcher()) { 6142 } else if (IsNoSuchMethodDispatcher() || IsInvokeFieldDispatcher()) {
6101 id = cls.FindInvocationDispatcherFunctionIndex(*this); 6143 id = cls.FindInvocationDispatcherFunctionIndex(*this);
6102 selector = "dispatchers"; 6144 selector = "dispatchers";
6103 } else { 6145 } else {
6104 id = cls.FindFunctionIndex(*this); 6146 id = cls.FindFunctionIndex(*this);
6105 selector = "functions"; 6147 selector = "functions";
6106 } 6148 }
6107 ASSERT(id >= 0); 6149 ASSERT(id >= 0);
6108 intptr_t cid = cls.id(); 6150 intptr_t cid = cls.id();
6109 JSONObject jsobj(stream); 6151 JSONObject jsobj(stream);
6110 jsobj.AddProperty("type", JSONType(ref)); 6152 jsobj.AddProperty("type", JSONType(ref));
6111 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); 6153 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id);
6112 jsobj.AddProperty("name", internal_name); 6154 jsobj.AddProperty("name", internal_name);
6113 jsobj.AddProperty("user_name", user_name); 6155 jsobj.AddProperty("user_name", user_name);
6114 jsobj.AddProperty("class", cls); 6156 jsobj.AddProperty("class", cls);
6157 const Function& parent = Function::Handle(parent_function());
6158 if (!parent.IsNull()) {
6159 jsobj.AddProperty("parent", parent);
6160 }
6115 const char* kind_string = Function::KindToCString(kind()); 6161 const char* kind_string = Function::KindToCString(kind());
6116 jsobj.AddProperty("kind", kind_string); 6162 jsobj.AddProperty("kind", kind_string);
6117 if (ref) return; 6163 if (ref) {
6164 return;
6165 }
6118 jsobj.AddProperty("is_static", is_static()); 6166 jsobj.AddProperty("is_static", is_static());
6119 jsobj.AddProperty("is_const", is_const()); 6167 jsobj.AddProperty("is_const", is_const());
6120 jsobj.AddProperty("is_optimizable", is_optimizable()); 6168 jsobj.AddProperty("is_optimizable", is_optimizable());
6121 jsobj.AddProperty("is_inlinable", IsInlineable()); 6169 jsobj.AddProperty("is_inlinable", IsInlineable());
6122 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); 6170 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code()));
6123 jsobj.AddProperty("usage_counter", usage_counter()); 6171 jsobj.AddProperty("usage_counter", usage_counter());
6124 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); 6172 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count());
6125 jsobj.AddProperty("code", Object::Handle(CurrentCode())); 6173 jsobj.AddProperty("code", Object::Handle(CurrentCode()));
6126 jsobj.AddProperty("deoptimizations", 6174 jsobj.AddProperty("deoptimizations",
6127 static_cast<intptr_t>(deoptimization_counter())); 6175 static_cast<intptr_t>(deoptimization_counter()));
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after
8761 const String& name = String::Handle(url()); 8809 const String& name = String::Handle(url());
8762 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 8810 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1;
8763 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 8811 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8764 OS::SNPrint(chars, len, kFormat, name.ToCString()); 8812 OS::SNPrint(chars, len, kFormat, name.ToCString());
8765 return chars; 8813 return chars;
8766 } 8814 }
8767 8815
8768 8816
8769 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { 8817 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const {
8770 const char* library_name = String::Handle(name()).ToCString(); 8818 const char* library_name = String::Handle(name()).ToCString();
8771 const char* library_url = String::Handle(url()).ToCString();
8772 intptr_t id = index(); 8819 intptr_t id = index();
8773 ASSERT(id >= 0); 8820 ASSERT(id >= 0);
8774 JSONObject jsobj(stream); 8821 JSONObject jsobj(stream);
8775 jsobj.AddProperty("type", JSONType(ref)); 8822 jsobj.AddProperty("type", JSONType(ref));
8776 jsobj.AddPropertyF("id", "libraries/%" Pd "", id); 8823 jsobj.AddPropertyF("id", "libraries/%" Pd "", id);
8824 jsobj.AddProperty("user_name", library_name);
8777 jsobj.AddProperty("name", library_name); 8825 jsobj.AddProperty("name", library_name);
8778 jsobj.AddProperty("user_name", library_url); 8826 if (ref) {
8779 if (ref) return; 8827 return;
8828 }
8829 const char* library_url = String::Handle(url()).ToCString();
8830 jsobj.AddProperty("url", library_url);
8780 { 8831 {
8781 JSONArray jsarr(&jsobj, "classes"); 8832 JSONArray jsarr(&jsobj, "classes");
8782 ClassDictionaryIterator class_iter(*this); 8833 ClassDictionaryIterator class_iter(*this);
8783 Class& klass = Class::Handle(); 8834 Class& klass = Class::Handle();
8784 while (class_iter.HasNext()) { 8835 while (class_iter.HasNext()) {
8785 klass = class_iter.GetNextClass(); 8836 klass = class_iter.GetNextClass();
8786 if (!klass.IsCanonicalSignatureClass() && 8837 if (!klass.IsCanonicalSignatureClass() &&
8787 !klass.IsAnonymousMixinApplication()) { 8838 !klass.IsAnonymousMixinApplication()) {
8788 jsarr.AddValue(klass); 8839 jsarr.AddValue(klass);
8789 } 8840 }
8790 } 8841 }
8791 } 8842 }
8792 { 8843 {
8793 JSONArray jsarr(&jsobj, "libraries"); 8844 JSONArray jsarr(&jsobj, "imports");
8794 Library& lib = Library::Handle(); 8845 Library& lib = Library::Handle();
8795 for (intptr_t i = 0; i < num_imports(); i++) { 8846 for (intptr_t i = 0; i < num_imports(); i++) {
8796 lib = ImportLibraryAt(i); 8847 lib = ImportLibraryAt(i);
8797 jsarr.AddValue(lib); 8848 jsarr.AddValue(lib);
8798 } 8849 }
8799 } 8850 }
8800 { 8851 {
8801 JSONArray jsarr(&jsobj, "variables"); 8852 JSONArray jsarr(&jsobj, "variables");
8802 DictionaryIterator entries(*this); 8853 DictionaryIterator entries(*this);
8803 Object& entry = Object::Handle(); 8854 Object& entry = Object::Handle();
(...skipping 8842 matching lines...) Expand 10 before | Expand all | Expand 10 after
17646 return "_MirrorReference"; 17697 return "_MirrorReference";
17647 } 17698 }
17648 17699
17649 17700
17650 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17701 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17651 Instance::PrintToJSONStream(stream, ref); 17702 Instance::PrintToJSONStream(stream, ref);
17652 } 17703 }
17653 17704
17654 17705
17655 } // namespace dart 17706 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/service/service.dart ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698