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

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: edits 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
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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 func ^= cls.ClosureFunctionFromIndex(id); 731 func ^= cls.ClosureFunctionFromIndex(id);
732 if (func.IsNull()) { 732 if (func.IsNull()) {
733 PrintError(js, "Closure function %" Pd " not found", id); 733 PrintError(js, "Closure function %" Pd " not found", id);
734 return true; 734 return true;
735 } 735 }
736 func.PrintToJSONStream(js, false); 736 func.PrintToJSONStream(js, false);
737 return true; 737 return true;
738 } 738 }
739 739
740 740
741 static bool HandleClassesEval(Isolate* isolate, const Class& cls,
742 JSONStream* js) {
743 if (js->num_arguments() > 3) {
744 PrintError(js, "Command too long");
745 return true;
746 }
747 const char* expr = js->LookupOption("expr");
748 if (expr == NULL) {
749 PrintError(js, "eval expects an 'expr' option\n",
750 js->num_arguments());
751 return true;
752 }
753 const String& expr_str = String::Handle(isolate, String::New(expr));
754 const Object& result = Object::Handle(cls.Evaluate(expr_str));
755 if (result.IsNull()) {
756 Object::null_instance().PrintToJSONStream(js, true);
757 } else {
758 result.PrintToJSONStream(js, true);
759 }
760 return true;
761 }
762
763
741 static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls, 764 static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls,
742 JSONStream* js) { 765 JSONStream* js) {
743 intptr_t id; 766 intptr_t id;
744 if (js->num_arguments() > 4) { 767 if (js->num_arguments() > 4) {
745 PrintError(js, "Command too long"); 768 PrintError(js, "Command too long");
746 return true; 769 return true;
747 } 770 }
748 if (!GetIntegerId(js->GetArgument(3), &id)) { 771 if (!GetIntegerId(js->GetArgument(3), &id)) {
749 PrintError(js, "Must specify collection object id: dispatchers/id"); 772 PrintError(js, "Must specify collection object id: dispatchers/id");
750 return true; 773 return true;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (!table->IsValidIndex(id)) { 864 if (!table->IsValidIndex(id)) {
842 PrintError(js, "%" Pd " is not a valid class id.", id);; 865 PrintError(js, "%" Pd " is not a valid class id.", id);;
843 return true; 866 return true;
844 } 867 }
845 Class& cls = Class::Handle(table->At(id)); 868 Class& cls = Class::Handle(table->At(id));
846 if (js->num_arguments() == 2) { 869 if (js->num_arguments() == 2) {
847 cls.PrintToJSONStream(js, false); 870 cls.PrintToJSONStream(js, false);
848 return true; 871 return true;
849 } else if (js->num_arguments() >= 3) { 872 } else if (js->num_arguments() >= 3) {
850 const char* second = js->GetArgument(2); 873 const char* second = js->GetArgument(2);
851 if (strcmp(second, "closures") == 0) { 874 if (strcmp(second, "eval") == 0) {
875 return HandleClassesEval(isolate, cls, js);
876 } else if (strcmp(second, "closures") == 0) {
852 return HandleClassesClosures(isolate, cls, js); 877 return HandleClassesClosures(isolate, cls, js);
853 } else if (strcmp(second, "fields") == 0) { 878 } else if (strcmp(second, "fields") == 0) {
854 return HandleClassesFields(isolate, cls, js); 879 return HandleClassesFields(isolate, cls, js);
855 } else if (strcmp(second, "functions") == 0) { 880 } else if (strcmp(second, "functions") == 0) {
856 return HandleClassesFunctions(isolate, cls, js); 881 return HandleClassesFunctions(isolate, cls, js);
857 } else if (strcmp(second, "implicit_closures") == 0) { 882 } else if (strcmp(second, "implicit_closures") == 0) {
858 return HandleClassesImplicitClosures(isolate, cls, js); 883 return HandleClassesImplicitClosures(isolate, cls, js);
859 } else if (strcmp(second, "dispatchers") == 0) { 884 } else if (strcmp(second, "dispatchers") == 0) {
860 return HandleClassesDispatchers(isolate, cls, js); 885 return HandleClassesDispatchers(isolate, cls, js);
861 } else { 886 } else {
862 PrintError(js, "Invalid sub collection %s", second); 887 PrintError(js, "Invalid sub collection %s", second);
863 return true; 888 return true;
864 } 889 }
865 } 890 }
866 UNREACHABLE(); 891 UNREACHABLE();
867 return true; 892 return true;
868 } 893 }
869 894
870 895
896 static bool HandleLibrariesEval(Isolate* isolate, const Library& lib,
897 JSONStream* js) {
898 if (js->num_arguments() > 3) {
899 PrintError(js, "Command too long");
900 return true;
901 }
902 const char* expr = js->LookupOption("expr");
903 if (expr == NULL) {
904 PrintError(js, "eval expects an 'expr' option\n",
905 js->num_arguments());
906 return true;
907 }
908 const String& expr_str = String::Handle(isolate, String::New(expr));
909 const Object& result = Object::Handle(lib.Evaluate(expr_str));
910 if (result.IsNull()) {
911 Object::null_instance().PrintToJSONStream(js, true);
912 } else {
913 result.PrintToJSONStream(js, true);
914 }
915 return true;
916 }
917
918
871 static bool HandleLibraries(Isolate* isolate, JSONStream* js) { 919 static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
872 // TODO(johnmccutchan): Support fields and functions on libraries. 920 // TODO(johnmccutchan): Support fields and functions on libraries.
873 REQUIRE_COLLECTION_ID("libraries"); 921 REQUIRE_COLLECTION_ID("libraries");
874 const GrowableObjectArray& libs = 922 const GrowableObjectArray& libs =
875 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 923 GrowableObjectArray::Handle(isolate->object_store()->libraries());
876 ASSERT(!libs.IsNull()); 924 ASSERT(!libs.IsNull());
877 intptr_t id = 0; 925 intptr_t id = 0;
878 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1), 926 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1),
879 id, js); 927 id, js);
880 Library& lib = Library::Handle(); 928 Library& lib = Library::Handle();
881 lib ^= libs.At(id); 929 lib ^= libs.At(id);
882 ASSERT(!lib.IsNull()); 930 ASSERT(!lib.IsNull());
883 lib.PrintToJSONStream(js, false); 931 if (js->num_arguments() == 2) {
932 lib.PrintToJSONStream(js, false);
933 return true;
934 } else if (js->num_arguments() >= 3) {
935 const char* second = js->GetArgument(2);
936 if (strcmp(second, "eval") == 0) {
937 return HandleLibrariesEval(isolate, lib, js);
938 } else {
939 PrintError(js, "Invalid sub collection %s", second);
940 return true;
941 }
942 }
943 UNREACHABLE();
884 return true; 944 return true;
885 } 945 }
886 946
887 947
888 static void PrintPseudoNull(JSONStream* js, 948 static void PrintPseudoNull(JSONStream* js,
889 const char* id, 949 const char* id,
890 const char* preview) { 950 const char* preview) {
891 JSONObject jsobj(js); 951 JSONObject jsobj(js);
892 jsobj.AddProperty("type", "Null"); 952 jsobj.AddProperty("type", "Null");
893 jsobj.AddProperty("id", id); 953 jsobj.AddProperty("id", id);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 const char* expr = js->LookupOption("expr"); 1102 const char* expr = js->LookupOption("expr");
1043 if (expr == NULL) { 1103 if (expr == NULL) {
1044 PrintError(js, "eval expects an 'expr' option\n", 1104 PrintError(js, "eval expects an 'expr' option\n",
1045 js->num_arguments()); 1105 js->num_arguments());
1046 return true; 1106 return true;
1047 } 1107 }
1048 const String& expr_str = String::Handle(isolate, String::New(expr)); 1108 const String& expr_str = String::Handle(isolate, String::New(expr));
1049 ASSERT(obj.IsInstance()); 1109 ASSERT(obj.IsInstance());
1050 const Instance& instance = Instance::Cast(obj); 1110 const Instance& instance = Instance::Cast(obj);
1051 const Object& result = Object::Handle(instance.Evaluate(expr_str)); 1111 const Object& result = Object::Handle(instance.Evaluate(expr_str));
1052 result.PrintToJSONStream(js, true); 1112 if (result.IsNull()) {
1113 Object::null_instance().PrintToJSONStream(js, true);
1114 } else {
1115 result.PrintToJSONStream(js, true);
1116 }
1053 return true; 1117 return true;
1054 } 1118 }
1055 1119
1056 PrintError(js, "unrecognized action '%s'\n", action); 1120 PrintError(js, "unrecognized action '%s'\n", action);
1057 return true; 1121 return true;
1058 } 1122 }
1059 1123
1060 1124
1061 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) { 1125 static bool HandleScriptsEnumerate(Isolate* isolate, JSONStream* js) {
1062 JSONObject jsobj(js); 1126 JSONObject jsobj(js);
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 while (current != NULL) { 1569 while (current != NULL) {
1506 if (strcmp(name, current->name()) == 0) { 1570 if (strcmp(name, current->name()) == 0) {
1507 return current; 1571 return current;
1508 } 1572 }
1509 current = current->next(); 1573 current = current->next();
1510 } 1574 }
1511 return NULL; 1575 return NULL;
1512 } 1576 }
1513 1577
1514 } // namespace dart 1578 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698