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

Side by Side Diff: runtime/vm/resolver.cc

Issue 50523018: Cleanup StaticResolveType, it does not seem to be used anywhere. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/resolver.h ('k') | runtime/vm/resolver_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RawFunction* Resolver::ResolveStatic(const Library& library, 143 RawFunction* Resolver::ResolveStatic(const Library& library,
144 const String& class_name, 144 const String& class_name,
145 const String& function_name, 145 const String& function_name,
146 intptr_t num_arguments, 146 intptr_t num_arguments,
147 const Array& argument_names, 147 const Array& argument_names) {
148 StaticResolveType resolve_type) {
149 ASSERT(!library.IsNull()); 148 ASSERT(!library.IsNull());
150 Function& function = Function::Handle(); 149 Function& function = Function::Handle();
151 if (class_name.IsNull() || (class_name.Length() == 0)) { 150 if (class_name.IsNull() || (class_name.Length() == 0)) {
152 // Check if we are referring to a top level function. 151 // Check if we are referring to a top level function.
153 const Object& object = Object::Handle(library.LookupObject(function_name)); 152 const Object& object = Object::Handle(library.LookupObject(function_name));
154 if (!object.IsNull() && object.IsFunction()) { 153 if (!object.IsNull() && object.IsFunction()) {
155 function ^= object.raw(); 154 function ^= object.raw();
156 if (!function.AreValidArguments(num_arguments, argument_names, NULL)) { 155 if (!function.AreValidArguments(num_arguments, argument_names, NULL)) {
157 if (FLAG_trace_resolving) { 156 if (FLAG_trace_resolving) {
158 String& error_message = String::Handle(); 157 String& error_message = String::Handle();
(...skipping 15 matching lines...) Expand all
174 } 173 }
175 } else { 174 } else {
176 // Lookup class_name in the library's class dictionary to get at 175 // Lookup class_name in the library's class dictionary to get at
177 // the dart class object. If class_name is not found in the dictionary 176 // the dart class object. If class_name is not found in the dictionary
178 // ResolveStatic will return a NULL function object. 177 // ResolveStatic will return a NULL function object.
179 const Class& cls = Class::Handle(library.LookupClass(class_name)); 178 const Class& cls = Class::Handle(library.LookupClass(class_name));
180 if (!cls.IsNull()) { 179 if (!cls.IsNull()) {
181 function = ResolveStatic(cls, 180 function = ResolveStatic(cls,
182 function_name, 181 function_name,
183 num_arguments, 182 num_arguments,
184 argument_names, 183 argument_names);
185 resolve_type);
186 } 184 }
187 if (FLAG_trace_resolving && function.IsNull()) { 185 if (FLAG_trace_resolving && function.IsNull()) {
188 OS::Print("ResolveStatic error: function '%s.%s' not found.\n", 186 OS::Print("ResolveStatic error: function '%s.%s' not found.\n",
189 class_name.ToCString(), 187 class_name.ToCString(),
190 function_name.ToCString()); 188 function_name.ToCString());
191 } 189 }
192 } 190 }
193 return function.raw(); 191 return function.raw();
194 } 192 }
195 193
196 194
197 RawFunction* Resolver::ResolveStaticByName(const Class& cls,
198 const String& function_name,
199 StaticResolveType resolve_type) {
200 ASSERT(!cls.IsNull());
201
202 if (FLAG_trace_resolving) {
203 OS::Print("ResolveStatic '%s'\n", function_name.ToCString());
204 }
205
206 // Now look for a static function whose name matches function_name
207 // in the class.
208 Function& function =
209 Function::Handle(cls.LookupStaticFunction(function_name));
210 if (resolve_type == kNotQualified) {
211 // Walk the hierarchy.
212 Class& super_class = Class::Handle(cls.SuperClass());
213 while (function.IsNull()) {
214 function = super_class.LookupStaticFunction(function_name);
215 super_class = super_class.SuperClass();
216 if (super_class.IsNull()) break;
217 }
218 }
219 return function.raw();
220 }
221
222
223
224 RawFunction* Resolver::ResolveStatic(const Class& cls, 195 RawFunction* Resolver::ResolveStatic(const Class& cls,
225 const String& function_name, 196 const String& function_name,
226 intptr_t num_arguments, 197 intptr_t num_arguments,
227 const Array& argument_names, 198 const Array& argument_names) {
228 StaticResolveType resolve_type) {
229 ASSERT(!cls.IsNull()); 199 ASSERT(!cls.IsNull());
230 const Function& function = Function::Handle( 200 if (FLAG_trace_resolving) {
231 ResolveStaticByName(cls, function_name, resolve_type)); 201 OS::Print("ResolveStatic '%s'\n", function_name.ToCString());
202 }
203 const Function& function =
204 Function::Handle(cls.LookupStaticFunction(function_name));
232 if (function.IsNull() || 205 if (function.IsNull() ||
233 !function.AreValidArguments(num_arguments, argument_names, NULL)) { 206 !function.AreValidArguments(num_arguments, argument_names, NULL)) {
234 // Return a null function to signal to the upper levels to throw a 207 // Return a null function to signal to the upper levels to throw a
235 // resolution error or maybe throw the error right here. 208 // resolution error or maybe throw the error right here.
236 if (FLAG_trace_resolving) { 209 if (FLAG_trace_resolving) {
237 String& error_message = String::Handle(String::New("function not found")); 210 String& error_message = String::Handle(String::New("function not found"));
238 if (!function.IsNull()) { 211 if (!function.IsNull()) {
239 // Obtain more detailed error message. 212 // Obtain more detailed error message.
240 function.AreValidArguments(num_arguments, 213 function.AreValidArguments(num_arguments,
241 argument_names, 214 argument_names,
242 &error_message); 215 &error_message);
243 } 216 }
244 OS::Print("ResolveStatic error '%s': %s.\n", 217 OS::Print("ResolveStatic error '%s': %s.\n",
245 function_name.ToCString(), 218 function_name.ToCString(),
246 error_message.ToCString()); 219 error_message.ToCString());
247 } 220 }
248 return Function::null(); 221 return Function::null();
249 } 222 }
250 return function.raw(); 223 return function.raw();
251 } 224 }
252 225
253 } // namespace dart 226 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/resolver.h ('k') | runtime/vm/resolver_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698