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

Unified Diff: runtime/vm/debugger_api_impl.cc

Issue 65383007: Add Dart_GetClosureInfo (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 | « runtime/include/dart_debugger_api.h ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger_api_impl.cc
===================================================================
--- runtime/vm/debugger_api_impl.cc (revision 30160)
+++ runtime/vm/debugger_api_impl.cc (working copy)
@@ -599,6 +599,44 @@
}
+DART_EXPORT Dart_Handle Dart_GetClosureInfo(
+ Dart_Handle closure,
+ Dart_Handle* name,
+ Dart_CodeLocation* location) {
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ UNWRAP_AND_CHECK_PARAM(Instance, instance, closure);
+ CHECK_NOT_NULL(location);
+
+ if (!instance.IsClosure()) {
+ return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC);
+ }
+ const Function& func = Function::Handle(Closure::function(instance));
+ ASSERT(!func.IsNull());
+ if (name != NULL) {
+ *name = Api::NewHandle(isolate, func.QualifiedUserVisibleName());
+ }
+ if (location != NULL) {
+ if (func.token_pos() >= 0) {
+ const Class& cls = Class::Handle(func.origin());
+ ASSERT(!cls.IsNull());
+ const Library& lib = Library::Handle(isolate, cls.library());
+ ASSERT(!lib.IsNull());
+ const Script& script = Script::Handle(cls.script());
+ ASSERT(!script.IsNull());
+ location->script_url = Api::NewHandle(isolate, script.url());
+ location->library_id = lib.index();
+ location->token_pos = func.token_pos();
+ } else {
+ location->script_url = Api::NewHandle(isolate, String::null());
+ location->library_id = -1;
+ location->token_pos = -1;
+ }
+ }
+ return Api::True();
+}
+
+
DART_EXPORT Dart_Handle Dart_GetClassInfo(
intptr_t cls_id,
Dart_Handle* class_name,
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698