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 4441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4452 strings.SetAt(s++, Symbols::RAngleBracket()); | 4452 strings.SetAt(s++, Symbols::RAngleBracket()); |
4453 ASSERT(s == num_strings); | 4453 ASSERT(s == num_strings); |
4454 name = String::ConcatAll(strings); | 4454 name = String::ConcatAll(strings); |
4455 return Symbols::New(name); | 4455 return Symbols::New(name); |
4456 } | 4456 } |
4457 | 4457 |
4458 | 4458 |
4459 bool TypeArguments::IsSubvectorEquivalent(const TypeArguments& other, | 4459 bool TypeArguments::IsSubvectorEquivalent(const TypeArguments& other, |
4460 intptr_t from_index, | 4460 intptr_t from_index, |
4461 intptr_t len, | 4461 intptr_t len, |
4462 GrowableObjectArray* trail) const { | 4462 TrailPtr trail) const { |
4463 if (this->raw() == other.raw()) { | 4463 if (this->raw() == other.raw()) { |
4464 return true; | 4464 return true; |
4465 } | 4465 } |
4466 if (IsNull() || other.IsNull()) { | 4466 if (IsNull() || other.IsNull()) { |
4467 return false; | 4467 return false; |
4468 } | 4468 } |
4469 const intptr_t num_types = Length(); | 4469 const intptr_t num_types = Length(); |
4470 if (num_types != other.Length()) { | 4470 if (num_types != other.Length()) { |
4471 return false; | 4471 return false; |
4472 } | 4472 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4649 if (!type.IsResolved()) { | 4649 if (!type.IsResolved()) { |
4650 return false; | 4650 return false; |
4651 } | 4651 } |
4652 } | 4652 } |
4653 return true; | 4653 return true; |
4654 } | 4654 } |
4655 | 4655 |
4656 | 4656 |
4657 bool TypeArguments::IsSubvectorInstantiated(intptr_t from_index, | 4657 bool TypeArguments::IsSubvectorInstantiated(intptr_t from_index, |
4658 intptr_t len, | 4658 intptr_t len, |
4659 GrowableObjectArray* trail) const { | 4659 TrailPtr trail) const { |
4660 ASSERT(!IsNull()); | 4660 ASSERT(!IsNull()); |
4661 AbstractType& type = AbstractType::Handle(); | 4661 AbstractType& type = AbstractType::Handle(); |
4662 for (intptr_t i = 0; i < len; i++) { | 4662 for (intptr_t i = 0; i < len; i++) { |
4663 type = TypeAt(from_index + i); | 4663 type = TypeAt(from_index + i); |
4664 // If the type argument is null, the type parameterized with this type | 4664 // If the type argument is null, the type parameterized with this type |
4665 // argument is still being finalized. Skip this null type argument. | 4665 // argument is still being finalized. Skip this null type argument. |
4666 if (!type.IsNull() && !type.IsInstantiated(trail)) { | 4666 if (!type.IsNull() && !type.IsInstantiated(trail)) { |
4667 return false; | 4667 return false; |
4668 } | 4668 } |
4669 } | 4669 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4807 return true; | 4807 return true; |
4808 } | 4808 } |
4809 } | 4809 } |
4810 return false; | 4810 return false; |
4811 } | 4811 } |
4812 | 4812 |
4813 | 4813 |
4814 RawTypeArguments* TypeArguments::InstantiateFrom( | 4814 RawTypeArguments* TypeArguments::InstantiateFrom( |
4815 const TypeArguments& instantiator_type_arguments, | 4815 const TypeArguments& instantiator_type_arguments, |
4816 Error* bound_error, | 4816 Error* bound_error, |
4817 GrowableObjectArray* trail) const { | 4817 TrailPtr trail) const { |
4818 ASSERT(!IsInstantiated()); | 4818 ASSERT(!IsInstantiated()); |
4819 if (!instantiator_type_arguments.IsNull() && | 4819 if (!instantiator_type_arguments.IsNull() && |
4820 IsUninstantiatedIdentity() && | 4820 IsUninstantiatedIdentity() && |
4821 (instantiator_type_arguments.Length() == Length())) { | 4821 (instantiator_type_arguments.Length() == Length())) { |
4822 return instantiator_type_arguments.raw(); | 4822 return instantiator_type_arguments.raw(); |
4823 } | 4823 } |
4824 const intptr_t num_types = Length(); | 4824 const intptr_t num_types = Length(); |
4825 TypeArguments& instantiated_array = | 4825 TypeArguments& instantiated_array = |
4826 TypeArguments::Handle(TypeArguments::New(num_types, Heap::kNew)); | 4826 TypeArguments::Handle(TypeArguments::New(num_types, Heap::kNew)); |
4827 AbstractType& type = AbstractType::Handle(); | 4827 AbstractType& type = AbstractType::Handle(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5041 type = type.CloneUnfinalized(); | 5041 type = type.CloneUnfinalized(); |
5042 clone.SetTypeAt(i, type); | 5042 clone.SetTypeAt(i, type); |
5043 } | 5043 } |
5044 ASSERT(clone.IsResolved()); | 5044 ASSERT(clone.IsResolved()); |
5045 return clone.raw(); | 5045 return clone.raw(); |
5046 } | 5046 } |
5047 | 5047 |
5048 | 5048 |
5049 RawTypeArguments* TypeArguments::CloneUninstantiated( | 5049 RawTypeArguments* TypeArguments::CloneUninstantiated( |
5050 const Class& new_owner, | 5050 const Class& new_owner, |
5051 GrowableObjectArray* trail) const { | 5051 TrailPtr trail) const { |
5052 ASSERT(!IsNull()); | 5052 ASSERT(!IsNull()); |
5053 ASSERT(IsFinalized()); | 5053 ASSERT(IsFinalized()); |
5054 ASSERT(!IsInstantiated()); | 5054 ASSERT(!IsInstantiated()); |
5055 AbstractType& type = AbstractType::Handle(); | 5055 AbstractType& type = AbstractType::Handle(); |
5056 const intptr_t num_types = Length(); | 5056 const intptr_t num_types = Length(); |
5057 const TypeArguments& clone = TypeArguments::Handle( | 5057 const TypeArguments& clone = TypeArguments::Handle( |
5058 TypeArguments::New(num_types)); | 5058 TypeArguments::New(num_types)); |
5059 for (intptr_t i = 0; i < num_types; i++) { | 5059 for (intptr_t i = 0; i < num_types; i++) { |
5060 type = TypeAt(i); | 5060 type = TypeAt(i); |
5061 if (!type.IsInstantiated()) { | 5061 if (!type.IsInstantiated()) { |
5062 type = type.CloneUninstantiated(new_owner, trail); | 5062 type = type.CloneUninstantiated(new_owner, trail); |
5063 } | 5063 } |
5064 clone.SetTypeAt(i, type); | 5064 clone.SetTypeAt(i, type); |
5065 } | 5065 } |
5066 ASSERT(clone.IsFinalized()); | 5066 ASSERT(clone.IsFinalized()); |
5067 return clone.raw(); | 5067 return clone.raw(); |
5068 } | 5068 } |
5069 | 5069 |
5070 | 5070 |
5071 RawTypeArguments* TypeArguments::Canonicalize( | 5071 RawTypeArguments* TypeArguments::Canonicalize(TrailPtr trail) const { |
5072 GrowableObjectArray* trail) const { | |
5073 if (IsNull() || IsCanonical()) { | 5072 if (IsNull() || IsCanonical()) { |
5074 ASSERT(IsOld()); | 5073 ASSERT(IsOld()); |
5075 return this->raw(); | 5074 return this->raw(); |
5076 } | 5075 } |
5077 const intptr_t num_types = Length(); | 5076 const intptr_t num_types = Length(); |
5078 if (IsRaw(0, num_types)) { | 5077 if (IsRaw(0, num_types)) { |
5079 return TypeArguments::null(); | 5078 return TypeArguments::null(); |
5080 } | 5079 } |
5081 Isolate* isolate = Isolate::Current(); | 5080 Isolate* isolate = Isolate::Current(); |
5082 ObjectStore* object_store = isolate->object_store(); | 5081 ObjectStore* object_store = isolate->object_store(); |
(...skipping 9710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14793 } | 14792 } |
14794 | 14793 |
14795 | 14794 |
14796 intptr_t AbstractType::token_pos() const { | 14795 intptr_t AbstractType::token_pos() const { |
14797 // AbstractType is an abstract class. | 14796 // AbstractType is an abstract class. |
14798 UNREACHABLE(); | 14797 UNREACHABLE(); |
14799 return -1; | 14798 return -1; |
14800 } | 14799 } |
14801 | 14800 |
14802 | 14801 |
14803 bool AbstractType::IsInstantiated(GrowableObjectArray* trail) const { | 14802 bool AbstractType::IsInstantiated(TrailPtr trail) const { |
14804 // AbstractType is an abstract class. | 14803 // AbstractType is an abstract class. |
14805 UNREACHABLE(); | 14804 UNREACHABLE(); |
14806 return false; | 14805 return false; |
14807 } | 14806 } |
14808 | 14807 |
14809 | 14808 |
14810 bool AbstractType::IsFinalized() const { | 14809 bool AbstractType::IsFinalized() const { |
14811 // AbstractType is an abstract class. | 14810 // AbstractType is an abstract class. |
14812 UNREACHABLE(); | 14811 UNREACHABLE(); |
14813 return false; | 14812 return false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14848 return LanguageError::null(); | 14847 return LanguageError::null(); |
14849 } | 14848 } |
14850 | 14849 |
14851 | 14850 |
14852 void AbstractType::set_error(const LanguageError& value) const { | 14851 void AbstractType::set_error(const LanguageError& value) const { |
14853 // AbstractType is an abstract class. | 14852 // AbstractType is an abstract class. |
14854 UNREACHABLE(); | 14853 UNREACHABLE(); |
14855 } | 14854 } |
14856 | 14855 |
14857 | 14856 |
14858 bool AbstractType::IsEquivalent(const Instance& other, | 14857 bool AbstractType::IsEquivalent(const Instance& other, TrailPtr trail) const { |
14859 GrowableObjectArray* trail) const { | |
14860 // AbstractType is an abstract class. | 14858 // AbstractType is an abstract class. |
14861 UNREACHABLE(); | 14859 UNREACHABLE(); |
14862 return false; | 14860 return false; |
14863 } | 14861 } |
14864 | 14862 |
14865 | 14863 |
14866 bool AbstractType::IsRecursive() const { | 14864 bool AbstractType::IsRecursive() const { |
14867 // AbstractType is an abstract class. | 14865 // AbstractType is an abstract class. |
14868 UNREACHABLE(); | 14866 UNREACHABLE(); |
14869 return false; | 14867 return false; |
14870 } | 14868 } |
14871 | 14869 |
14872 | 14870 |
14873 RawAbstractType* AbstractType::InstantiateFrom( | 14871 RawAbstractType* AbstractType::InstantiateFrom( |
14874 const TypeArguments& instantiator_type_arguments, | 14872 const TypeArguments& instantiator_type_arguments, |
14875 Error* bound_error, | 14873 Error* bound_error, |
14876 GrowableObjectArray* trail) const { | 14874 TrailPtr trail) const { |
14877 // AbstractType is an abstract class. | 14875 // AbstractType is an abstract class. |
14878 UNREACHABLE(); | 14876 UNREACHABLE(); |
14879 return NULL; | 14877 return NULL; |
14880 } | 14878 } |
14881 | 14879 |
14882 | 14880 |
14883 RawAbstractType* AbstractType::CloneUnfinalized() const { | 14881 RawAbstractType* AbstractType::CloneUnfinalized() const { |
14884 // AbstractType is an abstract class. | 14882 // AbstractType is an abstract class. |
14885 UNREACHABLE(); | 14883 UNREACHABLE(); |
14886 return NULL; | 14884 return NULL; |
14887 } | 14885 } |
14888 | 14886 |
14889 | 14887 |
14890 RawAbstractType* AbstractType::CloneUninstantiated( | 14888 RawAbstractType* AbstractType::CloneUninstantiated( |
14891 const Class& new_owner, | 14889 const Class& new_owner, TrailPtr trail) const { |
14892 GrowableObjectArray* trail) const { | |
14893 // AbstractType is an abstract class. | 14890 // AbstractType is an abstract class. |
14894 UNREACHABLE(); | 14891 UNREACHABLE(); |
14895 return NULL; | 14892 return NULL; |
14896 } | 14893 } |
14897 | 14894 |
14898 | 14895 |
14899 RawAbstractType* AbstractType::Canonicalize(GrowableObjectArray* trail) const { | 14896 RawAbstractType* AbstractType::Canonicalize(TrailPtr trail) const { |
14900 // AbstractType is an abstract class. | 14897 // AbstractType is an abstract class. |
14901 UNREACHABLE(); | 14898 UNREACHABLE(); |
14902 return NULL; | 14899 return NULL; |
14903 } | 14900 } |
14904 | 14901 |
14905 | 14902 |
14906 RawObject* AbstractType::OnlyBuddyInTrail(GrowableObjectArray* trail) const { | 14903 RawInstance* AbstractType::OnlyBuddyInTrail(TrailPtr trail) const { |
regis
2015/08/27 02:30:26
see comment in header
srdjan
2015/08/27 16:09:49
Done.
| |
14907 if (trail == NULL) { | 14904 if (trail == NULL) { |
14908 return Object::null(); | 14905 return Instance::null(); |
regis
2015/08/27 02:30:26
ditto
srdjan
2015/08/27 16:09:49
Done.
| |
14909 } | 14906 } |
14910 const intptr_t len = trail->Length(); | 14907 const intptr_t len = trail->length(); |
14911 ASSERT((len % 2) == 0); | 14908 ASSERT((len % 2) == 0); |
14912 for (intptr_t i = 0; i < len; i += 2) { | 14909 for (intptr_t i = 0; i < len; i += 2) { |
14913 if (trail->At(i) == this->raw()) { | 14910 if (trail->At(i)->raw() == this->raw()) { |
14914 ASSERT(trail->At(i + 1) != Object::null()); | 14911 ASSERT(!trail->At(i + 1)->IsNull()); |
14915 return trail->At(i + 1); | 14912 return trail->At(i + 1)->raw(); |
14916 } | 14913 } |
14917 } | 14914 } |
14918 return Object::null(); | 14915 return Instance::null(); |
regis
2015/08/27 02:30:25
ditto
srdjan
2015/08/27 16:09:49
Done.
| |
14919 } | 14916 } |
14920 | 14917 |
14921 | 14918 |
14922 void AbstractType::AddOnlyBuddyToTrail(GrowableObjectArray** trail, | 14919 void AbstractType::AddOnlyBuddyToTrail(TrailPtr* trail, |
14923 const Object& buddy) const { | 14920 const AbstractType& buddy) const { |
14924 if (*trail == NULL) { | 14921 if (*trail == NULL) { |
14925 *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New()); | 14922 *trail = new Trail(); |
14926 } else { | 14923 } else { |
14927 ASSERT(OnlyBuddyInTrail(*trail) == Object::null()); | 14924 ASSERT(OnlyBuddyInTrail(*trail) == Object::null()); |
regis
2015/08/27 02:30:26
AbstractType:null()
srdjan
2015/08/27 16:09:49
Done.
| |
14928 } | 14925 } |
14929 (*trail)->Add(*this); | 14926 AbstractType& t = AbstractType::ZoneHandle(this->raw()); |
14930 (*trail)->Add(buddy); | 14927 AbstractType& b = AbstractType::ZoneHandle(buddy.raw()); |
14928 (*trail)->Add(&t); | |
14929 (*trail)->Add(&b); | |
14931 } | 14930 } |
14932 | 14931 |
14933 | 14932 |
14934 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { | 14933 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { |
14935 if (IsBoundedType()) { | 14934 if (IsBoundedType()) { |
14936 const AbstractType& type = AbstractType::Handle( | 14935 const AbstractType& type = AbstractType::Handle( |
14937 BoundedType::Cast(*this).type()); | 14936 BoundedType::Cast(*this).type()); |
14938 if (name_visibility == kPrettyName) { | 14937 if (name_visibility == kPrettyName) { |
14939 return type.BuildName(kPrettyName); | 14938 return type.BuildName(kPrettyName); |
14940 } else if (name_visibility == kUserVisibleName) { | 14939 } else if (name_visibility == kUserVisibleName) { |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15425 return reinterpret_cast<RawUnresolvedClass*>(raw_ptr()->type_class_); | 15424 return reinterpret_cast<RawUnresolvedClass*>(raw_ptr()->type_class_); |
15426 #endif | 15425 #endif |
15427 } | 15426 } |
15428 | 15427 |
15429 | 15428 |
15430 RawTypeArguments* Type::arguments() const { | 15429 RawTypeArguments* Type::arguments() const { |
15431 return raw_ptr()->arguments_; | 15430 return raw_ptr()->arguments_; |
15432 } | 15431 } |
15433 | 15432 |
15434 | 15433 |
15435 bool Type::IsInstantiated(GrowableObjectArray* trail) const { | 15434 bool Type::IsInstantiated(TrailPtr trail) const { |
15436 if (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) { | 15435 if (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) { |
15437 return true; | 15436 return true; |
15438 } | 15437 } |
15439 if (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated) { | 15438 if (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated) { |
15440 return false; | 15439 return false; |
15441 } | 15440 } |
15442 if (arguments() == TypeArguments::null()) { | 15441 if (arguments() == TypeArguments::null()) { |
15443 return true; | 15442 return true; |
15444 } | 15443 } |
15445 const TypeArguments& args = TypeArguments::Handle(arguments()); | 15444 const TypeArguments& args = TypeArguments::Handle(arguments()); |
(...skipping 13 matching lines...) Expand all Loading... | |
15459 num_type_args = len; | 15458 num_type_args = len; |
15460 len = cls.NumTypeParameters(); // Check the type parameters only. | 15459 len = cls.NumTypeParameters(); // Check the type parameters only. |
15461 } | 15460 } |
15462 return (len == 0) || args.IsSubvectorInstantiated(num_type_args - len, len); | 15461 return (len == 0) || args.IsSubvectorInstantiated(num_type_args - len, len); |
15463 } | 15462 } |
15464 | 15463 |
15465 | 15464 |
15466 RawAbstractType* Type::InstantiateFrom( | 15465 RawAbstractType* Type::InstantiateFrom( |
15467 const TypeArguments& instantiator_type_arguments, | 15466 const TypeArguments& instantiator_type_arguments, |
15468 Error* bound_error, | 15467 Error* bound_error, |
15469 GrowableObjectArray* trail) const { | 15468 TrailPtr trail) const { |
15470 ASSERT(IsFinalized() || IsBeingFinalized()); | 15469 ASSERT(IsFinalized() || IsBeingFinalized()); |
15471 ASSERT(!IsInstantiated()); | 15470 ASSERT(!IsInstantiated()); |
15472 // Return the uninstantiated type unchanged if malformed. No copy needed. | 15471 // Return the uninstantiated type unchanged if malformed. No copy needed. |
15473 if (IsMalformed()) { | 15472 if (IsMalformed()) { |
15474 return raw(); | 15473 return raw(); |
15475 } | 15474 } |
15476 // Instantiating this type with its own type arguments as instantiator can | 15475 // Instantiating this type with its own type arguments as instantiator can |
15477 // occur during finalization and bounds checking. Return the type unchanged. | 15476 // occur during finalization and bounds checking. Return the type unchanged. |
15478 if (arguments() == instantiator_type_arguments.raw()) { | 15477 if (arguments() == instantiator_type_arguments.raw()) { |
15479 return raw(); | 15478 return raw(); |
(...skipping 25 matching lines...) Expand all Loading... | |
15505 if (IsFinalized()) { | 15504 if (IsFinalized()) { |
15506 instantiated_type.SetIsFinalized(); | 15505 instantiated_type.SetIsFinalized(); |
15507 } else { | 15506 } else { |
15508 instantiated_type.set_is_resolved(); | 15507 instantiated_type.set_is_resolved(); |
15509 } | 15508 } |
15510 // Canonicalization is not part of instantiation. | 15509 // Canonicalization is not part of instantiation. |
15511 return instantiated_type.raw(); | 15510 return instantiated_type.raw(); |
15512 } | 15511 } |
15513 | 15512 |
15514 | 15513 |
15515 bool Type::IsEquivalent(const Instance& other, | 15514 bool Type::IsEquivalent(const Instance& other, TrailPtr trail) const { |
15516 GrowableObjectArray* trail) const { | |
15517 ASSERT(!IsNull()); | 15515 ASSERT(!IsNull()); |
15518 if (raw() == other.raw()) { | 15516 if (raw() == other.raw()) { |
15519 return true; | 15517 return true; |
15520 } | 15518 } |
15521 if (other.IsTypeRef()) { | 15519 if (other.IsTypeRef()) { |
15522 // Unfold right hand type. Divergence is controlled by left hand type. | 15520 // Unfold right hand type. Divergence is controlled by left hand type. |
15523 const AbstractType& other_ref_type = AbstractType::Handle( | 15521 const AbstractType& other_ref_type = AbstractType::Handle( |
15524 TypeRef::Cast(other).type()); | 15522 TypeRef::Cast(other).type()); |
15525 ASSERT(!other_ref_type.IsTypeRef()); | 15523 ASSERT(!other_ref_type.IsTypeRef()); |
15526 return IsEquivalent(other_ref_type, trail); | 15524 return IsEquivalent(other_ref_type, trail); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15601 TypeArguments& type_args = TypeArguments::Handle(arguments()); | 15599 TypeArguments& type_args = TypeArguments::Handle(arguments()); |
15602 type_args = type_args.CloneUnfinalized(); | 15600 type_args = type_args.CloneUnfinalized(); |
15603 const Class& type_cls = Class::Handle(type_class()); | 15601 const Class& type_cls = Class::Handle(type_class()); |
15604 const Type& clone = Type::Handle(Type::New(type_cls, type_args, token_pos())); | 15602 const Type& clone = Type::Handle(Type::New(type_cls, type_args, token_pos())); |
15605 clone.set_is_resolved(); | 15603 clone.set_is_resolved(); |
15606 return clone.raw(); | 15604 return clone.raw(); |
15607 } | 15605 } |
15608 | 15606 |
15609 | 15607 |
15610 RawAbstractType* Type::CloneUninstantiated(const Class& new_owner, | 15608 RawAbstractType* Type::CloneUninstantiated(const Class& new_owner, |
15611 GrowableObjectArray* trail) const { | 15609 TrailPtr trail) const { |
15612 ASSERT(IsFinalized()); | 15610 ASSERT(IsFinalized()); |
15613 ASSERT(!IsMalformed()); | 15611 ASSERT(!IsMalformed()); |
15614 if (IsInstantiated()) { | 15612 if (IsInstantiated()) { |
15615 return raw(); | 15613 return raw(); |
15616 } | 15614 } |
15617 // We may recursively encounter a type already being cloned, because we clone | 15615 // We may recursively encounter a type already being cloned, because we clone |
15618 // the upper bounds of its uninstantiated type arguments in the same pass. | 15616 // the upper bounds of its uninstantiated type arguments in the same pass. |
15619 Type& clone = Type::Handle(); | 15617 Type& clone = Type::Handle(); |
15620 clone ^= OnlyBuddyInTrail(trail); | 15618 clone ^= OnlyBuddyInTrail(trail); |
15621 if (!clone.IsNull()) { | 15619 if (!clone.IsNull()) { |
15622 return clone.raw(); | 15620 return clone.raw(); |
15623 } | 15621 } |
15624 const Class& type_cls = Class::Handle(type_class()); | 15622 const Class& type_cls = Class::Handle(type_class()); |
15625 clone = Type::New(type_cls, TypeArguments::Handle(), token_pos()); | 15623 clone = Type::New(type_cls, TypeArguments::Handle(), token_pos()); |
15626 TypeArguments& type_args = TypeArguments::Handle(arguments()); | 15624 TypeArguments& type_args = TypeArguments::Handle(arguments()); |
15627 // Upper bounds of uninstantiated type arguments may form a cycle. | 15625 // Upper bounds of uninstantiated type arguments may form a cycle. |
15628 if (type_args.IsRecursive() || !type_args.IsInstantiated()) { | 15626 if (type_args.IsRecursive() || !type_args.IsInstantiated()) { |
15629 AddOnlyBuddyToTrail(&trail, clone); | 15627 AddOnlyBuddyToTrail(&trail, clone); |
15630 } | 15628 } |
15631 type_args = type_args.CloneUninstantiated(new_owner, trail); | 15629 type_args = type_args.CloneUninstantiated(new_owner, trail); |
15632 clone.set_arguments(type_args); | 15630 clone.set_arguments(type_args); |
15633 clone.SetIsFinalized(); | 15631 clone.SetIsFinalized(); |
15634 return clone.raw(); | 15632 return clone.raw(); |
15635 } | 15633 } |
15636 | 15634 |
15637 | 15635 |
15638 RawAbstractType* Type::Canonicalize(GrowableObjectArray* trail) const { | 15636 RawAbstractType* Type::Canonicalize(TrailPtr trail) const { |
15639 ASSERT(IsFinalized()); | 15637 ASSERT(IsFinalized()); |
15640 if (IsCanonical() || IsMalformed()) { | 15638 if (IsCanonical() || IsMalformed()) { |
15641 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); | 15639 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); |
15642 return this->raw(); | 15640 return this->raw(); |
15643 } | 15641 } |
15644 Isolate* isolate = Isolate::Current(); | 15642 Isolate* isolate = Isolate::Current(); |
15645 Type& type = Type::Handle(isolate); | 15643 Type& type = Type::Handle(isolate); |
15646 const Class& cls = Class::Handle(isolate, type_class()); | 15644 const Class& cls = Class::Handle(isolate, type_class()); |
15647 if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) { | 15645 if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) { |
15648 return Object::dynamic_type(); | 15646 return Object::dynamic_type(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15876 if (ref) { | 15874 if (ref) { |
15877 return; | 15875 return; |
15878 } | 15876 } |
15879 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 15877 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); |
15880 if (!typeArgs.IsNull()) { | 15878 if (!typeArgs.IsNull()) { |
15881 jsobj.AddProperty("typeArguments", typeArgs); | 15879 jsobj.AddProperty("typeArguments", typeArgs); |
15882 } | 15880 } |
15883 } | 15881 } |
15884 | 15882 |
15885 | 15883 |
15886 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { | 15884 bool TypeRef::IsInstantiated(TrailPtr trail) const { |
15887 if (TestAndAddToTrail(&trail)) { | 15885 if (TestAndAddToTrail(&trail)) { |
15888 return true; | 15886 return true; |
15889 } | 15887 } |
15890 return AbstractType::Handle(type()).IsInstantiated(trail); | 15888 return AbstractType::Handle(type()).IsInstantiated(trail); |
15891 } | 15889 } |
15892 | 15890 |
15893 | 15891 |
15894 bool TypeRef::IsEquivalent(const Instance& other, | 15892 bool TypeRef::IsEquivalent(const Instance& other, TrailPtr trail) const { |
15895 GrowableObjectArray* trail) const { | |
15896 if (raw() == other.raw()) { | 15893 if (raw() == other.raw()) { |
15897 return true; | 15894 return true; |
15898 } | 15895 } |
15899 if (TestAndAddBuddyToTrail(&trail, other)) { | 15896 if (TestAndAddBuddyToTrail(&trail, other)) { |
15900 return true; | 15897 return true; |
15901 } | 15898 } |
15902 return AbstractType::Handle(type()).IsEquivalent(other, trail); | 15899 return AbstractType::Handle(type()).IsEquivalent(other, trail); |
15903 } | 15900 } |
15904 | 15901 |
15905 | 15902 |
15906 RawTypeRef* TypeRef::InstantiateFrom( | 15903 RawTypeRef* TypeRef::InstantiateFrom( |
15907 const TypeArguments& instantiator_type_arguments, | 15904 const TypeArguments& instantiator_type_arguments, |
15908 Error* bound_error, | 15905 Error* bound_error, |
15909 GrowableObjectArray* trail) const { | 15906 TrailPtr trail) const { |
15910 TypeRef& instantiated_type_ref = TypeRef::Handle(); | 15907 TypeRef& instantiated_type_ref = TypeRef::Handle(); |
15911 instantiated_type_ref ^= OnlyBuddyInTrail(trail); | 15908 instantiated_type_ref ^= OnlyBuddyInTrail(trail); |
15912 if (!instantiated_type_ref.IsNull()) { | 15909 if (!instantiated_type_ref.IsNull()) { |
15913 return instantiated_type_ref.raw(); | 15910 return instantiated_type_ref.raw(); |
15914 } | 15911 } |
15915 AbstractType& ref_type = AbstractType::Handle(type()); | 15912 AbstractType& ref_type = AbstractType::Handle(type()); |
15916 ASSERT(!ref_type.IsTypeRef()); | 15913 ASSERT(!ref_type.IsTypeRef()); |
15917 AbstractType& instantiated_ref_type = AbstractType::Handle(); | 15914 AbstractType& instantiated_ref_type = AbstractType::Handle(); |
15918 instantiated_ref_type = ref_type.InstantiateFrom( | 15915 instantiated_ref_type = ref_type.InstantiateFrom( |
15919 instantiator_type_arguments, bound_error, trail); | 15916 instantiator_type_arguments, bound_error, trail); |
15920 ASSERT(!instantiated_ref_type.IsTypeRef()); | 15917 ASSERT(!instantiated_ref_type.IsTypeRef()); |
15921 instantiated_type_ref = TypeRef::New(instantiated_ref_type); | 15918 instantiated_type_ref = TypeRef::New(instantiated_ref_type); |
15922 AddOnlyBuddyToTrail(&trail, instantiated_type_ref); | 15919 AddOnlyBuddyToTrail(&trail, instantiated_type_ref); |
15923 return instantiated_type_ref.raw(); | 15920 return instantiated_type_ref.raw(); |
15924 } | 15921 } |
15925 | 15922 |
15926 | 15923 |
15927 RawTypeRef* TypeRef::CloneUninstantiated(const Class& new_owner, | 15924 RawTypeRef* TypeRef::CloneUninstantiated(const Class& new_owner, |
15928 GrowableObjectArray* trail) const { | 15925 TrailPtr trail) const { |
15929 TypeRef& cloned_type_ref = TypeRef::Handle(); | 15926 TypeRef& cloned_type_ref = TypeRef::Handle(); |
15930 cloned_type_ref ^= OnlyBuddyInTrail(trail); | 15927 cloned_type_ref ^= OnlyBuddyInTrail(trail); |
15931 if (!cloned_type_ref.IsNull()) { | 15928 if (!cloned_type_ref.IsNull()) { |
15932 return cloned_type_ref.raw(); | 15929 return cloned_type_ref.raw(); |
15933 } | 15930 } |
15934 AbstractType& ref_type = AbstractType::Handle(type()); | 15931 AbstractType& ref_type = AbstractType::Handle(type()); |
15935 ASSERT(!ref_type.IsTypeRef()); | 15932 ASSERT(!ref_type.IsTypeRef()); |
15936 AbstractType& cloned_ref_type = AbstractType::Handle(); | 15933 AbstractType& cloned_ref_type = AbstractType::Handle(); |
15937 cloned_ref_type = ref_type.CloneUninstantiated(new_owner, trail); | 15934 cloned_ref_type = ref_type.CloneUninstantiated(new_owner, trail); |
15938 ASSERT(!cloned_ref_type.IsTypeRef()); | 15935 ASSERT(!cloned_ref_type.IsTypeRef()); |
15939 cloned_type_ref = TypeRef::New(cloned_ref_type); | 15936 cloned_type_ref = TypeRef::New(cloned_ref_type); |
15940 AddOnlyBuddyToTrail(&trail, cloned_type_ref); | 15937 AddOnlyBuddyToTrail(&trail, cloned_type_ref); |
15941 return cloned_type_ref.raw(); | 15938 return cloned_type_ref.raw(); |
15942 } | 15939 } |
15943 | 15940 |
15944 | 15941 |
15945 void TypeRef::set_type(const AbstractType& value) const { | 15942 void TypeRef::set_type(const AbstractType& value) const { |
15946 ASSERT(value.HasResolvedTypeClass()); | 15943 ASSERT(value.HasResolvedTypeClass()); |
15947 ASSERT(!value.IsTypeRef()); | 15944 ASSERT(!value.IsTypeRef()); |
15948 StorePointer(&raw_ptr()->type_, value.raw()); | 15945 StorePointer(&raw_ptr()->type_, value.raw()); |
15949 } | 15946 } |
15950 | 15947 |
15951 | 15948 |
15952 // A TypeRef cannot be canonical by definition. Only its referenced type can be. | 15949 // A TypeRef cannot be canonical by definition. Only its referenced type can be. |
15953 // Consider the type Derived, where class Derived extends Base<Derived>. | 15950 // Consider the type Derived, where class Derived extends Base<Derived>. |
15954 // The first type argument of its flattened type argument vector is Derived, | 15951 // The first type argument of its flattened type argument vector is Derived, |
15955 // represented by a TypeRef pointing to itself. | 15952 // represented by a TypeRef pointing to itself. |
15956 RawAbstractType* TypeRef::Canonicalize(GrowableObjectArray* trail) const { | 15953 RawAbstractType* TypeRef::Canonicalize(TrailPtr trail) const { |
15957 if (TestAndAddToTrail(&trail)) { | 15954 if (TestAndAddToTrail(&trail)) { |
15958 return raw(); | 15955 return raw(); |
15959 } | 15956 } |
15960 // TODO(regis): Try to reduce the number of nodes required to represent the | 15957 // TODO(regis): Try to reduce the number of nodes required to represent the |
15961 // referenced recursive type. | 15958 // referenced recursive type. |
15962 AbstractType& ref_type = AbstractType::Handle(type()); | 15959 AbstractType& ref_type = AbstractType::Handle(type()); |
15963 ref_type = ref_type.Canonicalize(trail); | 15960 ref_type = ref_type.Canonicalize(trail); |
15964 set_type(ref_type); | 15961 set_type(ref_type); |
15965 return raw(); | 15962 return raw(); |
15966 } | 15963 } |
15967 | 15964 |
15968 | 15965 |
15969 intptr_t TypeRef::Hash() const { | 15966 intptr_t TypeRef::Hash() const { |
15970 // Do not calculate the hash of the referenced type to avoid divergence. | 15967 // Do not calculate the hash of the referenced type to avoid divergence. |
15971 const uint32_t result = | 15968 const uint32_t result = |
15972 Class::Handle(AbstractType::Handle(type()).type_class()).id(); | 15969 Class::Handle(AbstractType::Handle(type()).type_class()).id(); |
15973 return FinalizeHash(result); | 15970 return FinalizeHash(result); |
15974 } | 15971 } |
15975 | 15972 |
15976 | 15973 |
15977 bool TypeRef::TestAndAddToTrail(GrowableObjectArray** trail) const { | 15974 bool TypeRef::TestAndAddToTrail(TrailPtr* trail) const { |
15978 if (*trail == NULL) { | 15975 if (*trail == NULL) { |
15979 *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New()); | 15976 *trail = new Trail(); |
15980 } else { | 15977 } else { |
15981 const intptr_t len = (*trail)->Length(); | 15978 const intptr_t len = (*trail)->length(); |
15982 for (intptr_t i = 0; i < len; i++) { | 15979 for (intptr_t i = 0; i < len; i++) { |
15983 if ((*trail)->At(i) == this->raw()) { | 15980 if ((*trail)->At(i)->raw() == this->raw()) { |
15984 return true; | 15981 return true; |
15985 } | 15982 } |
15986 } | 15983 } |
15987 } | 15984 } |
15988 (*trail)->Add(*this); | 15985 AbstractType& t = AbstractType::ZoneHandle(this->raw()); |
15986 (*trail)->Add(&t); | |
15989 return false; | 15987 return false; |
15990 } | 15988 } |
15991 | 15989 |
15992 | 15990 |
15993 bool TypeRef::TestAndAddBuddyToTrail(GrowableObjectArray** trail, | 15991 bool TypeRef::TestAndAddBuddyToTrail(TrailPtr* trail, |
15994 const Object& buddy) const { | 15992 const Instance& buddy) const { |
regis
2015/08/27 02:30:26
AbstractType instead of Instance.
srdjan
2015/08/27 16:09:49
Done.
| |
15995 if (*trail == NULL) { | 15993 if (*trail == NULL) { |
15996 *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New()); | 15994 *trail = new Trail(); |
15997 } else { | 15995 } else { |
15998 const intptr_t len = (*trail)->Length(); | 15996 const intptr_t len = (*trail)->length(); |
15999 ASSERT((len % 2) == 0); | 15997 ASSERT((len % 2) == 0); |
16000 for (intptr_t i = 0; i < len; i += 2) { | 15998 for (intptr_t i = 0; i < len; i += 2) { |
16001 if (((*trail)->At(i) == this->raw()) && | 15999 if (((*trail)->At(i)->raw() == this->raw()) && |
16002 ((*trail)->At(i + 1) == buddy.raw())) { | 16000 ((*trail)->At(i + 1)->raw() == buddy.raw())) { |
16003 return true; | 16001 return true; |
16004 } | 16002 } |
16005 } | 16003 } |
16006 } | 16004 } |
16007 (*trail)->Add(*this); | 16005 AbstractType& t = AbstractType::ZoneHandle(this->raw()); |
16008 (*trail)->Add(buddy); | 16006 Instance& b = Instance::ZoneHandle(buddy.raw()); |
16007 (*trail)->Add(&t); | |
16008 (*trail)->Add(&b); | |
16009 return false; | 16009 return false; |
16010 } | 16010 } |
16011 | 16011 |
16012 | 16012 |
16013 RawTypeRef* TypeRef::New() { | 16013 RawTypeRef* TypeRef::New() { |
16014 RawObject* raw = Object::Allocate(TypeRef::kClassId, | 16014 RawObject* raw = Object::Allocate(TypeRef::kClassId, |
16015 TypeRef::InstanceSize(), | 16015 TypeRef::InstanceSize(), |
16016 Heap::kOld); | 16016 Heap::kOld); |
16017 return reinterpret_cast<RawTypeRef*>(raw); | 16017 return reinterpret_cast<RawTypeRef*>(raw); |
16018 } | 16018 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16061 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 16061 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
16062 } | 16062 } |
16063 | 16063 |
16064 | 16064 |
16065 void TypeParameter::set_is_finalized() const { | 16065 void TypeParameter::set_is_finalized() const { |
16066 ASSERT(!IsFinalized()); | 16066 ASSERT(!IsFinalized()); |
16067 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 16067 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
16068 } | 16068 } |
16069 | 16069 |
16070 | 16070 |
16071 bool TypeParameter::IsEquivalent(const Instance& other, | 16071 bool TypeParameter::IsEquivalent(const Instance& other, TrailPtr trail) const { |
16072 GrowableObjectArray* trail) const { | |
16073 if (raw() == other.raw()) { | 16072 if (raw() == other.raw()) { |
16074 return true; | 16073 return true; |
16075 } | 16074 } |
16076 if (other.IsTypeRef()) { | 16075 if (other.IsTypeRef()) { |
16077 // Unfold right hand type. Divergence is controlled by left hand type. | 16076 // Unfold right hand type. Divergence is controlled by left hand type. |
16078 const AbstractType& other_ref_type = AbstractType::Handle( | 16077 const AbstractType& other_ref_type = AbstractType::Handle( |
16079 TypeRef::Cast(other).type()); | 16078 TypeRef::Cast(other).type()); |
16080 ASSERT(!other_ref_type.IsTypeRef()); | 16079 ASSERT(!other_ref_type.IsTypeRef()); |
16081 return IsEquivalent(other_ref_type, trail); | 16080 return IsEquivalent(other_ref_type, trail); |
16082 } | 16081 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16114 | 16113 |
16115 | 16114 |
16116 void TypeParameter::set_bound(const AbstractType& value) const { | 16115 void TypeParameter::set_bound(const AbstractType& value) const { |
16117 StorePointer(&raw_ptr()->bound_, value.raw()); | 16116 StorePointer(&raw_ptr()->bound_, value.raw()); |
16118 } | 16117 } |
16119 | 16118 |
16120 | 16119 |
16121 RawAbstractType* TypeParameter::InstantiateFrom( | 16120 RawAbstractType* TypeParameter::InstantiateFrom( |
16122 const TypeArguments& instantiator_type_arguments, | 16121 const TypeArguments& instantiator_type_arguments, |
16123 Error* bound_error, | 16122 Error* bound_error, |
16124 GrowableObjectArray* trail) const { | 16123 TrailPtr trail) const { |
16125 ASSERT(IsFinalized()); | 16124 ASSERT(IsFinalized()); |
16126 if (instantiator_type_arguments.IsNull()) { | 16125 if (instantiator_type_arguments.IsNull()) { |
16127 return Type::DynamicType(); | 16126 return Type::DynamicType(); |
16128 } | 16127 } |
16129 const AbstractType& type_arg = AbstractType::Handle( | 16128 const AbstractType& type_arg = AbstractType::Handle( |
16130 instantiator_type_arguments.TypeAt(index())); | 16129 instantiator_type_arguments.TypeAt(index())); |
16131 // There is no need to canonicalize the instantiated type parameter, since all | 16130 // There is no need to canonicalize the instantiated type parameter, since all |
16132 // type arguments are canonicalized at type finalization time. It would be too | 16131 // type arguments are canonicalized at type finalization time. It would be too |
16133 // early to canonicalize the returned type argument here, since instantiation | 16132 // early to canonicalize the returned type argument here, since instantiation |
16134 // not only happens at run time, but also during type finalization. | 16133 // not only happens at run time, but also during type finalization. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16190 // No need to clone bound, as it is not part of the finalization state. | 16189 // No need to clone bound, as it is not part of the finalization state. |
16191 return TypeParameter::New(Class::Handle(parameterized_class()), | 16190 return TypeParameter::New(Class::Handle(parameterized_class()), |
16192 index(), | 16191 index(), |
16193 String::Handle(name()), | 16192 String::Handle(name()), |
16194 AbstractType::Handle(bound()), | 16193 AbstractType::Handle(bound()), |
16195 token_pos()); | 16194 token_pos()); |
16196 } | 16195 } |
16197 | 16196 |
16198 | 16197 |
16199 RawAbstractType* TypeParameter::CloneUninstantiated( | 16198 RawAbstractType* TypeParameter::CloneUninstantiated( |
16200 const Class& new_owner, | 16199 const Class& new_owner, TrailPtr trail) const { |
16201 GrowableObjectArray* trail) const { | |
16202 ASSERT(IsFinalized()); | 16200 ASSERT(IsFinalized()); |
16203 AbstractType& upper_bound = AbstractType::Handle(bound()); | 16201 AbstractType& upper_bound = AbstractType::Handle(bound()); |
16204 upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); | 16202 upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); |
16205 const Class& old_owner = Class::Handle(parameterized_class()); | 16203 const Class& old_owner = Class::Handle(parameterized_class()); |
16206 const intptr_t new_index = index() + | 16204 const intptr_t new_index = index() + |
16207 new_owner.NumTypeArguments() - old_owner.NumTypeArguments(); | 16205 new_owner.NumTypeArguments() - old_owner.NumTypeArguments(); |
16208 const TypeParameter& clone = TypeParameter::Handle( | 16206 const TypeParameter& clone = TypeParameter::Handle( |
16209 TypeParameter::New(new_owner, | 16207 TypeParameter::New(new_owner, |
16210 new_index, | 16208 new_index, |
16211 String::Handle(name()), | 16209 String::Handle(name()), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16314 bool BoundedType::IsMalformedOrMalbounded() const { | 16312 bool BoundedType::IsMalformedOrMalbounded() const { |
16315 return AbstractType::Handle(type()).IsMalformedOrMalbounded(); | 16313 return AbstractType::Handle(type()).IsMalformedOrMalbounded(); |
16316 } | 16314 } |
16317 | 16315 |
16318 | 16316 |
16319 RawLanguageError* BoundedType::error() const { | 16317 RawLanguageError* BoundedType::error() const { |
16320 return AbstractType::Handle(type()).error(); | 16318 return AbstractType::Handle(type()).error(); |
16321 } | 16319 } |
16322 | 16320 |
16323 | 16321 |
16324 bool BoundedType::IsEquivalent(const Instance& other, | 16322 bool BoundedType::IsEquivalent(const Instance& other, TrailPtr trail) const { |
16325 GrowableObjectArray* trail) const { | |
16326 // BoundedType are not canonicalized, because their bound may get finalized | 16323 // BoundedType are not canonicalized, because their bound may get finalized |
16327 // after the BoundedType is created and initialized. | 16324 // after the BoundedType is created and initialized. |
16328 if (raw() == other.raw()) { | 16325 if (raw() == other.raw()) { |
16329 return true; | 16326 return true; |
16330 } | 16327 } |
16331 if (other.IsTypeRef()) { | 16328 if (other.IsTypeRef()) { |
16332 // Unfold right hand type. Divergence is controlled by left hand type. | 16329 // Unfold right hand type. Divergence is controlled by left hand type. |
16333 const AbstractType& other_ref_type = AbstractType::Handle( | 16330 const AbstractType& other_ref_type = AbstractType::Handle( |
16334 TypeRef::Cast(other).type()); | 16331 TypeRef::Cast(other).type()); |
16335 ASSERT(!other_ref_type.IsTypeRef()); | 16332 ASSERT(!other_ref_type.IsTypeRef()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16379 // A null type parameter is set when marking a type malformed because of a | 16376 // A null type parameter is set when marking a type malformed because of a |
16380 // bound error at compile time. | 16377 // bound error at compile time. |
16381 ASSERT(value.IsNull() || value.IsFinalized()); | 16378 ASSERT(value.IsNull() || value.IsFinalized()); |
16382 StorePointer(&raw_ptr()->type_parameter_, value.raw()); | 16379 StorePointer(&raw_ptr()->type_parameter_, value.raw()); |
16383 } | 16380 } |
16384 | 16381 |
16385 | 16382 |
16386 RawAbstractType* BoundedType::InstantiateFrom( | 16383 RawAbstractType* BoundedType::InstantiateFrom( |
16387 const TypeArguments& instantiator_type_arguments, | 16384 const TypeArguments& instantiator_type_arguments, |
16388 Error* bound_error, | 16385 Error* bound_error, |
16389 GrowableObjectArray* trail) const { | 16386 TrailPtr trail) const { |
16390 ASSERT(IsFinalized()); | 16387 ASSERT(IsFinalized()); |
16391 AbstractType& bounded_type = AbstractType::Handle(type()); | 16388 AbstractType& bounded_type = AbstractType::Handle(type()); |
16392 ASSERT(bounded_type.IsFinalized()); | 16389 ASSERT(bounded_type.IsFinalized()); |
16393 if (!bounded_type.IsInstantiated()) { | 16390 if (!bounded_type.IsInstantiated()) { |
16394 bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, | 16391 bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, |
16395 bound_error, | 16392 bound_error, |
16396 trail); | 16393 trail); |
16397 // In case types of instantiator_type_arguments are not finalized, then | 16394 // In case types of instantiator_type_arguments are not finalized, then |
16398 // the instantiated bounded_type is not finalized either. | 16395 // the instantiated bounded_type is not finalized either. |
16399 // Note that instantiator_type_arguments must have the final length, though. | 16396 // Note that instantiator_type_arguments must have the final length, though. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16435 bounded_type = bounded_type.CloneUnfinalized(); | 16432 bounded_type = bounded_type.CloneUnfinalized(); |
16436 // No need to clone bound or type parameter, as they are not part of the | 16433 // No need to clone bound or type parameter, as they are not part of the |
16437 // finalization state of this bounded type. | 16434 // finalization state of this bounded type. |
16438 return BoundedType::New(bounded_type, | 16435 return BoundedType::New(bounded_type, |
16439 AbstractType::Handle(bound()), | 16436 AbstractType::Handle(bound()), |
16440 TypeParameter::Handle(type_parameter())); | 16437 TypeParameter::Handle(type_parameter())); |
16441 } | 16438 } |
16442 | 16439 |
16443 | 16440 |
16444 RawAbstractType* BoundedType::CloneUninstantiated( | 16441 RawAbstractType* BoundedType::CloneUninstantiated( |
16445 const Class& new_owner, | 16442 const Class& new_owner, TrailPtr trail) const { |
16446 GrowableObjectArray* trail) const { | |
16447 if (IsInstantiated()) { | 16443 if (IsInstantiated()) { |
16448 return raw(); | 16444 return raw(); |
16449 } | 16445 } |
16450 AbstractType& bounded_type = AbstractType::Handle(type()); | 16446 AbstractType& bounded_type = AbstractType::Handle(type()); |
16451 bounded_type = bounded_type.CloneUninstantiated(new_owner, trail); | 16447 bounded_type = bounded_type.CloneUninstantiated(new_owner, trail); |
16452 AbstractType& upper_bound = AbstractType::Handle(bound()); | 16448 AbstractType& upper_bound = AbstractType::Handle(bound()); |
16453 upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); | 16449 upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); |
16454 TypeParameter& type_param = TypeParameter::Handle(type_parameter()); | 16450 TypeParameter& type_param = TypeParameter::Handle(type_parameter()); |
16455 type_param ^= type_param.CloneUninstantiated(new_owner, trail); | 16451 type_param ^= type_param.CloneUninstantiated(new_owner, trail); |
16456 return BoundedType::New(bounded_type, upper_bound, type_param); | 16452 return BoundedType::New(bounded_type, upper_bound, type_param); |
(...skipping 4964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21421 return tag_label.ToCString(); | 21417 return tag_label.ToCString(); |
21422 } | 21418 } |
21423 | 21419 |
21424 | 21420 |
21425 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21421 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21426 Instance::PrintJSONImpl(stream, ref); | 21422 Instance::PrintJSONImpl(stream, ref); |
21427 } | 21423 } |
21428 | 21424 |
21429 | 21425 |
21430 } // namespace dart | 21426 } // namespace dart |
OLD | NEW |