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

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

Issue 1090373006: Properly resolve top-level setters (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 9325 matching lines...) Expand 10 before | Expand all | Expand 10 after
9336 } 9336 }
9337 9337
9338 9338
9339 RawObject* Library::LookupImportedObject(const String& name) const { 9339 RawObject* Library::LookupImportedObject(const String& name) const {
9340 Object& obj = Object::Handle(); 9340 Object& obj = Object::Handle();
9341 Namespace& import = Namespace::Handle(); 9341 Namespace& import = Namespace::Handle();
9342 Library& import_lib = Library::Handle(); 9342 Library& import_lib = Library::Handle();
9343 String& import_lib_url = String::Handle(); 9343 String& import_lib_url = String::Handle();
9344 String& first_import_lib_url = String::Handle(); 9344 String& first_import_lib_url = String::Handle();
9345 Object& found_obj = Object::Handle(); 9345 Object& found_obj = Object::Handle();
9346 String& found_obj_name = String::Handle();
9346 for (intptr_t i = 0; i < num_imports(); i++) { 9347 for (intptr_t i = 0; i < num_imports(); i++) {
9347 import ^= ImportAt(i); 9348 import ^= ImportAt(i);
9348 obj = import.Lookup(name); 9349 obj = import.Lookup(name);
9349 if (!obj.IsNull()) { 9350 if (!obj.IsNull()) {
9350 import_lib = import.library(); 9351 import_lib = import.library();
9351 import_lib_url = import_lib.url(); 9352 import_lib_url = import_lib.url();
9352 if (found_obj.raw() != obj.raw()) { 9353 if (found_obj.raw() != obj.raw()) {
9353 if (first_import_lib_url.IsNull() || 9354 if (first_import_lib_url.IsNull() ||
9354 first_import_lib_url.StartsWith(Symbols::DartScheme())) { 9355 first_import_lib_url.StartsWith(Symbols::DartScheme())) {
9355 // This is the first object we found, or the 9356 // This is the first object we found, or the
9356 // previously found object is exported from a Dart 9357 // previously found object is exported from a Dart
9357 // system library. The newly found object hides the one 9358 // system library. The newly found object hides the one
9358 // from the Dart library. 9359 // from the Dart library.
9359 first_import_lib_url = import_lib.url(); 9360 first_import_lib_url = import_lib.url();
9360 found_obj = obj.raw(); 9361 found_obj = obj.raw();
9362 found_obj_name = obj.DictionaryName();
9361 } else if (import_lib_url.StartsWith(Symbols::DartScheme())) { 9363 } else if (import_lib_url.StartsWith(Symbols::DartScheme())) {
9362 // The newly found object is exported from a Dart system 9364 // The newly found object is exported from a Dart system
9363 // library. It is hidden by the previously found object. 9365 // library. It is hidden by the previously found object.
9364 // We continue to search. 9366 // We continue to search.
9365 } else { 9367 } else {
9366 // We found two different objects with the same name. 9368 // We found two different objects with the same name.
9367 return Object::null(); 9369 // Note that we need to compare the names again because
9370 // looking up an unmangled name can return a getter or a
9371 // setter. A getter name is the same as the unmangled name,
9372 // but a setter name is different from an unmangled name or a
9373 // getter name.
9374 if (Field::IsGetterName(found_obj_name)) {
9375 found_obj_name = Field::NameFromGetter(found_obj_name);
9376 }
9377 String& second_obj_name = String::Handle(obj.DictionaryName());
9378 if (Field::IsGetterName(second_obj_name)) {
9379 second_obj_name = Field::NameFromGetter(second_obj_name);
9380 }
9381 if (found_obj_name.Equals(second_obj_name)) {
9382 return Object::null();
9383 }
9368 } 9384 }
9369 } 9385 }
9370 } 9386 }
9371 } 9387 }
9372 return found_obj.raw(); 9388 return found_obj.raw();
9373 } 9389 }
9374 9390
9375 9391
9376 RawClass* Library::LookupClass(const String& name) const { 9392 RawClass* Library::LookupClass(const String& name) const {
9377 Object& obj = Object::Handle(ResolveName(name)); 9393 Object& obj = Object::Handle(ResolveName(name));
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
10330 Isolate* isolate = Isolate::Current(); 10346 Isolate* isolate = Isolate::Current();
10331 const Library& lib = Library::Handle(isolate, library()); 10347 const Library& lib = Library::Handle(isolate, library());
10332 intptr_t ignore = 0; 10348 intptr_t ignore = 0;
10333 10349
10334 // Lookup the name in the library's symbols. 10350 // Lookup the name in the library's symbols.
10335 const String* filter_name = &name; 10351 const String* filter_name = &name;
10336 Object& obj = Object::Handle(isolate, lib.LookupEntry(name, &ignore)); 10352 Object& obj = Object::Handle(isolate, lib.LookupEntry(name, &ignore));
10337 if (Field::IsGetterName(name)) { 10353 if (Field::IsGetterName(name)) {
10338 filter_name = &String::Handle(Field::NameFromGetter(name)); 10354 filter_name = &String::Handle(Field::NameFromGetter(name));
10339 } else if (Field::IsSetterName(name)) { 10355 } else if (Field::IsSetterName(name)) {
10340 filter_name = &String::Handle(Field::NameFromGetter(name)); 10356 filter_name = &String::Handle(Field::NameFromSetter(name));
10341 } else { 10357 } else {
10342 if (obj.IsNull() || obj.IsLibraryPrefix()) { 10358 if (obj.IsNull() || obj.IsLibraryPrefix()) {
10343 obj = lib.LookupEntry(String::Handle(Field::GetterName(name)), &ignore); 10359 obj = lib.LookupEntry(String::Handle(Field::GetterName(name)), &ignore);
10344 if (obj.IsNull()) { 10360 if (obj.IsNull()) {
10345 obj = lib.LookupEntry(String::Handle(Field::SetterName(name)), &ignore); 10361 obj = lib.LookupEntry(String::Handle(Field::SetterName(name)), &ignore);
10346 } 10362 }
10347 } 10363 }
10348 } 10364 }
10349 10365
10350 // Library prefixes are not exported. 10366 // Library prefixes are not exported.
(...skipping 10340 matching lines...) Expand 10 before | Expand all | Expand 10 after
20691 return tag_label.ToCString(); 20707 return tag_label.ToCString();
20692 } 20708 }
20693 20709
20694 20710
20695 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20711 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20696 Instance::PrintJSONImpl(stream, ref); 20712 Instance::PrintJSONImpl(stream, ref);
20697 } 20713 }
20698 20714
20699 20715
20700 } // namespace dart 20716 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698