| OLD | NEW |
| 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 9385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9396 GrowDictionary(dict, dict_size); | 9396 GrowDictionary(dict, dict_size); |
| 9397 } | 9397 } |
| 9398 | 9398 |
| 9399 // Invalidate the cache of loaded scripts. | 9399 // Invalidate the cache of loaded scripts. |
| 9400 if (loaded_scripts() != Array::null()) { | 9400 if (loaded_scripts() != Array::null()) { |
| 9401 StorePointer(&raw_ptr()->loaded_scripts_, Array::null()); | 9401 StorePointer(&raw_ptr()->loaded_scripts_, Array::null()); |
| 9402 } | 9402 } |
| 9403 } | 9403 } |
| 9404 | 9404 |
| 9405 | 9405 |
| 9406 // Lookup a name in the library's re-export namespace. The name is | 9406 // Lookup a name in the library's re-export namespace. |
| 9407 // unmangled, i.e. no getter or setter names should be looked up. | |
| 9408 RawObject* Library::LookupReExport(const String& name) const { | 9407 RawObject* Library::LookupReExport(const String& name) const { |
| 9409 if (HasExports()) { | 9408 if (HasExports()) { |
| 9410 const Array& exports = Array::Handle(this->exports()); | 9409 const Array& exports = Array::Handle(this->exports()); |
| 9411 // Break potential export cycle while looking up name. | 9410 // Break potential export cycle while looking up name. |
| 9412 StorePointer(&raw_ptr()->exports_, Object::empty_array().raw()); | 9411 StorePointer(&raw_ptr()->exports_, Object::empty_array().raw()); |
| 9413 Namespace& ns = Namespace::Handle(); | 9412 Namespace& ns = Namespace::Handle(); |
| 9414 Object& obj = Object::Handle(); | 9413 Object& obj = Object::Handle(); |
| 9415 for (int i = 0; i < exports.Length(); i++) { | 9414 for (int i = 0; i < exports.Length(); i++) { |
| 9416 ns ^= exports.At(i); | 9415 ns ^= exports.At(i); |
| 9417 obj = ns.Lookup(name); | 9416 obj = ns.Lookup(name); |
| 9418 if (!obj.IsNull()) { | 9417 if (!obj.IsNull()) { |
| 9419 break; | 9418 // The Lookup call above may return a setter x= when we are looking |
| 9419 // for the name x. Make sure we only return when a matching name |
| 9420 // is found. |
| 9421 String& obj_name = String::Handle(obj.DictionaryName()); |
| 9422 if (Field::IsSetterName(obj_name) == Field::IsSetterName(name)) { |
| 9423 break; |
| 9424 } |
| 9420 } | 9425 } |
| 9421 } | 9426 } |
| 9422 StorePointer(&raw_ptr()->exports_, exports.raw()); | 9427 StorePointer(&raw_ptr()->exports_, exports.raw()); |
| 9423 return obj.raw(); | 9428 return obj.raw(); |
| 9424 } | 9429 } |
| 9425 return Object::null(); | 9430 return Object::null(); |
| 9426 } | 9431 } |
| 9427 | 9432 |
| 9428 | 9433 |
| 9429 RawObject* Library::LookupEntry(const String& name, intptr_t *index) const { | 9434 RawObject* Library::LookupEntry(const String& name, intptr_t *index) const { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9724 // previously found object is exported from a Dart | 9729 // previously found object is exported from a Dart |
| 9725 // system library. The newly found object hides the one | 9730 // system library. The newly found object hides the one |
| 9726 // from the Dart library. | 9731 // from the Dart library. |
| 9727 first_import_lib_url = import_lib.url(); | 9732 first_import_lib_url = import_lib.url(); |
| 9728 found_obj = obj.raw(); | 9733 found_obj = obj.raw(); |
| 9729 found_obj_name = obj.DictionaryName(); | 9734 found_obj_name = obj.DictionaryName(); |
| 9730 } else if (import_lib_url.StartsWith(Symbols::DartScheme())) { | 9735 } else if (import_lib_url.StartsWith(Symbols::DartScheme())) { |
| 9731 // The newly found object is exported from a Dart system | 9736 // The newly found object is exported from a Dart system |
| 9732 // library. It is hidden by the previously found object. | 9737 // library. It is hidden by the previously found object. |
| 9733 // We continue to search. | 9738 // We continue to search. |
| 9739 } else if (Field::IsSetterName(found_obj_name) && |
| 9740 !Field::IsSetterName(name)) { |
| 9741 // We are looking for an unmangled name or a getter, but |
| 9742 // the first object we found is a setter. Replace the first |
| 9743 // object with the one we just found. |
| 9744 first_import_lib_url = import_lib.url(); |
| 9745 found_obj = obj.raw(); |
| 9746 found_obj_name = found_obj.DictionaryName(); |
| 9734 } else { | 9747 } else { |
| 9735 // We found two different objects with the same name. | 9748 // We found two different objects with the same name. |
| 9736 // Note that we need to compare the names again because | 9749 // Note that we need to compare the names again because |
| 9737 // looking up an unmangled name can return a getter or a | 9750 // looking up an unmangled name can return a getter or a |
| 9738 // setter. A getter name is the same as the unmangled name, | 9751 // setter. A getter name is the same as the unmangled name, |
| 9739 // but a setter name is different from an unmangled name or a | 9752 // but a setter name is different from an unmangled name or a |
| 9740 // getter name. | 9753 // getter name. |
| 9741 if (Field::IsGetterName(found_obj_name)) { | 9754 if (Field::IsGetterName(found_obj_name)) { |
| 9742 found_obj_name = Field::NameFromGetter(found_obj_name); | 9755 found_obj_name = Field::NameFromGetter(found_obj_name); |
| 9743 } | 9756 } |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10334 if (!is_loaded() && !FLAG_load_deferred_eagerly) { | 10347 if (!is_loaded() && !FLAG_load_deferred_eagerly) { |
| 10335 return Object::null(); | 10348 return Object::null(); |
| 10336 } | 10349 } |
| 10337 Array& imports = Array::Handle(this->imports()); | 10350 Array& imports = Array::Handle(this->imports()); |
| 10338 Object& obj = Object::Handle(); | 10351 Object& obj = Object::Handle(); |
| 10339 Namespace& import = Namespace::Handle(); | 10352 Namespace& import = Namespace::Handle(); |
| 10340 Library& import_lib = Library::Handle(); | 10353 Library& import_lib = Library::Handle(); |
| 10341 String& import_lib_url = String::Handle(); | 10354 String& import_lib_url = String::Handle(); |
| 10342 String& first_import_lib_url = String::Handle(); | 10355 String& first_import_lib_url = String::Handle(); |
| 10343 Object& found_obj = Object::Handle(); | 10356 Object& found_obj = Object::Handle(); |
| 10357 String& found_obj_name = String::Handle(); |
| 10344 for (intptr_t i = 0; i < num_imports(); i++) { | 10358 for (intptr_t i = 0; i < num_imports(); i++) { |
| 10345 import ^= imports.At(i); | 10359 import ^= imports.At(i); |
| 10346 obj = import.Lookup(name); | 10360 obj = import.Lookup(name); |
| 10347 if (!obj.IsNull()) { | 10361 if (!obj.IsNull()) { |
| 10348 import_lib = import.library(); | 10362 import_lib = import.library(); |
| 10349 import_lib_url = import_lib.url(); | 10363 import_lib_url = import_lib.url(); |
| 10350 if (found_obj.raw() != obj.raw()) { | 10364 if (found_obj.raw() != obj.raw()) { |
| 10351 if (first_import_lib_url.IsNull() || | 10365 if (first_import_lib_url.IsNull() || |
| 10352 first_import_lib_url.StartsWith(Symbols::DartScheme())) { | 10366 first_import_lib_url.StartsWith(Symbols::DartScheme())) { |
| 10353 // This is the first object we found, or the | 10367 // This is the first object we found, or the |
| 10354 // previously found object is exported from a Dart | 10368 // previously found object is exported from a Dart |
| 10355 // system library. The newly found object hides the one | 10369 // system library. The newly found object hides the one |
| 10356 // from the Dart library. | 10370 // from the Dart library. |
| 10357 first_import_lib_url = import_lib.url(); | 10371 first_import_lib_url = import_lib.url(); |
| 10358 found_obj = obj.raw(); | 10372 found_obj = obj.raw(); |
| 10373 found_obj_name = found_obj.DictionaryName(); |
| 10359 } else if (import_lib_url.StartsWith(Symbols::DartScheme())) { | 10374 } else if (import_lib_url.StartsWith(Symbols::DartScheme())) { |
| 10360 // The newly found object is exported from a Dart system | 10375 // The newly found object is exported from a Dart system |
| 10361 // library. It is hidden by the previously found object. | 10376 // library. It is hidden by the previously found object. |
| 10362 // We continue to search. | 10377 // We continue to search. |
| 10378 } else if (Field::IsSetterName(found_obj_name) && |
| 10379 !Field::IsSetterName(name)) { |
| 10380 // We are looking for an unmangled name or a getter, but |
| 10381 // the first object we found is a setter. Replace the first |
| 10382 // object with the one we just found. |
| 10383 first_import_lib_url = import_lib.url(); |
| 10384 found_obj = obj.raw(); |
| 10385 found_obj_name = found_obj.DictionaryName(); |
| 10363 } else { | 10386 } else { |
| 10364 // We found two different objects with the same name. | 10387 // We found two different objects with the same name. |
| 10365 return Object::null(); | 10388 // Note that we need to compare the names again because |
| 10389 // looking up an unmangled name can return a getter or a |
| 10390 // setter. A getter name is the same as the unmangled name, |
| 10391 // but a setter name is different from an unmangled name or a |
| 10392 // getter name. |
| 10393 if (Field::IsGetterName(found_obj_name)) { |
| 10394 found_obj_name = Field::NameFromGetter(found_obj_name); |
| 10395 } |
| 10396 String& second_obj_name = String::Handle(obj.DictionaryName()); |
| 10397 if (Field::IsGetterName(second_obj_name)) { |
| 10398 second_obj_name = Field::NameFromGetter(second_obj_name); |
| 10399 } |
| 10400 if (found_obj_name.Equals(second_obj_name)) { |
| 10401 return Object::null(); |
| 10402 } |
| 10366 } | 10403 } |
| 10367 } | 10404 } |
| 10368 } | 10405 } |
| 10369 } | 10406 } |
| 10370 return found_obj.raw(); | 10407 return found_obj.raw(); |
| 10371 } | 10408 } |
| 10372 | 10409 |
| 10373 | 10410 |
| 10374 RawClass* LibraryPrefix::LookupClass(const String& class_name) const { | 10411 RawClass* LibraryPrefix::LookupClass(const String& class_name) const { |
| 10375 const Object& obj = Object::Handle(LookupObject(class_name)); | 10412 const Object& obj = Object::Handle(LookupObject(class_name)); |
| (...skipping 11325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21701 return UserTag::null(); | 21738 return UserTag::null(); |
| 21702 } | 21739 } |
| 21703 | 21740 |
| 21704 | 21741 |
| 21705 const char* UserTag::ToCString() const { | 21742 const char* UserTag::ToCString() const { |
| 21706 const String& tag_label = String::Handle(label()); | 21743 const String& tag_label = String::Handle(label()); |
| 21707 return tag_label.ToCString(); | 21744 return tag_label.ToCString(); |
| 21708 } | 21745 } |
| 21709 | 21746 |
| 21710 } // namespace dart | 21747 } // namespace dart |
| OLD | NEW |