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

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

Issue 23484020: Update handling of ambiguous name references (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months 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/intrinsifier_x64.cc ('k') | runtime/vm/object.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "include/dart_mirrors_api.h" 5 #include "include/dart_mirrors_api.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Case 4. Lookup the function with a . appended to find the 156 // Case 4. Lookup the function with a . appended to find the
157 // unnamed constructor. 157 // unnamed constructor.
158 if (func.IsNull()) { 158 if (func.IsNull()) {
159 tmp_name = String::Concat(func_name, Symbols::Dot()); 159 tmp_name = String::Concat(func_name, Symbols::Dot());
160 func = cls.LookupFunctionAllowPrivate(tmp_name); 160 func = cls.LookupFunctionAllowPrivate(tmp_name);
161 } 161 }
162 } else if (obj.IsLibrary()) { 162 } else if (obj.IsLibrary()) {
163 const Library& lib = Library::Cast(obj); 163 const Library& lib = Library::Cast(obj);
164 164
165 // Case 1. Lookup the unmodified function name. 165 // Case 1. Lookup the unmodified function name.
166 String& ambiguity_error_msg = String::Handle(isolate); 166 func = lib.LookupFunctionAllowPrivate(func_name);
167 func = lib.LookupFunctionAllowPrivate(func_name, &ambiguity_error_msg);
168 167
169 // Case 2. Lookup the function without the external setter suffix 168 // Case 2. Lookup the function without the external setter suffix
170 // '='. Make sure to do this check after the regular lookup, so 169 // '='. Make sure to do this check after the regular lookup, so
171 // that we don't interfere with operator lookups (like ==). 170 // that we don't interfere with operator lookups (like ==).
172 if (func.IsNull() && ambiguity_error_msg.IsNull() && 171 if (func.IsNull() && HasExternalSetterSuffix(func_name)) {
173 HasExternalSetterSuffix(func_name)) {
174 tmp_name = RemoveExternalSetterSuffix(func_name); 172 tmp_name = RemoveExternalSetterSuffix(func_name);
175 tmp_name = Field::SetterName(tmp_name); 173 tmp_name = Field::SetterName(tmp_name);
176 func = lib.LookupFunctionAllowPrivate(tmp_name, &ambiguity_error_msg); 174 func = lib.LookupFunctionAllowPrivate(tmp_name);
177 } 175 }
178 176
179 // Case 3. Lookup the function with the getter prefix prepended. 177 // Case 3. Lookup the function with the getter prefix prepended.
180 if (func.IsNull() && ambiguity_error_msg.IsNull()) { 178 if (func.IsNull()) {
181 tmp_name = Field::GetterName(func_name); 179 tmp_name = Field::GetterName(func_name);
182 func = lib.LookupFunctionAllowPrivate(tmp_name, &ambiguity_error_msg); 180 func = lib.LookupFunctionAllowPrivate(tmp_name);
183 }
184 if (!ambiguity_error_msg.IsNull()) {
185 return Api::NewError("%s.", ambiguity_error_msg.ToCString());
186 } 181 }
187 } else { 182 } else {
188 return Api::NewError( 183 return Api::NewError(
189 "%s expects argument 'target' to be a class or library.", 184 "%s expects argument 'target' to be a class or library.",
190 CURRENT_FUNC); 185 CURRENT_FUNC);
191 } 186 }
192 187
193 #if defined(DEBUG) 188 #if defined(DEBUG)
194 if (!func.IsNull()) { 189 if (!func.IsNull()) {
195 // We only provide access to a subset of function kinds. 190 // We only provide access to a subset of function kinds.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 RETURN_TYPE_ERROR(isolate, closure, Instance); 360 RETURN_TYPE_ERROR(isolate, closure, Instance);
366 } 361 }
367 362
368 ASSERT(ClassFinalizer::AllClassesFinalized()); 363 ASSERT(ClassFinalizer::AllClassesFinalized());
369 364
370 RawFunction* rf = Closure::function(closure_obj); 365 RawFunction* rf = Closure::function(closure_obj);
371 return Api::NewHandle(isolate, rf); 366 return Api::NewHandle(isolate, rf);
372 } 367 }
373 368
374 } // namespace dart 369 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_x64.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698