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

Unified Diff: runtime/vm/object.cc

Issue 10188004: Provide better ToCString description for closures (issue 2680). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « no previous file | tests/language/src/LocalFunction3Test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 6857)
+++ runtime/vm/object.cc (working copy)
@@ -8938,7 +8938,17 @@
const char* Closure::ToCString() const {
- return "Closure";
+ const Function& fun = Function::Handle(function());
+ const bool is_implicit_closure = fun.IsImplicitClosureFunction();
+ const char* fun_sig = String::Handle(fun.Signature()).ToCString();
+ const char* from = is_implicit_closure ? " from " : "";
+ const char* fun_desc = is_implicit_closure ? fun.ToCString() : "";
+ const char* format = "Closure: %s%s%s";
+ intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1;
+ char* chars = reinterpret_cast<char*>(
+ Isolate::Current()->current_zone()->Allocate(len));
+ OS::SNPrint(chars, len, format, fun_sig, from, fun_desc);
+ return chars;
}
« no previous file with comments | « no previous file | tests/language/src/LocalFunction3Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698