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

Unified Diff: runtime/bin/dbg_message.cc

Issue 61153006: Add closure object type to debugger wire protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | « no previous file | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dbg_message.cc
===================================================================
--- runtime/bin/dbg_message.cc (revision 30163)
+++ runtime/bin/dbg_message.cc (working copy)
@@ -227,29 +227,47 @@
static void FormatValue(dart::TextBuffer* buf, Dart_Handle object) {
+ bool print_text_field = true;
if (Dart_IsNumber(object)) {
- buf->Printf("\"kind\":\"number\",");
+ buf->Printf("\"kind\":\"number\"");
} else if (Dart_IsString(object)) {
- buf->Printf("\"kind\":\"string\",");
+ buf->Printf("\"kind\":\"string\"");
} else if (Dart_IsBoolean(object)) {
- buf->Printf("\"kind\":\"boolean\",");
+ buf->Printf("\"kind\":\"boolean\"");
} else if (Dart_IsList(object)) {
intptr_t len = 0;
Dart_Handle res = Dart_ListLength(object, &len);
ASSERT_NOT_ERROR(res);
- buf->Printf("\"kind\":\"list\",\"length\":%" Pd ",", len);
+ buf->Printf("\"kind\":\"list\",\"length\":%" Pd "", len);
+ } else if (Dart_IsClosure(object)) {
+ Dart_Handle name, signature;
+ Dart_CodeLocation location;
+ Dart_Handle res = Dart_GetClosureInfo(object, &name, &signature, &location);
+ ASSERT_NOT_ERROR(res);
+ buf->Printf("\"kind\":\"function\",\"name\":\"%s\"", GetStringChars(name));
+ buf->Printf(",\"signature\":\"%s\"", GetStringChars(signature));
+ if (!Dart_IsNull(location.script_url)) {
+ ASSERT(Dart_IsString(location.script_url));
+ buf->Printf(",\"location\": { \"url\":");
+ FormatEncodedString(buf, location.script_url);
+ buf->Printf(",\"libraryId\":%d,", location.library_id);
+ buf->Printf("\"tokenOffset\":%d}", location.token_pos);
+ }
+ print_text_field = false;
} else {
- buf->Printf("\"kind\":\"object\",");
+ buf->Printf("\"kind\":\"object\"");
intptr_t class_id = 0;
Dart_Handle res = Dart_GetObjClassId(object, &class_id);
if (!Dart_IsError(res)) {
- buf->Printf("\"classId\":%" Pd ",", class_id);
+ buf->Printf(",\"classId\":%" Pd ",", class_id);
}
}
- buf->Printf("\"text\":\"");
- const intptr_t max_chars = 250;
- FormatTextualValue(buf, object, max_chars, true);
- buf->Printf("\"");
+ if (print_text_field) {
+ buf->Printf(",\"text\":\"");
+ const intptr_t max_chars = 250;
+ FormatTextualValue(buf, object, max_chars, true);
+ buf->Printf("\"");
+ }
}
« no previous file with comments | « no previous file | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698