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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 function ^= CreateMethodExtractor(function_name, function); | 131 function ^= CreateMethodExtractor(function_name, function); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 cls = cls.SuperClass(); | 135 cls = cls.SuperClass(); |
136 } | 136 } |
137 return function.raw(); | 137 return function.raw(); |
138 } | 138 } |
139 | 139 |
140 | 140 |
| 141 // TODO(13355): Remove. |
| 142 RawFunction* Resolver::ResolveDynamicAnyArgsAllowPrivate( |
| 143 const Class& receiver_class, |
| 144 const String& function_name) { |
| 145 Class& cls = Class::Handle(receiver_class.raw()); |
| 146 if (FLAG_trace_resolving) { |
| 147 OS::Print("ResolveDynamic '%s' for class %s\n", |
| 148 function_name.ToCString(), |
| 149 String::Handle(cls.Name()).ToCString()); |
| 150 } |
| 151 |
| 152 const bool is_getter = Field::IsGetterName(function_name); |
| 153 String& field_name = String::Handle(); |
| 154 if (is_getter) { |
| 155 field_name ^= Field::NameFromGetter(function_name); |
| 156 } |
| 157 |
| 158 // Now look for an instance function whose name matches function_name |
| 159 // in the class. |
| 160 Function& function = Function::Handle(); |
| 161 while (function.IsNull() && !cls.IsNull()) { |
| 162 function ^= cls.LookupDynamicFunctionAllowPrivate(function_name); |
| 163 |
| 164 // Getter invocation might actually be a method extraction. |
| 165 if (is_getter && function.IsNull()) { |
| 166 function ^= cls.LookupDynamicFunctionAllowPrivate(field_name); |
| 167 if (!function.IsNull()) { |
| 168 // We were looking for the getter but found a method with the same name. |
| 169 // Create a method extractor and return it. |
| 170 function ^= CreateMethodExtractor(function_name, function); |
| 171 } |
| 172 } |
| 173 |
| 174 cls = cls.SuperClass(); |
| 175 } |
| 176 return function.raw(); |
| 177 } |
| 178 |
| 179 |
141 RawFunction* Resolver::ResolveStatic(const Library& library, | 180 RawFunction* Resolver::ResolveStatic(const Library& library, |
142 const String& class_name, | 181 const String& class_name, |
143 const String& function_name, | 182 const String& function_name, |
144 intptr_t num_arguments, | 183 intptr_t num_arguments, |
145 const Array& argument_names, | 184 const Array& argument_names, |
146 StaticResolveType resolve_type) { | 185 StaticResolveType resolve_type) { |
147 ASSERT(!library.IsNull()); | 186 ASSERT(!library.IsNull()); |
148 Function& function = Function::Handle(); | 187 Function& function = Function::Handle(); |
149 if (class_name.IsNull() || (class_name.Length() == 0)) { | 188 if (class_name.IsNull() || (class_name.Length() == 0)) { |
150 // Check if we are referring to a top level function. | 189 // Check if we are referring to a top level function. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 OS::Print("ResolveStatic error '%s': %s.\n", | 281 OS::Print("ResolveStatic error '%s': %s.\n", |
243 function_name.ToCString(), | 282 function_name.ToCString(), |
244 error_message.ToCString()); | 283 error_message.ToCString()); |
245 } | 284 } |
246 return Function::null(); | 285 return Function::null(); |
247 } | 286 } |
248 return function.raw(); | 287 return function.raw(); |
249 } | 288 } |
250 | 289 |
251 } // namespace dart | 290 } // namespace dart |
OLD | NEW |