Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index db19ab39c99ae3623a34b8d0ea12fb4bc7aa0b99..728e2ffe6446a8833d056194b9aef8d727408440 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -12063,6 +12063,32 @@ RawFunction* Library::GetFunction(const GrowableArray<Library*>& libs, |
} |
+RawObject* Library::GetFunctionClosure(const String& name) const { |
+ Thread* thread = Thread::Current(); |
+ Zone* zone = thread->zone(); |
+ Function& func = Function::Handle(zone, LookupFunctionAllowPrivate(name)); |
+ if (func.IsNull()) { |
+ // Check whether the function is reexported into the library. |
+ const Object& obj = Object::Handle(zone, LookupReExport(name)); |
+ if (obj.IsFunction()) { |
+ func ^= obj.raw(); |
+ } else { |
+ // Check if there is a getter of 'name', in which case invoke it |
+ // and return the result. |
+ const String& getter_name = String::Handle(zone, Field::GetterName(name)); |
+ func = LookupFunctionAllowPrivate(getter_name); |
+ if (func.IsNull()) { |
+ return Closure::null(); |
+ } |
+ // Invoke the getter and return the result. |
+ return DartEntry::InvokeFunction(func, Object::empty_array()); |
+ } |
+ } |
+ func = func.ImplicitClosureFunction(); |
+ return func.ImplicitStaticClosure(); |
+} |
+ |
+ |
#if defined(DART_NO_SNAPSHOT) && !defined(PRODUCT) |
void Library::CheckFunctionFingerprints() { |
GrowableArray<Library*> all_libs; |