| 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 9716 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14799 } | 14798 } | 
| 14800 | 14799 | 
| 14801 | 14800 | 
| 14802 intptr_t AbstractType::token_pos() const { | 14801 intptr_t AbstractType::token_pos() const { | 
| 14803   // AbstractType is an abstract class. | 14802   // AbstractType is an abstract class. | 
| 14804   UNREACHABLE(); | 14803   UNREACHABLE(); | 
| 14805   return -1; | 14804   return -1; | 
| 14806 } | 14805 } | 
| 14807 | 14806 | 
| 14808 | 14807 | 
| 14809 bool AbstractType::IsInstantiated(GrowableObjectArray* trail) const { | 14808 bool AbstractType::IsInstantiated(TrailPtr trail) const { | 
| 14810   // AbstractType is an abstract class. | 14809   // AbstractType is an abstract class. | 
| 14811   UNREACHABLE(); | 14810   UNREACHABLE(); | 
| 14812   return false; | 14811   return false; | 
| 14813 } | 14812 } | 
| 14814 | 14813 | 
| 14815 | 14814 | 
| 14816 bool AbstractType::IsFinalized() const { | 14815 bool AbstractType::IsFinalized() const { | 
| 14817   // AbstractType is an abstract class. | 14816   // AbstractType is an abstract class. | 
| 14818   UNREACHABLE(); | 14817   UNREACHABLE(); | 
| 14819   return false; | 14818   return false; | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14854   return LanguageError::null(); | 14853   return LanguageError::null(); | 
| 14855 } | 14854 } | 
| 14856 | 14855 | 
| 14857 | 14856 | 
| 14858 void AbstractType::set_error(const LanguageError& value) const { | 14857 void AbstractType::set_error(const LanguageError& value) const { | 
| 14859   // AbstractType is an abstract class. | 14858   // AbstractType is an abstract class. | 
| 14860   UNREACHABLE(); | 14859   UNREACHABLE(); | 
| 14861 } | 14860 } | 
| 14862 | 14861 | 
| 14863 | 14862 | 
| 14864 bool AbstractType::IsEquivalent(const Instance& other, | 14863 bool AbstractType::IsEquivalent(const Instance& other, TrailPtr trail) const { | 
| 14865                                 GrowableObjectArray* trail) const { |  | 
| 14866   // AbstractType is an abstract class. | 14864   // AbstractType is an abstract class. | 
| 14867   UNREACHABLE(); | 14865   UNREACHABLE(); | 
| 14868   return false; | 14866   return false; | 
| 14869 } | 14867 } | 
| 14870 | 14868 | 
| 14871 | 14869 | 
| 14872 bool AbstractType::IsRecursive() const { | 14870 bool AbstractType::IsRecursive() const { | 
| 14873   // AbstractType is an abstract class. | 14871   // AbstractType is an abstract class. | 
| 14874   UNREACHABLE(); | 14872   UNREACHABLE(); | 
| 14875   return false; | 14873   return false; | 
| 14876 } | 14874 } | 
| 14877 | 14875 | 
| 14878 | 14876 | 
| 14879 RawAbstractType* AbstractType::InstantiateFrom( | 14877 RawAbstractType* AbstractType::InstantiateFrom( | 
| 14880     const TypeArguments& instantiator_type_arguments, | 14878     const TypeArguments& instantiator_type_arguments, | 
| 14881     Error* bound_error, | 14879     Error* bound_error, | 
| 14882     GrowableObjectArray* trail) const { | 14880     TrailPtr trail) const { | 
| 14883   // AbstractType is an abstract class. | 14881   // AbstractType is an abstract class. | 
| 14884   UNREACHABLE(); | 14882   UNREACHABLE(); | 
| 14885   return NULL; | 14883   return NULL; | 
| 14886 } | 14884 } | 
| 14887 | 14885 | 
| 14888 | 14886 | 
| 14889 RawAbstractType* AbstractType::CloneUnfinalized() const { | 14887 RawAbstractType* AbstractType::CloneUnfinalized() const { | 
| 14890   // AbstractType is an abstract class. | 14888   // AbstractType is an abstract class. | 
| 14891   UNREACHABLE(); | 14889   UNREACHABLE(); | 
| 14892   return NULL; | 14890   return NULL; | 
| 14893 } | 14891 } | 
| 14894 | 14892 | 
| 14895 | 14893 | 
| 14896 RawAbstractType* AbstractType::CloneUninstantiated( | 14894 RawAbstractType* AbstractType::CloneUninstantiated( | 
| 14897     const Class& new_owner, | 14895     const Class& new_owner, TrailPtr trail) const { | 
| 14898     GrowableObjectArray* trail) const { |  | 
| 14899   // AbstractType is an abstract class. | 14896   // AbstractType is an abstract class. | 
| 14900   UNREACHABLE(); | 14897   UNREACHABLE(); | 
| 14901   return NULL; | 14898   return NULL; | 
| 14902 } | 14899 } | 
| 14903 | 14900 | 
| 14904 | 14901 | 
| 14905 RawAbstractType* AbstractType::Canonicalize(GrowableObjectArray* trail) const { | 14902 RawAbstractType* AbstractType::Canonicalize(TrailPtr trail) const { | 
| 14906   // AbstractType is an abstract class. | 14903   // AbstractType is an abstract class. | 
| 14907   UNREACHABLE(); | 14904   UNREACHABLE(); | 
| 14908   return NULL; | 14905   return NULL; | 
| 14909 } | 14906 } | 
| 14910 | 14907 | 
| 14911 | 14908 | 
| 14912 RawObject* AbstractType::OnlyBuddyInTrail(GrowableObjectArray* trail) const { | 14909 RawAbstractType* AbstractType::OnlyBuddyInTrail(TrailPtr trail) const { | 
| 14913   if (trail == NULL) { | 14910   if (trail == NULL) { | 
| 14914     return Object::null(); | 14911     return AbstractType::null(); | 
| 14915   } | 14912   } | 
| 14916   const intptr_t len = trail->Length(); | 14913   const intptr_t len = trail->length(); | 
| 14917   ASSERT((len % 2) == 0); | 14914   ASSERT((len % 2) == 0); | 
| 14918   for (intptr_t i = 0; i < len; i += 2) { | 14915   for (intptr_t i = 0; i < len; i += 2) { | 
| 14919     if (trail->At(i) == this->raw()) { | 14916     ASSERT(trail->At(i)->IsZoneHandle()); | 
| 14920       ASSERT(trail->At(i + 1) != Object::null()); | 14917     ASSERT(trail->At(i + 1)->IsZoneHandle()); | 
| 14921       return trail->At(i + 1); | 14918     if (trail->At(i)->raw() == this->raw()) { | 
|  | 14919       ASSERT(!trail->At(i + 1)->IsNull()); | 
|  | 14920       return trail->At(i + 1)->raw(); | 
| 14922     } | 14921     } | 
| 14923   } | 14922   } | 
| 14924   return Object::null(); | 14923   return AbstractType::null(); | 
| 14925 } | 14924 } | 
| 14926 | 14925 | 
| 14927 | 14926 | 
| 14928 void AbstractType::AddOnlyBuddyToTrail(GrowableObjectArray** trail, | 14927 void AbstractType::AddOnlyBuddyToTrail(TrailPtr* trail, | 
| 14929                                        const Object& buddy) const { | 14928                                        const AbstractType& buddy) const { | 
| 14930   if (*trail == NULL) { | 14929   if (*trail == NULL) { | 
| 14931     *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New()); | 14930     *trail = new Trail(4); | 
| 14932   } else { | 14931   } else { | 
| 14933     ASSERT(OnlyBuddyInTrail(*trail) == Object::null()); | 14932     ASSERT(OnlyBuddyInTrail(*trail) == AbstractType::null()); | 
| 14934   } | 14933   } | 
| 14935   (*trail)->Add(*this); | 14934   AbstractType& t = AbstractType::ZoneHandle(this->raw()); | 
| 14936   (*trail)->Add(buddy); | 14935   AbstractType& b = AbstractType::ZoneHandle(buddy.raw()); | 
|  | 14936   (*trail)->Add(&t); | 
|  | 14937   (*trail)->Add(&b); | 
| 14937 } | 14938 } | 
| 14938 | 14939 | 
| 14939 | 14940 | 
| 14940 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { | 14941 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { | 
| 14941   if (IsBoundedType()) { | 14942   if (IsBoundedType()) { | 
| 14942     const AbstractType& type = AbstractType::Handle( | 14943     const AbstractType& type = AbstractType::Handle( | 
| 14943         BoundedType::Cast(*this).type()); | 14944         BoundedType::Cast(*this).type()); | 
| 14944     if (name_visibility == kPrettyName) { | 14945     if (name_visibility == kPrettyName) { | 
| 14945       return type.BuildName(kPrettyName); | 14946       return type.BuildName(kPrettyName); | 
| 14946     } else if (name_visibility == kUserVisibleName) { | 14947     } else if (name_visibility == kUserVisibleName) { | 
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 15431   return reinterpret_cast<RawUnresolvedClass*>(raw_ptr()->type_class_); | 15432   return reinterpret_cast<RawUnresolvedClass*>(raw_ptr()->type_class_); | 
| 15432 #endif | 15433 #endif | 
| 15433 } | 15434 } | 
| 15434 | 15435 | 
| 15435 | 15436 | 
| 15436 RawTypeArguments* Type::arguments() const { | 15437 RawTypeArguments* Type::arguments() const { | 
| 15437   return raw_ptr()->arguments_; | 15438   return raw_ptr()->arguments_; | 
| 15438 } | 15439 } | 
| 15439 | 15440 | 
| 15440 | 15441 | 
| 15441 bool Type::IsInstantiated(GrowableObjectArray* trail) const { | 15442 bool Type::IsInstantiated(TrailPtr trail) const { | 
| 15442   if (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) { | 15443   if (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) { | 
| 15443     return true; | 15444     return true; | 
| 15444   } | 15445   } | 
| 15445   if (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated) { | 15446   if (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated) { | 
| 15446     return false; | 15447     return false; | 
| 15447   } | 15448   } | 
| 15448   if (arguments() == TypeArguments::null()) { | 15449   if (arguments() == TypeArguments::null()) { | 
| 15449     return true; | 15450     return true; | 
| 15450   } | 15451   } | 
| 15451   const TypeArguments& args = TypeArguments::Handle(arguments()); | 15452   const TypeArguments& args = TypeArguments::Handle(arguments()); | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 15465     num_type_args = len; | 15466     num_type_args = len; | 
| 15466     len = cls.NumTypeParameters();  // Check the type parameters only. | 15467     len = cls.NumTypeParameters();  // Check the type parameters only. | 
| 15467   } | 15468   } | 
| 15468   return (len == 0) || args.IsSubvectorInstantiated(num_type_args - len, len); | 15469   return (len == 0) || args.IsSubvectorInstantiated(num_type_args - len, len); | 
| 15469 } | 15470 } | 
| 15470 | 15471 | 
| 15471 | 15472 | 
| 15472 RawAbstractType* Type::InstantiateFrom( | 15473 RawAbstractType* Type::InstantiateFrom( | 
| 15473     const TypeArguments& instantiator_type_arguments, | 15474     const TypeArguments& instantiator_type_arguments, | 
| 15474     Error* bound_error, | 15475     Error* bound_error, | 
| 15475     GrowableObjectArray* trail) const { | 15476     TrailPtr trail) const { | 
| 15476   ASSERT(IsFinalized() || IsBeingFinalized()); | 15477   ASSERT(IsFinalized() || IsBeingFinalized()); | 
| 15477   ASSERT(!IsInstantiated()); | 15478   ASSERT(!IsInstantiated()); | 
| 15478   // Return the uninstantiated type unchanged if malformed. No copy needed. | 15479   // Return the uninstantiated type unchanged if malformed. No copy needed. | 
| 15479   if (IsMalformed()) { | 15480   if (IsMalformed()) { | 
| 15480     return raw(); | 15481     return raw(); | 
| 15481   } | 15482   } | 
| 15482   // Instantiating this type with its own type arguments as instantiator can | 15483   // Instantiating this type with its own type arguments as instantiator can | 
| 15483   // occur during finalization and bounds checking. Return the type unchanged. | 15484   // occur during finalization and bounds checking. Return the type unchanged. | 
| 15484   if (arguments() == instantiator_type_arguments.raw()) { | 15485   if (arguments() == instantiator_type_arguments.raw()) { | 
| 15485     return raw(); | 15486     return raw(); | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 15511   if (IsFinalized()) { | 15512   if (IsFinalized()) { | 
| 15512     instantiated_type.SetIsFinalized(); | 15513     instantiated_type.SetIsFinalized(); | 
| 15513   } else { | 15514   } else { | 
| 15514     instantiated_type.set_is_resolved(); | 15515     instantiated_type.set_is_resolved(); | 
| 15515   } | 15516   } | 
| 15516   // Canonicalization is not part of instantiation. | 15517   // Canonicalization is not part of instantiation. | 
| 15517   return instantiated_type.raw(); | 15518   return instantiated_type.raw(); | 
| 15518 } | 15519 } | 
| 15519 | 15520 | 
| 15520 | 15521 | 
| 15521 bool Type::IsEquivalent(const Instance& other, | 15522 bool Type::IsEquivalent(const Instance& other, TrailPtr trail) const { | 
| 15522                         GrowableObjectArray* trail) const { |  | 
| 15523   ASSERT(!IsNull()); | 15523   ASSERT(!IsNull()); | 
| 15524   if (raw() == other.raw()) { | 15524   if (raw() == other.raw()) { | 
| 15525     return true; | 15525     return true; | 
| 15526   } | 15526   } | 
| 15527   if (other.IsTypeRef()) { | 15527   if (other.IsTypeRef()) { | 
| 15528     // Unfold right hand type. Divergence is controlled by left hand type. | 15528     // Unfold right hand type. Divergence is controlled by left hand type. | 
| 15529     const AbstractType& other_ref_type = AbstractType::Handle( | 15529     const AbstractType& other_ref_type = AbstractType::Handle( | 
| 15530         TypeRef::Cast(other).type()); | 15530         TypeRef::Cast(other).type()); | 
| 15531     ASSERT(!other_ref_type.IsTypeRef()); | 15531     ASSERT(!other_ref_type.IsTypeRef()); | 
| 15532     return IsEquivalent(other_ref_type, trail); | 15532     return IsEquivalent(other_ref_type, trail); | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 15607   TypeArguments& type_args = TypeArguments::Handle(arguments()); | 15607   TypeArguments& type_args = TypeArguments::Handle(arguments()); | 
| 15608   type_args = type_args.CloneUnfinalized(); | 15608   type_args = type_args.CloneUnfinalized(); | 
| 15609   const Class& type_cls = Class::Handle(type_class()); | 15609   const Class& type_cls = Class::Handle(type_class()); | 
| 15610   const Type& clone = Type::Handle(Type::New(type_cls, type_args, token_pos())); | 15610   const Type& clone = Type::Handle(Type::New(type_cls, type_args, token_pos())); | 
| 15611   clone.set_is_resolved(); | 15611   clone.set_is_resolved(); | 
| 15612   return clone.raw(); | 15612   return clone.raw(); | 
| 15613 } | 15613 } | 
| 15614 | 15614 | 
| 15615 | 15615 | 
| 15616 RawAbstractType* Type::CloneUninstantiated(const Class& new_owner, | 15616 RawAbstractType* Type::CloneUninstantiated(const Class& new_owner, | 
| 15617                                            GrowableObjectArray* trail) const { | 15617                                            TrailPtr trail) const { | 
| 15618   ASSERT(IsFinalized()); | 15618   ASSERT(IsFinalized()); | 
| 15619   ASSERT(!IsMalformed()); | 15619   ASSERT(!IsMalformed()); | 
| 15620   if (IsInstantiated()) { | 15620   if (IsInstantiated()) { | 
| 15621     return raw(); | 15621     return raw(); | 
| 15622   } | 15622   } | 
| 15623   // We may recursively encounter a type already being cloned, because we clone | 15623   // We may recursively encounter a type already being cloned, because we clone | 
| 15624   // the upper bounds of its uninstantiated type arguments in the same pass. | 15624   // the upper bounds of its uninstantiated type arguments in the same pass. | 
| 15625   Type& clone = Type::Handle(); | 15625   Type& clone = Type::Handle(); | 
| 15626   clone ^= OnlyBuddyInTrail(trail); | 15626   clone ^= OnlyBuddyInTrail(trail); | 
| 15627   if (!clone.IsNull()) { | 15627   if (!clone.IsNull()) { | 
| 15628     return clone.raw(); | 15628     return clone.raw(); | 
| 15629   } | 15629   } | 
| 15630   const Class& type_cls = Class::Handle(type_class()); | 15630   const Class& type_cls = Class::Handle(type_class()); | 
| 15631   clone = Type::New(type_cls, TypeArguments::Handle(), token_pos()); | 15631   clone = Type::New(type_cls, TypeArguments::Handle(), token_pos()); | 
| 15632   TypeArguments& type_args = TypeArguments::Handle(arguments()); | 15632   TypeArguments& type_args = TypeArguments::Handle(arguments()); | 
| 15633   // Upper bounds of uninstantiated type arguments may form a cycle. | 15633   // Upper bounds of uninstantiated type arguments may form a cycle. | 
| 15634   if (type_args.IsRecursive() || !type_args.IsInstantiated()) { | 15634   if (type_args.IsRecursive() || !type_args.IsInstantiated()) { | 
| 15635     AddOnlyBuddyToTrail(&trail, clone); | 15635     AddOnlyBuddyToTrail(&trail, clone); | 
| 15636   } | 15636   } | 
| 15637   type_args = type_args.CloneUninstantiated(new_owner, trail); | 15637   type_args = type_args.CloneUninstantiated(new_owner, trail); | 
| 15638   clone.set_arguments(type_args); | 15638   clone.set_arguments(type_args); | 
| 15639   clone.SetIsFinalized(); | 15639   clone.SetIsFinalized(); | 
| 15640   return clone.raw(); | 15640   return clone.raw(); | 
| 15641 } | 15641 } | 
| 15642 | 15642 | 
| 15643 | 15643 | 
| 15644 RawAbstractType* Type::Canonicalize(GrowableObjectArray* trail) const { | 15644 RawAbstractType* Type::Canonicalize(TrailPtr trail) const { | 
| 15645   ASSERT(IsFinalized()); | 15645   ASSERT(IsFinalized()); | 
| 15646   if (IsCanonical() || IsMalformed()) { | 15646   if (IsCanonical() || IsMalformed()) { | 
| 15647     ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); | 15647     ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); | 
| 15648     return this->raw(); | 15648     return this->raw(); | 
| 15649   } | 15649   } | 
| 15650   Isolate* isolate = Isolate::Current(); | 15650   Isolate* isolate = Isolate::Current(); | 
| 15651   Type& type = Type::Handle(isolate); | 15651   Type& type = Type::Handle(isolate); | 
| 15652   const Class& cls = Class::Handle(isolate, type_class()); | 15652   const Class& cls = Class::Handle(isolate, type_class()); | 
| 15653   if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) { | 15653   if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) { | 
| 15654     return Object::dynamic_type(); | 15654     return Object::dynamic_type(); | 
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 15882   if (ref) { | 15882   if (ref) { | 
| 15883     return; | 15883     return; | 
| 15884   } | 15884   } | 
| 15885   const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 15885   const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 
| 15886   if (!typeArgs.IsNull()) { | 15886   if (!typeArgs.IsNull()) { | 
| 15887     jsobj.AddProperty("typeArguments", typeArgs); | 15887     jsobj.AddProperty("typeArguments", typeArgs); | 
| 15888   } | 15888   } | 
| 15889 } | 15889 } | 
| 15890 | 15890 | 
| 15891 | 15891 | 
| 15892 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { | 15892 bool TypeRef::IsInstantiated(TrailPtr trail) const { | 
| 15893   if (TestAndAddToTrail(&trail)) { | 15893   if (TestAndAddToTrail(&trail)) { | 
| 15894     return true; | 15894     return true; | 
| 15895   } | 15895   } | 
| 15896   return AbstractType::Handle(type()).IsInstantiated(trail); | 15896   return AbstractType::Handle(type()).IsInstantiated(trail); | 
| 15897 } | 15897 } | 
| 15898 | 15898 | 
| 15899 | 15899 | 
| 15900 bool TypeRef::IsEquivalent(const Instance& other, | 15900 bool TypeRef::IsEquivalent(const Instance& other, TrailPtr trail) const { | 
| 15901                            GrowableObjectArray* trail) const { |  | 
| 15902   if (raw() == other.raw()) { | 15901   if (raw() == other.raw()) { | 
| 15903     return true; | 15902     return true; | 
| 15904   } | 15903   } | 
| 15905   if (TestAndAddBuddyToTrail(&trail, other)) { | 15904   if (!other.IsAbstractType()) { | 
|  | 15905     return false; | 
|  | 15906   } | 
|  | 15907   if (TestAndAddBuddyToTrail(&trail, AbstractType::Cast(other))) { | 
| 15906     return true; | 15908     return true; | 
| 15907   } | 15909   } | 
| 15908   return AbstractType::Handle(type()).IsEquivalent(other, trail); | 15910   return AbstractType::Handle(type()).IsEquivalent(other, trail); | 
| 15909 } | 15911 } | 
| 15910 | 15912 | 
| 15911 | 15913 | 
| 15912 RawTypeRef* TypeRef::InstantiateFrom( | 15914 RawTypeRef* TypeRef::InstantiateFrom( | 
| 15913     const TypeArguments& instantiator_type_arguments, | 15915     const TypeArguments& instantiator_type_arguments, | 
| 15914     Error* bound_error, | 15916     Error* bound_error, | 
| 15915     GrowableObjectArray* trail) const { | 15917     TrailPtr trail) const { | 
| 15916   TypeRef& instantiated_type_ref = TypeRef::Handle(); | 15918   TypeRef& instantiated_type_ref = TypeRef::Handle(); | 
| 15917   instantiated_type_ref ^= OnlyBuddyInTrail(trail); | 15919   instantiated_type_ref ^= OnlyBuddyInTrail(trail); | 
| 15918   if (!instantiated_type_ref.IsNull()) { | 15920   if (!instantiated_type_ref.IsNull()) { | 
| 15919     return instantiated_type_ref.raw(); | 15921     return instantiated_type_ref.raw(); | 
| 15920   } | 15922   } | 
| 15921   AbstractType& ref_type = AbstractType::Handle(type()); | 15923   AbstractType& ref_type = AbstractType::Handle(type()); | 
| 15922   ASSERT(!ref_type.IsTypeRef()); | 15924   ASSERT(!ref_type.IsTypeRef()); | 
| 15923   AbstractType& instantiated_ref_type = AbstractType::Handle(); | 15925   AbstractType& instantiated_ref_type = AbstractType::Handle(); | 
| 15924   instantiated_ref_type = ref_type.InstantiateFrom( | 15926   instantiated_ref_type = ref_type.InstantiateFrom( | 
| 15925       instantiator_type_arguments, bound_error, trail); | 15927       instantiator_type_arguments, bound_error, trail); | 
| 15926   ASSERT(!instantiated_ref_type.IsTypeRef()); | 15928   ASSERT(!instantiated_ref_type.IsTypeRef()); | 
| 15927   instantiated_type_ref = TypeRef::New(instantiated_ref_type); | 15929   instantiated_type_ref = TypeRef::New(instantiated_ref_type); | 
| 15928   AddOnlyBuddyToTrail(&trail, instantiated_type_ref); | 15930   AddOnlyBuddyToTrail(&trail, instantiated_type_ref); | 
| 15929   return instantiated_type_ref.raw(); | 15931   return instantiated_type_ref.raw(); | 
| 15930 } | 15932 } | 
| 15931 | 15933 | 
| 15932 | 15934 | 
| 15933 RawTypeRef* TypeRef::CloneUninstantiated(const Class& new_owner, | 15935 RawTypeRef* TypeRef::CloneUninstantiated(const Class& new_owner, | 
| 15934                                          GrowableObjectArray* trail) const { | 15936                                          TrailPtr trail) const { | 
| 15935   TypeRef& cloned_type_ref = TypeRef::Handle(); | 15937   TypeRef& cloned_type_ref = TypeRef::Handle(); | 
| 15936   cloned_type_ref ^= OnlyBuddyInTrail(trail); | 15938   cloned_type_ref ^= OnlyBuddyInTrail(trail); | 
| 15937   if (!cloned_type_ref.IsNull()) { | 15939   if (!cloned_type_ref.IsNull()) { | 
| 15938     return cloned_type_ref.raw(); | 15940     return cloned_type_ref.raw(); | 
| 15939   } | 15941   } | 
| 15940   AbstractType& ref_type = AbstractType::Handle(type()); | 15942   AbstractType& ref_type = AbstractType::Handle(type()); | 
| 15941   ASSERT(!ref_type.IsTypeRef()); | 15943   ASSERT(!ref_type.IsTypeRef()); | 
| 15942   AbstractType& cloned_ref_type = AbstractType::Handle(); | 15944   AbstractType& cloned_ref_type = AbstractType::Handle(); | 
| 15943   cloned_ref_type = ref_type.CloneUninstantiated(new_owner, trail); | 15945   cloned_ref_type = ref_type.CloneUninstantiated(new_owner, trail); | 
| 15944   ASSERT(!cloned_ref_type.IsTypeRef()); | 15946   ASSERT(!cloned_ref_type.IsTypeRef()); | 
| 15945   cloned_type_ref = TypeRef::New(cloned_ref_type); | 15947   cloned_type_ref = TypeRef::New(cloned_ref_type); | 
| 15946   AddOnlyBuddyToTrail(&trail, cloned_type_ref); | 15948   AddOnlyBuddyToTrail(&trail, cloned_type_ref); | 
| 15947   return cloned_type_ref.raw(); | 15949   return cloned_type_ref.raw(); | 
| 15948 } | 15950 } | 
| 15949 | 15951 | 
| 15950 | 15952 | 
| 15951 void TypeRef::set_type(const AbstractType& value) const { | 15953 void TypeRef::set_type(const AbstractType& value) const { | 
| 15952   ASSERT(value.HasResolvedTypeClass()); | 15954   ASSERT(value.HasResolvedTypeClass()); | 
| 15953   ASSERT(!value.IsTypeRef()); | 15955   ASSERT(!value.IsTypeRef()); | 
| 15954   StorePointer(&raw_ptr()->type_, value.raw()); | 15956   StorePointer(&raw_ptr()->type_, value.raw()); | 
| 15955 } | 15957 } | 
| 15956 | 15958 | 
| 15957 | 15959 | 
| 15958 // A TypeRef cannot be canonical by definition. Only its referenced type can be. | 15960 // A TypeRef cannot be canonical by definition. Only its referenced type can be. | 
| 15959 // Consider the type Derived, where class Derived extends Base<Derived>. | 15961 // Consider the type Derived, where class Derived extends Base<Derived>. | 
| 15960 // The first type argument of its flattened type argument vector is Derived, | 15962 // The first type argument of its flattened type argument vector is Derived, | 
| 15961 // represented by a TypeRef pointing to itself. | 15963 // represented by a TypeRef pointing to itself. | 
| 15962 RawAbstractType* TypeRef::Canonicalize(GrowableObjectArray* trail) const { | 15964 RawAbstractType* TypeRef::Canonicalize(TrailPtr trail) const { | 
| 15963   if (TestAndAddToTrail(&trail)) { | 15965   if (TestAndAddToTrail(&trail)) { | 
| 15964     return raw(); | 15966     return raw(); | 
| 15965   } | 15967   } | 
| 15966   // TODO(regis): Try to reduce the number of nodes required to represent the | 15968   // TODO(regis): Try to reduce the number of nodes required to represent the | 
| 15967   // referenced recursive type. | 15969   // referenced recursive type. | 
| 15968   AbstractType& ref_type = AbstractType::Handle(type()); | 15970   AbstractType& ref_type = AbstractType::Handle(type()); | 
| 15969   ref_type = ref_type.Canonicalize(trail); | 15971   ref_type = ref_type.Canonicalize(trail); | 
| 15970   set_type(ref_type); | 15972   set_type(ref_type); | 
| 15971   return raw(); | 15973   return raw(); | 
| 15972 } | 15974 } | 
| 15973 | 15975 | 
| 15974 | 15976 | 
| 15975 intptr_t TypeRef::Hash() const { | 15977 intptr_t TypeRef::Hash() const { | 
| 15976   // Do not calculate the hash of the referenced type to avoid divergence. | 15978   // Do not calculate the hash of the referenced type to avoid divergence. | 
| 15977   const uint32_t result = | 15979   const uint32_t result = | 
| 15978       Class::Handle(AbstractType::Handle(type()).type_class()).id(); | 15980       Class::Handle(AbstractType::Handle(type()).type_class()).id(); | 
| 15979   return FinalizeHash(result); | 15981   return FinalizeHash(result); | 
| 15980 } | 15982 } | 
| 15981 | 15983 | 
| 15982 | 15984 | 
| 15983 bool TypeRef::TestAndAddToTrail(GrowableObjectArray** trail) const { | 15985 bool TypeRef::TestAndAddToTrail(TrailPtr* trail) const { | 
| 15984   if (*trail == NULL) { | 15986   if (*trail == NULL) { | 
| 15985     *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New()); | 15987     *trail = new Trail(4); | 
| 15986   } else { | 15988   } else { | 
| 15987     const intptr_t len = (*trail)->Length(); | 15989     const intptr_t len = (*trail)->length(); | 
| 15988     for (intptr_t i = 0; i < len; i++) { | 15990     for (intptr_t i = 0; i < len; i++) { | 
| 15989       if ((*trail)->At(i) == this->raw()) { | 15991       if ((*trail)->At(i)->raw() == this->raw()) { | 
| 15990         return true; | 15992         return true; | 
| 15991       } | 15993       } | 
| 15992     } | 15994     } | 
| 15993   } | 15995   } | 
| 15994   (*trail)->Add(*this); | 15996   AbstractType& t = AbstractType::ZoneHandle(this->raw()); | 
|  | 15997   (*trail)->Add(&t); | 
| 15995   return false; | 15998   return false; | 
| 15996 } | 15999 } | 
| 15997 | 16000 | 
| 15998 | 16001 | 
| 15999 bool TypeRef::TestAndAddBuddyToTrail(GrowableObjectArray** trail, | 16002 bool TypeRef::TestAndAddBuddyToTrail(TrailPtr* trail, | 
| 16000                                      const Object& buddy) const { | 16003                                      const AbstractType& buddy) const { | 
| 16001   if (*trail == NULL) { | 16004   if (*trail == NULL) { | 
| 16002     *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New()); | 16005     *trail = new Trail(4); | 
| 16003   } else { | 16006   } else { | 
| 16004     const intptr_t len = (*trail)->Length(); | 16007     const intptr_t len = (*trail)->length(); | 
| 16005     ASSERT((len % 2) == 0); | 16008     ASSERT((len % 2) == 0); | 
| 16006     for (intptr_t i = 0; i < len; i += 2) { | 16009     for (intptr_t i = 0; i < len; i += 2) { | 
| 16007       if (((*trail)->At(i) == this->raw()) && | 16010       ASSERT((*trail)->At(i)->IsZoneHandle()); | 
| 16008           ((*trail)->At(i + 1) == buddy.raw())) { | 16011       ASSERT((*trail)->At(i + 1)->IsZoneHandle()); | 
|  | 16012       if (((*trail)->At(i)->raw() == this->raw()) && | 
|  | 16013           ((*trail)->At(i + 1)->raw() == buddy.raw())) { | 
| 16009         return true; | 16014         return true; | 
| 16010       } | 16015       } | 
| 16011     } | 16016     } | 
| 16012   } | 16017   } | 
| 16013   (*trail)->Add(*this); | 16018   AbstractType& t = AbstractType::ZoneHandle(this->raw()); | 
| 16014   (*trail)->Add(buddy); | 16019   AbstractType& b = AbstractType::ZoneHandle(buddy.raw()); | 
|  | 16020   (*trail)->Add(&t); | 
|  | 16021   (*trail)->Add(&b); | 
| 16015   return false; | 16022   return false; | 
| 16016 } | 16023 } | 
| 16017 | 16024 | 
| 16018 | 16025 | 
| 16019 RawTypeRef* TypeRef::New() { | 16026 RawTypeRef* TypeRef::New() { | 
| 16020   RawObject* raw = Object::Allocate(TypeRef::kClassId, | 16027   RawObject* raw = Object::Allocate(TypeRef::kClassId, | 
| 16021                                     TypeRef::InstanceSize(), | 16028                                     TypeRef::InstanceSize(), | 
| 16022                                     Heap::kOld); | 16029                                     Heap::kOld); | 
| 16023   return reinterpret_cast<RawTypeRef*>(raw); | 16030   return reinterpret_cast<RawTypeRef*>(raw); | 
| 16024 } | 16031 } | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 16067   jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 16074   jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 
| 16068 } | 16075 } | 
| 16069 | 16076 | 
| 16070 | 16077 | 
| 16071 void TypeParameter::set_is_finalized() const { | 16078 void TypeParameter::set_is_finalized() const { | 
| 16072   ASSERT(!IsFinalized()); | 16079   ASSERT(!IsFinalized()); | 
| 16073   set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 16080   set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 
| 16074 } | 16081 } | 
| 16075 | 16082 | 
| 16076 | 16083 | 
| 16077 bool TypeParameter::IsEquivalent(const Instance& other, | 16084 bool TypeParameter::IsEquivalent(const Instance& other, TrailPtr trail) const { | 
| 16078                                  GrowableObjectArray* trail) const { |  | 
| 16079   if (raw() == other.raw()) { | 16085   if (raw() == other.raw()) { | 
| 16080     return true; | 16086     return true; | 
| 16081   } | 16087   } | 
| 16082   if (other.IsTypeRef()) { | 16088   if (other.IsTypeRef()) { | 
| 16083     // Unfold right hand type. Divergence is controlled by left hand type. | 16089     // Unfold right hand type. Divergence is controlled by left hand type. | 
| 16084     const AbstractType& other_ref_type = AbstractType::Handle( | 16090     const AbstractType& other_ref_type = AbstractType::Handle( | 
| 16085         TypeRef::Cast(other).type()); | 16091         TypeRef::Cast(other).type()); | 
| 16086     ASSERT(!other_ref_type.IsTypeRef()); | 16092     ASSERT(!other_ref_type.IsTypeRef()); | 
| 16087     return IsEquivalent(other_ref_type, trail); | 16093     return IsEquivalent(other_ref_type, trail); | 
| 16088   } | 16094   } | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 16120 | 16126 | 
| 16121 | 16127 | 
| 16122 void TypeParameter::set_bound(const AbstractType& value) const { | 16128 void TypeParameter::set_bound(const AbstractType& value) const { | 
| 16123   StorePointer(&raw_ptr()->bound_, value.raw()); | 16129   StorePointer(&raw_ptr()->bound_, value.raw()); | 
| 16124 } | 16130 } | 
| 16125 | 16131 | 
| 16126 | 16132 | 
| 16127 RawAbstractType* TypeParameter::InstantiateFrom( | 16133 RawAbstractType* TypeParameter::InstantiateFrom( | 
| 16128     const TypeArguments& instantiator_type_arguments, | 16134     const TypeArguments& instantiator_type_arguments, | 
| 16129     Error* bound_error, | 16135     Error* bound_error, | 
| 16130     GrowableObjectArray* trail) const { | 16136     TrailPtr trail) const { | 
| 16131   ASSERT(IsFinalized()); | 16137   ASSERT(IsFinalized()); | 
| 16132   if (instantiator_type_arguments.IsNull()) { | 16138   if (instantiator_type_arguments.IsNull()) { | 
| 16133     return Type::DynamicType(); | 16139     return Type::DynamicType(); | 
| 16134   } | 16140   } | 
| 16135   const AbstractType& type_arg = AbstractType::Handle( | 16141   const AbstractType& type_arg = AbstractType::Handle( | 
| 16136       instantiator_type_arguments.TypeAt(index())); | 16142       instantiator_type_arguments.TypeAt(index())); | 
| 16137   // There is no need to canonicalize the instantiated type parameter, since all | 16143   // There is no need to canonicalize the instantiated type parameter, since all | 
| 16138   // type arguments are canonicalized at type finalization time. It would be too | 16144   // type arguments are canonicalized at type finalization time. It would be too | 
| 16139   // early to canonicalize the returned type argument here, since instantiation | 16145   // early to canonicalize the returned type argument here, since instantiation | 
| 16140   // not only happens at run time, but also during type finalization. | 16146   // not only happens at run time, but also during type finalization. | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 16196   // No need to clone bound, as it is not part of the finalization state. | 16202   // No need to clone bound, as it is not part of the finalization state. | 
| 16197   return TypeParameter::New(Class::Handle(parameterized_class()), | 16203   return TypeParameter::New(Class::Handle(parameterized_class()), | 
| 16198                             index(), | 16204                             index(), | 
| 16199                             String::Handle(name()), | 16205                             String::Handle(name()), | 
| 16200                             AbstractType::Handle(bound()), | 16206                             AbstractType::Handle(bound()), | 
| 16201                             token_pos()); | 16207                             token_pos()); | 
| 16202 } | 16208 } | 
| 16203 | 16209 | 
| 16204 | 16210 | 
| 16205 RawAbstractType* TypeParameter::CloneUninstantiated( | 16211 RawAbstractType* TypeParameter::CloneUninstantiated( | 
| 16206     const Class& new_owner, | 16212     const Class& new_owner, TrailPtr trail) const { | 
| 16207     GrowableObjectArray* trail) const { |  | 
| 16208   ASSERT(IsFinalized()); | 16213   ASSERT(IsFinalized()); | 
| 16209   AbstractType& upper_bound = AbstractType::Handle(bound()); | 16214   AbstractType& upper_bound = AbstractType::Handle(bound()); | 
| 16210   upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); | 16215   upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); | 
| 16211   const Class& old_owner = Class::Handle(parameterized_class()); | 16216   const Class& old_owner = Class::Handle(parameterized_class()); | 
| 16212   const intptr_t new_index = index() + | 16217   const intptr_t new_index = index() + | 
| 16213       new_owner.NumTypeArguments() - old_owner.NumTypeArguments(); | 16218       new_owner.NumTypeArguments() - old_owner.NumTypeArguments(); | 
| 16214   const TypeParameter& clone = TypeParameter::Handle( | 16219   const TypeParameter& clone = TypeParameter::Handle( | 
| 16215       TypeParameter::New(new_owner, | 16220       TypeParameter::New(new_owner, | 
| 16216                          new_index, | 16221                          new_index, | 
| 16217                          String::Handle(name()), | 16222                          String::Handle(name()), | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 16320 bool BoundedType::IsMalformedOrMalbounded() const { | 16325 bool BoundedType::IsMalformedOrMalbounded() const { | 
| 16321   return AbstractType::Handle(type()).IsMalformedOrMalbounded(); | 16326   return AbstractType::Handle(type()).IsMalformedOrMalbounded(); | 
| 16322 } | 16327 } | 
| 16323 | 16328 | 
| 16324 | 16329 | 
| 16325 RawLanguageError* BoundedType::error() const { | 16330 RawLanguageError* BoundedType::error() const { | 
| 16326   return AbstractType::Handle(type()).error(); | 16331   return AbstractType::Handle(type()).error(); | 
| 16327 } | 16332 } | 
| 16328 | 16333 | 
| 16329 | 16334 | 
| 16330 bool BoundedType::IsEquivalent(const Instance& other, | 16335 bool BoundedType::IsEquivalent(const Instance& other, TrailPtr trail) const { | 
| 16331                                GrowableObjectArray* trail) const { |  | 
| 16332   // BoundedType are not canonicalized, because their bound may get finalized | 16336   // BoundedType are not canonicalized, because their bound may get finalized | 
| 16333   // after the BoundedType is created and initialized. | 16337   // after the BoundedType is created and initialized. | 
| 16334   if (raw() == other.raw()) { | 16338   if (raw() == other.raw()) { | 
| 16335     return true; | 16339     return true; | 
| 16336   } | 16340   } | 
| 16337   if (other.IsTypeRef()) { | 16341   if (other.IsTypeRef()) { | 
| 16338     // Unfold right hand type. Divergence is controlled by left hand type. | 16342     // Unfold right hand type. Divergence is controlled by left hand type. | 
| 16339     const AbstractType& other_ref_type = AbstractType::Handle( | 16343     const AbstractType& other_ref_type = AbstractType::Handle( | 
| 16340         TypeRef::Cast(other).type()); | 16344         TypeRef::Cast(other).type()); | 
| 16341     ASSERT(!other_ref_type.IsTypeRef()); | 16345     ASSERT(!other_ref_type.IsTypeRef()); | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 16385   // A null type parameter is set when marking a type malformed because of a | 16389   // A null type parameter is set when marking a type malformed because of a | 
| 16386   // bound error at compile time. | 16390   // bound error at compile time. | 
| 16387   ASSERT(value.IsNull() || value.IsFinalized()); | 16391   ASSERT(value.IsNull() || value.IsFinalized()); | 
| 16388   StorePointer(&raw_ptr()->type_parameter_, value.raw()); | 16392   StorePointer(&raw_ptr()->type_parameter_, value.raw()); | 
| 16389 } | 16393 } | 
| 16390 | 16394 | 
| 16391 | 16395 | 
| 16392 RawAbstractType* BoundedType::InstantiateFrom( | 16396 RawAbstractType* BoundedType::InstantiateFrom( | 
| 16393     const TypeArguments& instantiator_type_arguments, | 16397     const TypeArguments& instantiator_type_arguments, | 
| 16394     Error* bound_error, | 16398     Error* bound_error, | 
| 16395     GrowableObjectArray* trail) const { | 16399     TrailPtr trail) const { | 
| 16396   ASSERT(IsFinalized()); | 16400   ASSERT(IsFinalized()); | 
| 16397   AbstractType& bounded_type = AbstractType::Handle(type()); | 16401   AbstractType& bounded_type = AbstractType::Handle(type()); | 
| 16398   ASSERT(bounded_type.IsFinalized()); | 16402   ASSERT(bounded_type.IsFinalized()); | 
| 16399   if (!bounded_type.IsInstantiated()) { | 16403   if (!bounded_type.IsInstantiated()) { | 
| 16400     bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, | 16404     bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, | 
| 16401                                                 bound_error, | 16405                                                 bound_error, | 
| 16402                                                 trail); | 16406                                                 trail); | 
| 16403     // In case types of instantiator_type_arguments are not finalized, then | 16407     // In case types of instantiator_type_arguments are not finalized, then | 
| 16404     // the instantiated bounded_type is not finalized either. | 16408     // the instantiated bounded_type is not finalized either. | 
| 16405     // Note that instantiator_type_arguments must have the final length, though. | 16409     // Note that instantiator_type_arguments must have the final length, though. | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 16441   bounded_type = bounded_type.CloneUnfinalized(); | 16445   bounded_type = bounded_type.CloneUnfinalized(); | 
| 16442   // No need to clone bound or type parameter, as they are not part of the | 16446   // No need to clone bound or type parameter, as they are not part of the | 
| 16443   // finalization state of this bounded type. | 16447   // finalization state of this bounded type. | 
| 16444   return BoundedType::New(bounded_type, | 16448   return BoundedType::New(bounded_type, | 
| 16445                           AbstractType::Handle(bound()), | 16449                           AbstractType::Handle(bound()), | 
| 16446                           TypeParameter::Handle(type_parameter())); | 16450                           TypeParameter::Handle(type_parameter())); | 
| 16447 } | 16451 } | 
| 16448 | 16452 | 
| 16449 | 16453 | 
| 16450 RawAbstractType* BoundedType::CloneUninstantiated( | 16454 RawAbstractType* BoundedType::CloneUninstantiated( | 
| 16451     const Class& new_owner, | 16455     const Class& new_owner, TrailPtr trail) const { | 
| 16452     GrowableObjectArray* trail) const { |  | 
| 16453   if (IsInstantiated()) { | 16456   if (IsInstantiated()) { | 
| 16454     return raw(); | 16457     return raw(); | 
| 16455   } | 16458   } | 
| 16456   AbstractType& bounded_type = AbstractType::Handle(type()); | 16459   AbstractType& bounded_type = AbstractType::Handle(type()); | 
| 16457   bounded_type = bounded_type.CloneUninstantiated(new_owner, trail); | 16460   bounded_type = bounded_type.CloneUninstantiated(new_owner, trail); | 
| 16458   AbstractType& upper_bound = AbstractType::Handle(bound()); | 16461   AbstractType& upper_bound = AbstractType::Handle(bound()); | 
| 16459   upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); | 16462   upper_bound = upper_bound.CloneUninstantiated(new_owner, trail); | 
| 16460   TypeParameter& type_param =  TypeParameter::Handle(type_parameter()); | 16463   TypeParameter& type_param =  TypeParameter::Handle(type_parameter()); | 
| 16461   type_param ^= type_param.CloneUninstantiated(new_owner, trail); | 16464   type_param ^= type_param.CloneUninstantiated(new_owner, trail); | 
| 16462   return BoundedType::New(bounded_type, upper_bound, type_param); | 16465   return BoundedType::New(bounded_type, upper_bound, type_param); | 
| (...skipping 4969 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 21432   return tag_label.ToCString(); | 21435   return tag_label.ToCString(); | 
| 21433 } | 21436 } | 
| 21434 | 21437 | 
| 21435 | 21438 | 
| 21436 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21439 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 
| 21437   Instance::PrintJSONImpl(stream, ref); | 21440   Instance::PrintJSONImpl(stream, ref); | 
| 21438 } | 21441 } | 
| 21439 | 21442 | 
| 21440 | 21443 | 
| 21441 }  // namespace dart | 21444 }  // namespace dart | 
| OLD | NEW | 
|---|