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

Side by Side Diff: runtime/vm/service.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/vm/object.cc ('k') | runtime/vm/service_test.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/coverage.h" 10 #include "vm/coverage.h"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 func ^= cls.ClosureFunctionFromIndex(id); 795 func ^= cls.ClosureFunctionFromIndex(id);
796 if (func.IsNull()) { 796 if (func.IsNull()) {
797 PrintError(js, "Closure function %" Pd " not found", id); 797 PrintError(js, "Closure function %" Pd " not found", id);
798 return true; 798 return true;
799 } 799 }
800 func.PrintToJSONStream(js, false); 800 func.PrintToJSONStream(js, false);
801 return true; 801 return true;
802 } 802 }
803 803
804 804
805 static bool HandleClassesEval(Isolate* isolate, const Class& cls,
806 JSONStream* js) {
807 if (js->num_arguments() > 3) {
808 PrintError(js, "Command too long");
809 return true;
810 }
811 const char* expr = js->LookupOption("expr");
812 if (expr == NULL) {
813 PrintError(js, "eval expects an 'expr' option\n",
814 js->num_arguments());
815 return true;
816 }
817 const String& expr_str = String::Handle(isolate, String::New(expr));
818 const Object& result = Object::Handle(cls.Evaluate(expr_str));
819 if (result.IsNull()) {
820 Object::null_instance().PrintToJSONStream(js, true);
821 } else {
822 result.PrintToJSONStream(js, true);
823 }
824 return true;
825 }
826
827
805 static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls, 828 static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls,
806 JSONStream* js) { 829 JSONStream* js) {
807 intptr_t id; 830 intptr_t id;
808 if (js->num_arguments() > 4) { 831 if (js->num_arguments() > 4) {
809 PrintError(js, "Command too long"); 832 PrintError(js, "Command too long");
810 return true; 833 return true;
811 } 834 }
812 if (!GetIntegerId(js->GetArgument(3), &id)) { 835 if (!GetIntegerId(js->GetArgument(3), &id)) {
813 PrintError(js, "Must specify collection object id: dispatchers/id"); 836 PrintError(js, "Must specify collection object id: dispatchers/id");
814 return true; 837 return true;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 if (!table->IsValidIndex(id)) { 928 if (!table->IsValidIndex(id)) {
906 PrintError(js, "%" Pd " is not a valid class id.", id);; 929 PrintError(js, "%" Pd " is not a valid class id.", id);;
907 return true; 930 return true;
908 } 931 }
909 Class& cls = Class::Handle(table->At(id)); 932 Class& cls = Class::Handle(table->At(id));
910 if (js->num_arguments() == 2) { 933 if (js->num_arguments() == 2) {
911 cls.PrintToJSONStream(js, false); 934 cls.PrintToJSONStream(js, false);
912 return true; 935 return true;
913 } else if (js->num_arguments() >= 3) { 936 } else if (js->num_arguments() >= 3) {
914 const char* second = js->GetArgument(2); 937 const char* second = js->GetArgument(2);
915 if (strcmp(second, "closures") == 0) { 938 if (strcmp(second, "eval") == 0) {
939 return HandleClassesEval(isolate, cls, js);
940 } else if (strcmp(second, "closures") == 0) {
916 return HandleClassesClosures(isolate, cls, js); 941 return HandleClassesClosures(isolate, cls, js);
917 } else if (strcmp(second, "fields") == 0) { 942 } else if (strcmp(second, "fields") == 0) {
918 return HandleClassesFields(isolate, cls, js); 943 return HandleClassesFields(isolate, cls, js);
919 } else if (strcmp(second, "functions") == 0) { 944 } else if (strcmp(second, "functions") == 0) {
920 return HandleClassesFunctions(isolate, cls, js); 945 return HandleClassesFunctions(isolate, cls, js);
921 } else if (strcmp(second, "implicit_closures") == 0) { 946 } else if (strcmp(second, "implicit_closures") == 0) {
922 return HandleClassesImplicitClosures(isolate, cls, js); 947 return HandleClassesImplicitClosures(isolate, cls, js);
923 } else if (strcmp(second, "dispatchers") == 0) { 948 } else if (strcmp(second, "dispatchers") == 0) {
924 return HandleClassesDispatchers(isolate, cls, js); 949 return HandleClassesDispatchers(isolate, cls, js);
925 } else { 950 } else {
926 PrintError(js, "Invalid sub collection %s", second); 951 PrintError(js, "Invalid sub collection %s", second);
927 return true; 952 return true;
928 } 953 }
929 } 954 }
930 UNREACHABLE(); 955 UNREACHABLE();
931 return true; 956 return true;
932 } 957 }
933 958
934 959
960 static bool HandleLibrariesEval(Isolate* isolate, const Library& lib,
961 JSONStream* js) {
962 if (js->num_arguments() > 3) {
963 PrintError(js, "Command too long");
964 return true;
965 }
966 const char* expr = js->LookupOption("expr");
967 if (expr == NULL) {
968 PrintError(js, "eval expects an 'expr' option\n",
969 js->num_arguments());
970 return true;
971 }
972 const String& expr_str = String::Handle(isolate, String::New(expr));
973 const Object& result = Object::Handle(lib.Evaluate(expr_str));
974 if (result.IsNull()) {
975 Object::null_instance().PrintToJSONStream(js, true);
976 } else {
977 result.PrintToJSONStream(js, true);
978 }
979 return true;
980 }
981
982
935 static bool HandleLibraries(Isolate* isolate, JSONStream* js) { 983 static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
936 // TODO(johnmccutchan): Support fields and functions on libraries. 984 // TODO(johnmccutchan): Support fields and functions on libraries.
937 REQUIRE_COLLECTION_ID("libraries"); 985 REQUIRE_COLLECTION_ID("libraries");
938 const GrowableObjectArray& libs = 986 const GrowableObjectArray& libs =
939 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 987 GrowableObjectArray::Handle(isolate->object_store()->libraries());
940 ASSERT(!libs.IsNull()); 988 ASSERT(!libs.IsNull());
941 intptr_t id = 0; 989 intptr_t id = 0;
942 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1), 990 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1),
943 id, js); 991 id, js);
944 Library& lib = Library::Handle(); 992 Library& lib = Library::Handle();
945 lib ^= libs.At(id); 993 lib ^= libs.At(id);
946 ASSERT(!lib.IsNull()); 994 ASSERT(!lib.IsNull());
947 lib.PrintToJSONStream(js, false); 995 if (js->num_arguments() == 2) {
996 lib.PrintToJSONStream(js, false);
997 return true;
998 } else if (js->num_arguments() >= 3) {
999 const char* second = js->GetArgument(2);
1000 if (strcmp(second, "eval") == 0) {
1001 return HandleLibrariesEval(isolate, lib, js);
1002 } else {
1003 PrintError(js, "Invalid sub collection %s", second);
1004 return true;
1005 }
1006 }
1007 UNREACHABLE();
948 return true; 1008 return true;
949 } 1009 }
950 1010
951 1011
952 static void PrintPseudoNull(JSONStream* js, 1012 static void PrintPseudoNull(JSONStream* js,
953 const char* id, 1013 const char* id,
954 const char* preview) { 1014 const char* preview) {
955 JSONObject jsobj(js); 1015 JSONObject jsobj(js);
956 jsobj.AddProperty("type", "Null"); 1016 jsobj.AddProperty("type", "Null");
957 jsobj.AddProperty("id", id); 1017 jsobj.AddProperty("id", id);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 const char* expr = js->LookupOption("expr"); 1166 const char* expr = js->LookupOption("expr");
1107 if (expr == NULL) { 1167 if (expr == NULL) {
1108 PrintError(js, "eval expects an 'expr' option\n", 1168 PrintError(js, "eval expects an 'expr' option\n",
1109 js->num_arguments()); 1169 js->num_arguments());
1110 return true; 1170 return true;
1111 } 1171 }
1112 const String& expr_str = String::Handle(isolate, String::New(expr)); 1172 const String& expr_str = String::Handle(isolate, String::New(expr));
1113 ASSERT(obj.IsInstance()); 1173 ASSERT(obj.IsInstance());
1114 const Instance& instance = Instance::Cast(obj); 1174 const Instance& instance = Instance::Cast(obj);
1115 const Object& result = Object::Handle(instance.Evaluate(expr_str)); 1175 const Object& result = Object::Handle(instance.Evaluate(expr_str));
1116 result.PrintToJSONStream(js, true); 1176 if (result.IsNull()) {
1177 Object::null_instance().PrintToJSONStream(js, true);
1178 } else {
1179 result.PrintToJSONStream(js, true);
1180 }
1117 return true; 1181 return true;
1118 } 1182 }
1119 1183
1120 PrintError(js, "unrecognized action '%s'\n", action); 1184 PrintError(js, "unrecognized action '%s'\n", action);
1121 return true; 1185 return true;
1122 } 1186 }
1123 1187
1124 1188
1125 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) { 1189 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) {
1126 JSONObject jsobj(js); 1190 JSONObject jsobj(js);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 while (current != NULL) { 1646 while (current != NULL) {
1583 if (strcmp(name, current->name()) == 0) { 1647 if (strcmp(name, current->name()) == 0) {
1584 return current; 1648 return current;
1585 } 1649 }
1586 current = current->next(); 1650 current = current->next();
1587 } 1651 }
1588 return NULL; 1652 return NULL;
1589 } 1653 }
1590 1654
1591 } // namespace dart 1655 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698