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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 10834096: Added Dart_FunctionEnclosingClassOrLibrary. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 10077)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -2784,6 +2784,32 @@
}
+DART_EXPORT Dart_Handle Dart_FunctionEnclosingClassOrLibrary(
+ Dart_Handle function) {
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ const Function& func = Api::UnwrapFunctionHandle(isolate, function);
+ if (func.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, function, Function);
+ }
+ const Class& owner = Class::Handle(func.owner());
+ ASSERT(!owner.IsNull());
+ if (owner.IsTopLevel()) {
+ // Top-level functions are implemented as members of a hidden class. We hide
+ // that class here and instead answer the library.
+#if defined(DEBUG)
+ const Library& lib = Library::Handle(owner.library());
+ if (lib.IsNull()) {
+ ASSERT(owner.IsDynamicClass() || owner.IsVoidClass());
+ }
+#endif
+ return Api::NewHandle(isolate, owner.library());
+ } else {
+ return Api::NewHandle(isolate, owner.raw());
+ }
+}
+
+
DART_EXPORT Dart_Handle Dart_FunctionIsAbstract(Dart_Handle function,
bool* is_abstract) {
Isolate* isolate = Isolate::Current();
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698