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/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 DEFINE_FLAG(bool, trace_resolving, false, "Trace resolving."); | 14 DEFINE_FLAG(bool, trace_resolving, false, "Trace resolving."); |
15 | 15 |
16 | 16 |
17 // The actual names of named arguments are not checked by the dynamic resolver, | 17 // The actual names of named arguments are not checked by the dynamic resolver, |
18 // but by the method entry code. It is important that the dynamic resolver | 18 // but by the method entry code. It is important that the dynamic resolver |
19 // checks that no named arguments are passed to a method that does not accept | 19 // checks that no named arguments are passed to a method that does not accept |
20 // them, since the entry code of such a method does not check for named | 20 // them, since the entry code of such a method does not check for named |
21 // arguments. The dynamic resolver actually checks that a valid number of named | 21 // arguments. The dynamic resolver actually checks that a valid number of named |
22 // arguments is passed in. | 22 // arguments is passed in. |
23 RawFunction* Resolver::ResolveDynamic(const Instance& receiver, | 23 RawFunction* Resolver::ResolveDynamic(const Instance& receiver, |
24 const String& function_name, | 24 const String& function_name, |
25 int num_arguments, | 25 int num_arguments, |
26 int num_named_arguments) { | 26 int num_named_arguments) { |
27 // Figure out type of receiver first. | 27 // Figure out type of receiver first. |
28 Class& cls = Class::Handle(); | 28 Class& cls = Class::Handle(); |
29 if (receiver.IsNull()) { | 29 cls = receiver.clazz(); |
30 // For method lookup treat null object as instance of Object. | 30 // For lookups treat null as an instance of class Object. |
31 // TODO(srdjan): Remove special case once Dart's NullClass is implemented. | 31 if (cls.IsNullClass()) { |
32 cls = Isolate::Current()->object_store()->object_class(); | 32 cls = Isolate::Current()->object_store()->object_class(); |
33 } else { | |
34 cls = receiver.clazz(); | |
35 } | 33 } |
36 ASSERT(!cls.IsNull()); | 34 ASSERT(!cls.IsNull()); |
37 | 35 |
38 return ResolveDynamicForReceiverClass( | 36 return ResolveDynamicForReceiverClass( |
39 cls, function_name, num_arguments, num_named_arguments); | 37 cls, function_name, num_arguments, num_named_arguments); |
40 } | 38 } |
41 | 39 |
42 | 40 |
43 RawFunction* Resolver::ResolveDynamicForReceiverClass( | 41 RawFunction* Resolver::ResolveDynamicForReceiverClass( |
44 const Class& receiver_class, | 42 const Class& receiver_class, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 OS::Print("ResolveStatic error '%s': %s.\n", | 192 OS::Print("ResolveStatic error '%s': %s.\n", |
195 function_name.ToCString(), | 193 function_name.ToCString(), |
196 error_message.ToCString()); | 194 error_message.ToCString()); |
197 } | 195 } |
198 return Function::null(); | 196 return Function::null(); |
199 } | 197 } |
200 return function.raw(); | 198 return function.raw(); |
201 } | 199 } |
202 | 200 |
203 } // namespace dart | 201 } // namespace dart |
OLD | NEW |