| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 RegisterClass(cls, Symbols::Bool(), core_lib); | 740 RegisterClass(cls, Symbols::Bool(), core_lib); |
| 741 pending_classes.Add(cls, Heap::kOld); | 741 pending_classes.Add(cls, Heap::kOld); |
| 742 | 742 |
| 743 cls = object_store->array_class(); // Was allocated above. | 743 cls = object_store->array_class(); // Was allocated above. |
| 744 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); | 744 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); |
| 745 pending_classes.Add(cls, Heap::kOld); | 745 pending_classes.Add(cls, Heap::kOld); |
| 746 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. | 746 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. |
| 747 type ^= Type::New(Object::Handle(cls.raw()), | 747 type ^= Type::New(Object::Handle(cls.raw()), |
| 748 TypeArguments::Handle(), | 748 TypeArguments::Handle(), |
| 749 Scanner::kDummyTokenIndex); | 749 Scanner::kDummyTokenIndex); |
| 750 type.set_is_finalized_instantiated(); | 750 type.SetIsFinalized(); |
| 751 type ^= type.Canonicalize(); | 751 type ^= type.Canonicalize(); |
| 752 object_store->set_array_type(type); | 752 object_store->set_array_type(type); |
| 753 | 753 |
| 754 cls = object_store->growable_object_array_class(); // Was allocated above. | 754 cls = object_store->growable_object_array_class(); // Was allocated above. |
| 755 RegisterPrivateClass(cls, Symbols::GrowableObjectArray(), core_lib); | 755 RegisterPrivateClass(cls, Symbols::GrowableObjectArray(), core_lib); |
| 756 pending_classes.Add(cls, Heap::kOld); | 756 pending_classes.Add(cls, Heap::kOld); |
| 757 | 757 |
| 758 cls = Class::New<ImmutableArray>(); | 758 cls = Class::New<ImmutableArray>(); |
| 759 object_store->set_immutable_array_class(cls); | 759 object_store->set_immutable_array_class(cls); |
| 760 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); | 760 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); |
| (...skipping 7960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8721 if (IsNull()) { | 8721 if (IsNull()) { |
| 8722 return Type::NullType(); | 8722 return Type::NullType(); |
| 8723 } | 8723 } |
| 8724 const Class& cls = Class::Handle(clazz()); | 8724 const Class& cls = Class::Handle(clazz()); |
| 8725 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 8725 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 8726 if (cls.HasTypeArguments()) { | 8726 if (cls.HasTypeArguments()) { |
| 8727 type_arguments = GetTypeArguments(); | 8727 type_arguments = GetTypeArguments(); |
| 8728 } | 8728 } |
| 8729 const Type& type = Type::Handle( | 8729 const Type& type = Type::Handle( |
| 8730 Type::New(cls, type_arguments, Scanner::kDummyTokenIndex)); | 8730 Type::New(cls, type_arguments, Scanner::kDummyTokenIndex)); |
| 8731 type.set_is_finalized_instantiated(); | 8731 type.SetIsFinalized(); |
| 8732 return type.raw(); | 8732 return type.raw(); |
| 8733 } | 8733 } |
| 8734 | 8734 |
| 8735 | 8735 |
| 8736 RawAbstractTypeArguments* Instance::GetTypeArguments() const { | 8736 RawAbstractTypeArguments* Instance::GetTypeArguments() const { |
| 8737 const Class& cls = Class::Handle(clazz()); | 8737 const Class& cls = Class::Handle(clazz()); |
| 8738 intptr_t field_offset = cls.type_arguments_field_offset(); | 8738 intptr_t field_offset = cls.type_arguments_field_offset(); |
| 8739 ASSERT(field_offset != Class::kNoTypeArguments); | 8739 ASSERT(field_offset != Class::kNoTypeArguments); |
| 8740 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 8740 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 8741 type_arguments ^= *FieldAddrAtOffset(field_offset); | 8741 type_arguments ^= *FieldAddrAtOffset(field_offset); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9284 } | 9284 } |
| 9285 | 9285 |
| 9286 | 9286 |
| 9287 RawType* Type::NewNonParameterizedType(const Class& type_class) { | 9287 RawType* Type::NewNonParameterizedType(const Class& type_class) { |
| 9288 ASSERT(!type_class.HasTypeArguments()); | 9288 ASSERT(!type_class.HasTypeArguments()); |
| 9289 const TypeArguments& no_type_arguments = TypeArguments::Handle(); | 9289 const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
| 9290 Type& type = Type::Handle(); | 9290 Type& type = Type::Handle(); |
| 9291 type ^= Type::New(Object::Handle(type_class.raw()), | 9291 type ^= Type::New(Object::Handle(type_class.raw()), |
| 9292 no_type_arguments, | 9292 no_type_arguments, |
| 9293 Scanner::kDummyTokenIndex); | 9293 Scanner::kDummyTokenIndex); |
| 9294 type.set_is_finalized_instantiated(); | 9294 type.SetIsFinalized(); |
| 9295 type ^= type.Canonicalize(); | 9295 type ^= type.Canonicalize(); |
| 9296 return type.raw(); | 9296 return type.raw(); |
| 9297 } | 9297 } |
| 9298 | 9298 |
| 9299 | 9299 |
| 9300 void Type::set_is_finalized_instantiated() const { | 9300 void Type::SetIsFinalized() const { |
| 9301 ASSERT(!IsFinalized()); | 9301 ASSERT(!IsFinalized()); |
| 9302 set_type_state(RawType::kFinalizedInstantiated); | 9302 if (IsInstantiated()) { |
| 9303 } | 9303 set_type_state(RawType::kFinalizedInstantiated); |
| 9304 | 9304 } else { |
| 9305 | 9305 set_type_state(RawType::kFinalizedUninstantiated); |
| 9306 void Type::set_is_finalized_uninstantiated() const { | 9306 } |
| 9307 ASSERT(!IsFinalized()); | |
| 9308 set_type_state(RawType::kFinalizedUninstantiated); | |
| 9309 } | 9307 } |
| 9310 | 9308 |
| 9311 | 9309 |
| 9312 void Type::set_is_being_finalized() const { | 9310 void Type::set_is_being_finalized() const { |
| 9313 ASSERT(!IsFinalized() && !IsBeingFinalized()); | 9311 ASSERT(!IsFinalized() && !IsBeingFinalized()); |
| 9314 set_type_state(RawType::kBeingFinalized); | 9312 set_type_state(RawType::kBeingFinalized); |
| 9315 } | 9313 } |
| 9316 | 9314 |
| 9317 | 9315 |
| 9318 bool Type::IsMalformed() const { | 9316 bool Type::IsMalformed() const { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9412 ASSERT(!IsInstantiated()); | 9410 ASSERT(!IsInstantiated()); |
| 9413 AbstractTypeArguments& type_arguments = | 9411 AbstractTypeArguments& type_arguments = |
| 9414 AbstractTypeArguments::Handle(arguments()); | 9412 AbstractTypeArguments::Handle(arguments()); |
| 9415 type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments); | 9413 type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments); |
| 9416 const Class& cls = Class::Handle(type_class()); | 9414 const Class& cls = Class::Handle(type_class()); |
| 9417 ASSERT(cls.is_finalized()); | 9415 ASSERT(cls.is_finalized()); |
| 9418 Type& instantiated_type = Type::Handle( | 9416 Type& instantiated_type = Type::Handle( |
| 9419 Type::New(cls, type_arguments, token_pos())); | 9417 Type::New(cls, type_arguments, token_pos())); |
| 9420 ASSERT(type_arguments.IsNull() || | 9418 ASSERT(type_arguments.IsNull() || |
| 9421 (type_arguments.Length() == cls.NumTypeArguments())); | 9419 (type_arguments.Length() == cls.NumTypeArguments())); |
| 9422 instantiated_type.set_is_finalized_instantiated(); | 9420 instantiated_type.SetIsFinalized(); |
| 9423 return instantiated_type.raw(); | 9421 return instantiated_type.raw(); |
| 9424 } | 9422 } |
| 9425 | 9423 |
| 9426 | 9424 |
| 9427 bool Type::Equals(const Instance& other) const { | 9425 bool Type::Equals(const Instance& other) const { |
| 9428 if (raw() == other.raw()) { | 9426 if (raw() == other.raw()) { |
| 9429 return true; | 9427 return true; |
| 9430 } | 9428 } |
| 9431 if (!other.IsType()) { | 9429 if (!other.IsType()) { |
| 9432 return false; | 9430 return false; |
| (...skipping 3675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13108 } | 13106 } |
| 13109 return result.raw(); | 13107 return result.raw(); |
| 13110 } | 13108 } |
| 13111 | 13109 |
| 13112 | 13110 |
| 13113 const char* WeakProperty::ToCString() const { | 13111 const char* WeakProperty::ToCString() const { |
| 13114 return "_WeakProperty"; | 13112 return "_WeakProperty"; |
| 13115 } | 13113 } |
| 13116 | 13114 |
| 13117 } // namespace dart | 13115 } // namespace dart |
| OLD | NEW |