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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 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
« 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/log.h" 10 #include "vm/log.h"
(...skipping 21 matching lines...) Expand all
32 32
33 33
34 RawFunction* Resolver::ResolveDynamicForReceiverClass( 34 RawFunction* Resolver::ResolveDynamicForReceiverClass(
35 const Class& receiver_class, 35 const Class& receiver_class,
36 const String& function_name, 36 const String& function_name,
37 const ArgumentsDescriptor& args_desc, 37 const ArgumentsDescriptor& args_desc,
38 bool allow_add) { 38 bool allow_add) {
39 Thread* thread = Thread::Current(); 39 Thread* thread = Thread::Current();
40 Zone* zone = thread->zone(); 40 Zone* zone = thread->zone();
41 41
42 Function& function = Function::Handle(zone, 42 Function& function = Function::Handle(
43 zone,
43 ResolveDynamicAnyArgs(zone, receiver_class, function_name, allow_add)); 44 ResolveDynamicAnyArgs(zone, receiver_class, function_name, allow_add));
44 45
45 if (function.IsNull() || 46 if (function.IsNull() || !function.AreValidArguments(args_desc, NULL)) {
46 !function.AreValidArguments(args_desc, NULL)) {
47 // Return a null function to signal to the upper levels to dispatch to 47 // Return a null function to signal to the upper levels to dispatch to
48 // "noSuchMethod" function. 48 // "noSuchMethod" function.
49 if (FLAG_trace_resolving) { 49 if (FLAG_trace_resolving) {
50 String& error_message = 50 String& error_message =
51 String::Handle(zone, Symbols::New(thread, "function not found")); 51 String::Handle(zone, Symbols::New(thread, "function not found"));
52 if (!function.IsNull()) { 52 if (!function.IsNull()) {
53 // Obtain more detailed error message. 53 // Obtain more detailed error message.
54 function.AreValidArguments(args_desc, &error_message); 54 function.AreValidArguments(args_desc, &error_message);
55 } 55 }
56 THR_Print("ResolveDynamic error '%s': %s.\n", 56 THR_Print("ResolveDynamic error '%s': %s.\n", function_name.ToCString(),
57 function_name.ToCString(),
58 error_message.ToCString()); 57 error_message.ToCString());
59 } 58 }
60 return Function::null(); 59 return Function::null();
61 } 60 }
62 return function.raw(); 61 return function.raw();
63 } 62 }
64 63
65 64
66 RawFunction* Resolver::ResolveDynamicAnyArgs( 65 RawFunction* Resolver::ResolveDynamicAnyArgs(Zone* zone,
67 Zone* zone, 66 const Class& receiver_class,
68 const Class& receiver_class, 67 const String& function_name,
69 const String& function_name, 68 bool allow_add) {
70 bool allow_add) {
71 Class& cls = Class::Handle(zone, receiver_class.raw()); 69 Class& cls = Class::Handle(zone, receiver_class.raw());
72 if (FLAG_trace_resolving) { 70 if (FLAG_trace_resolving) {
73 THR_Print("ResolveDynamic '%s' for class %s\n", 71 THR_Print("ResolveDynamic '%s' for class %s\n", function_name.ToCString(),
74 function_name.ToCString(),
75 String::Handle(zone, cls.Name()).ToCString()); 72 String::Handle(zone, cls.Name()).ToCString());
76 } 73 }
77 74
78 const bool is_getter = Field::IsGetterName(function_name); 75 const bool is_getter = Field::IsGetterName(function_name);
79 String& field_name = String::Handle(zone); 76 String& field_name = String::Handle(zone);
80 if (is_getter) { 77 if (is_getter) {
81 field_name ^= Field::NameFromGetter(function_name); 78 field_name ^= Field::NameFromGetter(function_name);
82 79
83 if (field_name.CharAt(0) == '#') { 80 if (field_name.CharAt(0) == '#') {
84 // Resolving a getter "get:#..." is a request to closurize an instance 81 // Resolving a getter "get:#..." is a request to closurize an instance
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 Function& function = Function::Handle(); 152 Function& function = Function::Handle();
156 if (class_name.IsNull() || (class_name.Length() == 0)) { 153 if (class_name.IsNull() || (class_name.Length() == 0)) {
157 // Check if we are referring to a top level function. 154 // Check if we are referring to a top level function.
158 const Object& object = Object::Handle(library.ResolveName(function_name)); 155 const Object& object = Object::Handle(library.ResolveName(function_name));
159 if (!object.IsNull() && object.IsFunction()) { 156 if (!object.IsNull() && object.IsFunction()) {
160 function ^= object.raw(); 157 function ^= object.raw();
161 if (!function.AreValidArguments(num_arguments, argument_names, NULL)) { 158 if (!function.AreValidArguments(num_arguments, argument_names, NULL)) {
162 if (FLAG_trace_resolving) { 159 if (FLAG_trace_resolving) {
163 String& error_message = String::Handle(); 160 String& error_message = String::Handle();
164 // Obtain more detailed error message. 161 // Obtain more detailed error message.
165 function.AreValidArguments(num_arguments, 162 function.AreValidArguments(num_arguments, argument_names,
166 argument_names,
167 &error_message); 163 &error_message);
168 THR_Print("ResolveStatic error '%s': %s.\n", 164 THR_Print("ResolveStatic error '%s': %s.\n",
169 function_name.ToCString(), 165 function_name.ToCString(), error_message.ToCString());
170 error_message.ToCString());
171 } 166 }
172 function = Function::null(); 167 function = Function::null();
173 } 168 }
174 } else { 169 } else {
175 if (FLAG_trace_resolving) { 170 if (FLAG_trace_resolving) {
176 THR_Print("ResolveStatic error: function '%s' not found.\n", 171 THR_Print("ResolveStatic error: function '%s' not found.\n",
177 function_name.ToCString()); 172 function_name.ToCString());
178 } 173 }
179 } 174 }
180 } else { 175 } else {
181 // Lookup class_name in the library's class dictionary to get at 176 // Lookup class_name in the library's class dictionary to get at
182 // the dart class object. If class_name is not found in the dictionary 177 // the dart class object. If class_name is not found in the dictionary
183 // ResolveStatic will return a NULL function object. 178 // ResolveStatic will return a NULL function object.
184 const Class& cls = Class::Handle(library.LookupClass(class_name)); 179 const Class& cls = Class::Handle(library.LookupClass(class_name));
185 if (!cls.IsNull()) { 180 if (!cls.IsNull()) {
186 function = ResolveStatic(cls, 181 function =
187 function_name, 182 ResolveStatic(cls, function_name, num_arguments, argument_names);
188 num_arguments,
189 argument_names);
190 } 183 }
191 if (FLAG_trace_resolving && function.IsNull()) { 184 if (FLAG_trace_resolving && function.IsNull()) {
192 THR_Print("ResolveStatic error: function '%s.%s' not found.\n", 185 THR_Print("ResolveStatic error: function '%s.%s' not found.\n",
193 class_name.ToCString(), 186 class_name.ToCString(), function_name.ToCString());
194 function_name.ToCString());
195 } 187 }
196 } 188 }
197 return function.raw(); 189 return function.raw();
198 } 190 }
199 191
200 192
201 RawFunction* Resolver::ResolveStatic(const Class& cls, 193 RawFunction* Resolver::ResolveStatic(const Class& cls,
202 const String& function_name, 194 const String& function_name,
203 intptr_t num_arguments, 195 intptr_t num_arguments,
204 const Array& argument_names) { 196 const Array& argument_names) {
205 ASSERT(!cls.IsNull()); 197 ASSERT(!cls.IsNull());
206 if (FLAG_trace_resolving) { 198 if (FLAG_trace_resolving) {
207 THR_Print("ResolveStatic '%s'\n", function_name.ToCString()); 199 THR_Print("ResolveStatic '%s'\n", function_name.ToCString());
208 } 200 }
209 const Function& function = 201 const Function& function =
210 Function::Handle(cls.LookupStaticFunction(function_name)); 202 Function::Handle(cls.LookupStaticFunction(function_name));
211 if (function.IsNull() || 203 if (function.IsNull() ||
212 !function.AreValidArguments(num_arguments, argument_names, NULL)) { 204 !function.AreValidArguments(num_arguments, argument_names, NULL)) {
213 // Return a null function to signal to the upper levels to throw a 205 // Return a null function to signal to the upper levels to throw a
214 // resolution error or maybe throw the error right here. 206 // resolution error or maybe throw the error right here.
215 if (FLAG_trace_resolving) { 207 if (FLAG_trace_resolving) {
216 String& error_message = String::Handle(String::New("function not found")); 208 String& error_message = String::Handle(String::New("function not found"));
217 if (!function.IsNull()) { 209 if (!function.IsNull()) {
218 // Obtain more detailed error message. 210 // Obtain more detailed error message.
219 function.AreValidArguments(num_arguments, 211 function.AreValidArguments(num_arguments, argument_names,
220 argument_names,
221 &error_message); 212 &error_message);
222 } 213 }
223 THR_Print("ResolveStatic error '%s': %s.\n", 214 THR_Print("ResolveStatic error '%s': %s.\n", function_name.ToCString(),
224 function_name.ToCString(),
225 error_message.ToCString()); 215 error_message.ToCString());
226 } 216 }
227 return Function::null(); 217 return Function::null();
228 } 218 }
229 return function.raw(); 219 return function.raw();
230 } 220 }
231 221
232 222
233 RawFunction* Resolver::ResolveStaticAllowPrivate(const Class& cls, 223 RawFunction* Resolver::ResolveStaticAllowPrivate(const Class& cls,
234 const String& function_name, 224 const String& function_name,
235 intptr_t num_arguments, 225 intptr_t num_arguments,
236 const Array& argument_names) { 226 const Array& argument_names) {
237 ASSERT(!cls.IsNull()); 227 ASSERT(!cls.IsNull());
238 if (FLAG_trace_resolving) { 228 if (FLAG_trace_resolving) {
239 THR_Print("ResolveStaticAllowPrivate '%s'\n", function_name.ToCString()); 229 THR_Print("ResolveStaticAllowPrivate '%s'\n", function_name.ToCString());
240 } 230 }
241 const Function& function = 231 const Function& function =
242 Function::Handle(cls.LookupStaticFunctionAllowPrivate(function_name)); 232 Function::Handle(cls.LookupStaticFunctionAllowPrivate(function_name));
243 if (function.IsNull() || 233 if (function.IsNull() ||
244 !function.AreValidArguments(num_arguments, argument_names, NULL)) { 234 !function.AreValidArguments(num_arguments, argument_names, NULL)) {
245 // Return a null function to signal to the upper levels to throw a 235 // Return a null function to signal to the upper levels to throw a
246 // resolution error or maybe throw the error right here. 236 // resolution error or maybe throw the error right here.
247 if (FLAG_trace_resolving) { 237 if (FLAG_trace_resolving) {
248 String& error_message = String::Handle(String::New("function not found")); 238 String& error_message = String::Handle(String::New("function not found"));
249 if (!function.IsNull()) { 239 if (!function.IsNull()) {
250 // Obtain more detailed error message. 240 // Obtain more detailed error message.
251 function.AreValidArguments(num_arguments, 241 function.AreValidArguments(num_arguments, argument_names,
252 argument_names,
253 &error_message); 242 &error_message);
254 } 243 }
255 THR_Print("ResolveStaticAllowPrivate error '%s': %s.\n", 244 THR_Print("ResolveStaticAllowPrivate error '%s': %s.\n",
256 function_name.ToCString(), 245 function_name.ToCString(), error_message.ToCString());
257 error_message.ToCString());
258 } 246 }
259 return Function::null(); 247 return Function::null();
260 } 248 }
261 return function.raw(); 249 return function.raw();
262 } 250 }
263 251
264 } // namespace dart 252 } // 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