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

Unified Diff: runtime/vm/resolver.cc

Issue 23441073: 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: address comments 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..17028e1fc21f8ff4e8388322821db24dc2941e54 100644
--- a/runtime/vm/resolver.cc
+++ b/runtime/vm/resolver.cc
@@ -119,9 +119,11 @@ RawFunction* Resolver::ResolveDynamicAnyArgs(
// Now look for an instance function whose name matches function_name
// in the class.
Function& function = Function::Handle();
- while (function.IsNull() && !cls.IsNull()) {
+ while (!cls.IsNull()) {
function ^= cls.LookupDynamicFunction(function_name);
-
+ if (!function.IsNull()) {
+ return function.raw();
+ }
// Getter invocation might actually be a method extraction.
if (is_getter && function.IsNull()) {
function ^= cls.LookupDynamicFunction(field_name);
@@ -129,9 +131,50 @@ RawFunction* Resolver::ResolveDynamicAnyArgs(
// 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);
+ return function.raw();
}
}
+ cls = cls.SuperClass();
+ }
+ return function.raw();
+}
+
+
+// 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 (!cls.IsNull()) {
+ function ^= cls.LookupDynamicFunctionAllowPrivate(function_name);
+ if (!function.IsNull()) {
+ return function.raw();
+ }
+ // Getter invocation might actually be a method extraction.
+ if (is_getter && function.IsNull()) {
+ function ^= cls.LookupDynamicFunction(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);
+ return function.raw();
+ }
+ }
cls = cls.SuperClass();
}
return function.raw();
« 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