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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 function ^= CreateMethodExtractor(function_name, function); | 133 function ^= CreateMethodExtractor(function_name, function); |
134 return function.raw(); | 134 return function.raw(); |
135 } | 135 } |
136 } | 136 } |
137 cls = cls.SuperClass(); | 137 cls = cls.SuperClass(); |
138 } | 138 } |
139 return function.raw(); | 139 return function.raw(); |
140 } | 140 } |
141 | 141 |
142 | 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(); | |
181 } | |
182 | |
183 | |
184 RawFunction* Resolver::ResolveStatic(const Library& library, | 143 RawFunction* Resolver::ResolveStatic(const Library& library, |
185 const String& class_name, | 144 const String& class_name, |
186 const String& function_name, | 145 const String& function_name, |
187 intptr_t num_arguments, | 146 intptr_t num_arguments, |
188 const Array& argument_names, | 147 const Array& argument_names, |
189 StaticResolveType resolve_type) { | 148 StaticResolveType resolve_type) { |
190 ASSERT(!library.IsNull()); | 149 ASSERT(!library.IsNull()); |
191 Function& function = Function::Handle(); | 150 Function& function = Function::Handle(); |
192 if (class_name.IsNull() || (class_name.Length() == 0)) { | 151 if (class_name.IsNull() || (class_name.Length() == 0)) { |
193 // Check if we are referring to a top level function. | 152 // Check if we are referring to a top level function. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 OS::Print("ResolveStatic error '%s': %s.\n", | 244 OS::Print("ResolveStatic error '%s': %s.\n", |
286 function_name.ToCString(), | 245 function_name.ToCString(), |
287 error_message.ToCString()); | 246 error_message.ToCString()); |
288 } | 247 } |
289 return Function::null(); | 248 return Function::null(); |
290 } | 249 } |
291 return function.raw(); | 250 return function.raw(); |
292 } | 251 } |
293 | 252 |
294 } // namespace dart | 253 } // namespace dart |
OLD | NEW |