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" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 Class& cls = Class::Handle(receiver_class.raw()); | 119 Class& cls = Class::Handle(receiver_class.raw()); |
120 if (FLAG_trace_resolving) { | 120 if (FLAG_trace_resolving) { |
121 OS::Print("ResolveDynamic '%s' for class %s\n", | 121 OS::Print("ResolveDynamic '%s' for class %s\n", |
122 function_name.ToCString(), | 122 function_name.ToCString(), |
123 String::Handle(cls.Name()).ToCString()); | 123 String::Handle(cls.Name()).ToCString()); |
124 } | 124 } |
125 | 125 |
126 const bool is_getter = Field::IsGetterName(function_name); | 126 const bool is_getter = Field::IsGetterName(function_name); |
127 String& field_name = String::Handle(); | 127 String& field_name = String::Handle(); |
128 if (is_getter) { | 128 if (is_getter) { |
129 field_name ^= Field::NameFromGetter(function_name); | 129 field_name |= Field::NameFromGetter(function_name); |
130 } | 130 } |
131 | 131 |
132 // Now look for an instance function whose name matches function_name | 132 // Now look for an instance function whose name matches function_name |
133 // in the class. | 133 // in the class. |
134 Function& function = Function::Handle(); | 134 Function& function = Function::Handle(); |
135 while (function.IsNull() && !cls.IsNull()) { | 135 while (function.IsNull() && !cls.IsNull()) { |
136 function ^= cls.LookupDynamicFunction(function_name); | 136 function |= cls.LookupDynamicFunction(function_name); |
137 | 137 |
138 // Getter invocation might actually be a method extraction. | 138 // Getter invocation might actually be a method extraction. |
139 if (is_getter && function.IsNull()) { | 139 if (is_getter && function.IsNull()) { |
140 function ^= cls.LookupDynamicFunction(field_name); | 140 function |= cls.LookupDynamicFunction(field_name); |
141 if (!function.IsNull()) { | 141 if (!function.IsNull()) { |
142 // We were looking for the getter but found a method with the same name. | 142 // We were looking for the getter but found a method with the same name. |
143 // Create a method extractor and return it. | 143 // Create a method extractor and return it. |
144 function ^= CreateMethodExtractor(function_name, function); | 144 function |= CreateMethodExtractor(function_name, function); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 cls = cls.SuperClass(); | 148 cls = cls.SuperClass(); |
149 } | 149 } |
150 return function.raw(); | 150 return function.raw(); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 RawFunction* Resolver::ResolveStatic(const Library& library, | 154 RawFunction* Resolver::ResolveStatic(const Library& library, |
155 const String& class_name, | 155 const String& class_name, |
156 const String& function_name, | 156 const String& function_name, |
157 int num_arguments, | 157 int num_arguments, |
158 const Array& argument_names, | 158 const Array& argument_names, |
159 StaticResolveType resolve_type) { | 159 StaticResolveType resolve_type) { |
160 ASSERT(!library.IsNull()); | 160 ASSERT(!library.IsNull()); |
161 Function& function = Function::Handle(); | 161 Function& function = Function::Handle(); |
162 if (class_name.IsNull() || (class_name.Length() == 0)) { | 162 if (class_name.IsNull() || (class_name.Length() == 0)) { |
163 // Check if we are referring to a top level function. | 163 // Check if we are referring to a top level function. |
164 const Object& object = Object::Handle(library.LookupObject(function_name)); | 164 const Object& object = Object::Handle(library.LookupObject(function_name)); |
165 if (!object.IsNull() && object.IsFunction()) { | 165 if (!object.IsNull() && object.IsFunction()) { |
166 function ^= object.raw(); | 166 function |= object.raw(); |
167 if (!function.AreValidArguments(num_arguments, argument_names, NULL)) { | 167 if (!function.AreValidArguments(num_arguments, argument_names, NULL)) { |
168 if (FLAG_trace_resolving) { | 168 if (FLAG_trace_resolving) { |
169 String& error_message = String::Handle(); | 169 String& error_message = String::Handle(); |
170 // Obtain more detailed error message. | 170 // Obtain more detailed error message. |
171 function.AreValidArguments(num_arguments, | 171 function.AreValidArguments(num_arguments, |
172 argument_names, | 172 argument_names, |
173 &error_message); | 173 &error_message); |
174 OS::Print("ResolveStatic error '%s': %s.\n", | 174 OS::Print("ResolveStatic error '%s': %s.\n", |
175 function_name.ToCString(), | 175 function_name.ToCString(), |
176 error_message.ToCString()); | 176 error_message.ToCString()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 OS::Print("ResolveStatic error '%s': %s.\n", | 250 OS::Print("ResolveStatic error '%s': %s.\n", |
251 function_name.ToCString(), | 251 function_name.ToCString(), |
252 error_message.ToCString()); | 252 error_message.ToCString()); |
253 } | 253 } |
254 return Function::null(); | 254 return Function::null(); |
255 } | 255 } |
256 return function.raw(); | 256 return function.raw(); |
257 } | 257 } |
258 | 258 |
259 } // namespace dart | 259 } // namespace dart |
OLD | NEW |