OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/resolver.h" | 5 #include "vm/resolver.h" |
6 | 6 |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 const bool is_getter = Field::IsGetterName(function_name); | 113 const bool is_getter = Field::IsGetterName(function_name); |
114 String& field_name = String::Handle(); | 114 String& field_name = String::Handle(); |
115 if (is_getter) { | 115 if (is_getter) { |
116 field_name ^= Field::NameFromGetter(function_name); | 116 field_name ^= Field::NameFromGetter(function_name); |
117 } | 117 } |
118 | 118 |
119 // Now look for an instance function whose name matches function_name | 119 // Now look for an instance function whose name matches function_name |
120 // in the class. | 120 // in the class. |
121 Function& function = Function::Handle(); | 121 Function& function = Function::Handle(); |
122 while (function.IsNull() && !cls.IsNull()) { | 122 while (!cls.IsNull()) { |
123 function ^= cls.LookupDynamicFunction(function_name); | 123 function ^= cls.LookupDynamicFunction(function_name); |
124 | 124 if (!function.IsNull()) { |
| 125 return function.raw(); |
| 126 } |
125 // Getter invocation might actually be a method extraction. | 127 // Getter invocation might actually be a method extraction. |
126 if (is_getter && function.IsNull()) { | 128 if (is_getter && function.IsNull()) { |
127 function ^= cls.LookupDynamicFunction(field_name); | 129 function ^= cls.LookupDynamicFunction(field_name); |
128 if (!function.IsNull()) { | 130 if (!function.IsNull()) { |
129 // We were looking for the getter but found a method with the same name. | 131 // We were looking for the getter but found a method with the same name. |
130 // Create a method extractor and return it. | 132 // Create a method extractor and return it. |
131 function ^= CreateMethodExtractor(function_name, function); | 133 function ^= CreateMethodExtractor(function_name, function); |
| 134 return function.raw(); |
132 } | 135 } |
133 } | 136 } |
134 | |
135 cls = cls.SuperClass(); | 137 cls = cls.SuperClass(); |
136 } | 138 } |
137 return function.raw(); | 139 return function.raw(); |
| 140 } |
| 141 |
| 142 |
| 143 // TODO(13355): Remove. |
| 144 RawFunction* Resolver::ResolveDynamicAnyArgsAllowPrivate( |
| 145 const Class& receiver_class, |
| 146 const String& function_name) { |
| 147 Class& cls = Class::Handle(receiver_class.raw()); |
| 148 if (FLAG_trace_resolving) { |
| 149 OS::Print("ResolveDynamic '%s' for class %s\n", |
| 150 function_name.ToCString(), |
| 151 String::Handle(cls.Name()).ToCString()); |
| 152 } |
| 153 |
| 154 const bool is_getter = Field::IsGetterName(function_name); |
| 155 String& field_name = String::Handle(); |
| 156 if (is_getter) { |
| 157 field_name ^= Field::NameFromGetter(function_name); |
| 158 } |
| 159 |
| 160 // Now look for an instance function whose name matches function_name |
| 161 // in the class. |
| 162 Function& function = Function::Handle(); |
| 163 while (!cls.IsNull()) { |
| 164 function ^= cls.LookupDynamicFunctionAllowPrivate(function_name); |
| 165 if (!function.IsNull()) { |
| 166 return function.raw(); |
| 167 } |
| 168 // Getter invocation might actually be a method extraction. |
| 169 if (is_getter && function.IsNull()) { |
| 170 function ^= cls.LookupDynamicFunction(field_name); |
| 171 if (!function.IsNull()) { |
| 172 // We were looking for the getter but found a method with the same name. |
| 173 // Create a method extractor and return it. |
| 174 function ^= CreateMethodExtractor(function_name, function); |
| 175 return function.raw(); |
| 176 } |
| 177 } |
| 178 cls = cls.SuperClass(); |
| 179 } |
| 180 return function.raw(); |
138 } | 181 } |
139 | 182 |
140 | 183 |
141 RawFunction* Resolver::ResolveStatic(const Library& library, | 184 RawFunction* Resolver::ResolveStatic(const Library& library, |
142 const String& class_name, | 185 const String& class_name, |
143 const String& function_name, | 186 const String& function_name, |
144 intptr_t num_arguments, | 187 intptr_t num_arguments, |
145 const Array& argument_names, | 188 const Array& argument_names, |
146 StaticResolveType resolve_type) { | 189 StaticResolveType resolve_type) { |
147 ASSERT(!library.IsNull()); | 190 ASSERT(!library.IsNull()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 OS::Print("ResolveStatic error '%s': %s.\n", | 285 OS::Print("ResolveStatic error '%s': %s.\n", |
243 function_name.ToCString(), | 286 function_name.ToCString(), |
244 error_message.ToCString()); | 287 error_message.ToCString()); |
245 } | 288 } |
246 return Function::null(); | 289 return Function::null(); |
247 } | 290 } |
248 return function.raw(); | 291 return function.raw(); |
249 } | 292 } |
250 | 293 |
251 } // namespace dart | 294 } // namespace dart |
OLD | NEW |