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

Unified Diff: runtime/vm/service.cc

Issue 211283004: Support Types in instance-ref/instance-view (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 2b3be6ab67064a625248b711dc4dfd21e7cfed65..384ffa5fc52f1e7067d937cc6fac71e78a1ff19f 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -798,6 +798,54 @@ static bool GetCodeId(const char* s, int64_t* timestamp, uword* address) {
}
+static bool HandleInstanceCommands(Isolate* isolate,
+ const Object& obj,
+ JSONStream* js,
+ intptr_t arg_pos) {
+ ASSERT(js->num_arguments() > arg_pos);
+ const char* action = js->GetArgument(arg_pos);
+ if (strcmp(action, "eval") == 0) {
+ if (js->num_arguments() > (arg_pos + 1)) {
+ PrintError(js, "expected at most %" Pd " arguments but found %" Pd "\n",
+ arg_pos + 1,
+ js->num_arguments());
+ return true;
+ }
+ if (obj.IsNull()) {
+ PrintErrorWithKind(js, "EvalCollected",
+ "attempt to evaluate against collected object\n",
+ js->num_arguments());
+ return true;
+ }
+ if (obj.raw() == Object::sentinel().raw()) {
+ PrintErrorWithKind(js, "EvalExpired",
+ "attempt to evaluate against expired object\n",
+ js->num_arguments());
+ return true;
+ }
+ const char* expr = js->LookupOption("expr");
+ if (expr == NULL) {
+ PrintError(js, "eval expects an 'expr' option\n",
+ js->num_arguments());
+ return true;
+ }
+ const String& expr_str = String::Handle(isolate, String::New(expr));
+ ASSERT(obj.IsInstance());
+ const Instance& instance = Instance::Cast(obj);
+ const Object& result = Object::Handle(instance.Evaluate(expr_str));
+ if (result.IsNull()) {
+ Object::null_instance().PrintToJSONStream(js, true);
+ } else {
+ result.PrintToJSONStream(js, true);
+ }
+ return true;
+ }
+
+ PrintError(js, "unrecognized action '%s'\n", action);
+ return true;
+}
+
+
static bool HandleClassesClosures(Isolate* isolate, const Class& cls,
JSONStream* js) {
intptr_t id;
@@ -944,11 +992,8 @@ static bool HandleClassesTypes(Isolate* isolate, const Class& cls,
}
return true;
}
+ ASSERT(js->num_arguments() >= 4);
intptr_t id;
- if (js->num_arguments() > 4) {
- PrintError(js, "Command too long");
- return true;
- }
if (!GetIntegerId(js->GetArgument(3), &id)) {
PrintError(js, "Must specify collection object id: types/id");
return true;
@@ -959,8 +1004,11 @@ static bool HandleClassesTypes(Isolate* isolate, const Class& cls,
PrintError(js, "Canonical type %" Pd " not found", id);
return true;
}
- type.PrintToJSONStream(js, false);
- return true;
+ if (js->num_arguments() == 4) {
+ type.PrintToJSONStream(js, false);
+ return true;
+ }
+ return HandleInstanceCommands(isolate, type, js, 4);
}
@@ -1181,8 +1229,6 @@ static bool HandleObjects(Isolate* isolate, JSONStream* js) {
PrintError(js, "unrecognized object id '%s'", arg);
return true;
}
-
- // Now what should we do with the object?
if (js->num_arguments() == 2) {
// Print.
if (obj.IsNull()) {
@@ -1197,47 +1243,7 @@ static bool HandleObjects(Isolate* isolate, JSONStream* js) {
obj.PrintToJSONStream(js, false);
return true;
}
- ASSERT(js->num_arguments() > 2);
-
- const char* action = js->GetArgument(2);
- if (strcmp(action, "eval") == 0) {
- if (js->num_arguments() > 3) {
- PrintError(js, "expected at most 3 arguments but found %" Pd "\n",
- js->num_arguments());
- return true;
- }
- if (obj.IsNull()) {
- PrintErrorWithKind(js, "EvalCollected",
- "attempt to evaluate against collected object\n",
- js->num_arguments());
- return true;
- }
- if (obj.raw() == Object::sentinel().raw()) {
- PrintErrorWithKind(js, "EvalExpired",
- "attempt to evaluate against expired object\n",
- js->num_arguments());
- return true;
- }
- const char* expr = js->LookupOption("expr");
- if (expr == NULL) {
- PrintError(js, "eval expects an 'expr' option\n",
- js->num_arguments());
- return true;
- }
- const String& expr_str = String::Handle(isolate, String::New(expr));
- ASSERT(obj.IsInstance());
- const Instance& instance = Instance::Cast(obj);
- const Object& result = Object::Handle(instance.Evaluate(expr_str));
- if (result.IsNull()) {
- Object::null_instance().PrintToJSONStream(js, true);
- } else {
- result.PrintToJSONStream(js, true);
- }
- return true;
- }
-
- PrintError(js, "unrecognized action '%s'\n", action);
- return true;
+ return HandleInstanceCommands(isolate, obj, js, 2);
}
« 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