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

Unified Diff: runtime/vm/resolver.cc

Issue 23909002: Implement closurization of regular methods in ObjectMirror.getField in the VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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/vm/resolver.h ('k') | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/resolver.cc
diff --git a/runtime/vm/resolver.cc b/runtime/vm/resolver.cc
index 4021d7145243e8f8be5345bea24606b930fd6964..faad5dbd6a8053553245588cc1acd8d0a518df6d 100644
--- a/runtime/vm/resolver.cc
+++ b/runtime/vm/resolver.cc
@@ -138,6 +138,45 @@ RawFunction* Resolver::ResolveDynamicAnyArgs(
}
+// TODO(13355): Remove.
+RawFunction* Resolver::ResolveDynamicAnyArgsAllowPrivate(
+ const Class& receiver_class,
+ const String& function_name) {
+ Class& cls = Class::Handle(receiver_class.raw());
+ if (FLAG_trace_resolving) {
+ OS::Print("ResolveDynamic '%s' for class %s\n",
+ function_name.ToCString(),
+ String::Handle(cls.Name()).ToCString());
+ }
+
+ const bool is_getter = Field::IsGetterName(function_name);
+ String& field_name = String::Handle();
+ if (is_getter) {
+ field_name ^= Field::NameFromGetter(function_name);
+ }
+
+ // Now look for an instance function whose name matches function_name
+ // in the class.
+ Function& function = Function::Handle();
+ while (function.IsNull() && !cls.IsNull()) {
+ function ^= cls.LookupDynamicFunctionAllowPrivate(function_name);
+
+ // Getter invocation might actually be a method extraction.
+ if (is_getter && function.IsNull()) {
+ function ^= cls.LookupDynamicFunctionAllowPrivate(field_name);
+ if (!function.IsNull()) {
+ // We were looking for the getter but found a method with the same name.
+ // Create a method extractor and return it.
+ function ^= CreateMethodExtractor(function_name, function);
+ }
+ }
+
+ cls = cls.SuperClass();
+ }
+ return function.raw();
+}
+
+
RawFunction* Resolver::ResolveStatic(const Library& library,
const String& class_name,
const String& function_name,
« no previous file with comments | « runtime/vm/resolver.h ('k') | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698