Chromium Code Reviews| 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); |
| + } |
|
Ivan Posva
2012/07/31 23:38:58
if (func.IsError()) {
return function;
}
rmacnak
2012/08/01 17:21:55
If I add that test with an ASSERT(false), that pat
turnidge
2012/08/01 17:59:42
Checking for an error handle isn't required here.
Ivan Posva
2012/08/01 20:43:55
Thanks for the clarification. The difference betwe
|
| + 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(); |