| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 16939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16950 TrailPtr instantiation_trail, | 16950 TrailPtr instantiation_trail, |
| 16951 TrailPtr bound_trail, | 16951 TrailPtr bound_trail, |
| 16952 Heap::Space space) const { | 16952 Heap::Space space) const { |
| 16953 Zone* zone = Thread::Current()->zone(); | 16953 Zone* zone = Thread::Current()->zone(); |
| 16954 ASSERT(IsFinalized() || IsBeingFinalized()); | 16954 ASSERT(IsFinalized() || IsBeingFinalized()); |
| 16955 ASSERT(!IsInstantiated()); | 16955 ASSERT(!IsInstantiated()); |
| 16956 // Return the uninstantiated type unchanged if malformed. No copy needed. | 16956 // Return the uninstantiated type unchanged if malformed. No copy needed. |
| 16957 if (IsMalformed()) { | 16957 if (IsMalformed()) { |
| 16958 return raw(); | 16958 return raw(); |
| 16959 } | 16959 } |
| 16960 // Instantiating this type with its own type arguments as instantiator can | |
| 16961 // occur during finalization and bounds checking. Return the type unchanged. | |
| 16962 if (arguments() == instantiator_type_arguments.raw()) { | |
| 16963 return raw(); | |
| 16964 } | |
| 16965 // Note that the type class has to be resolved at this time, but not | 16960 // Note that the type class has to be resolved at this time, but not |
| 16966 // necessarily finalized yet. We may be checking bounds at compile time or | 16961 // necessarily finalized yet. We may be checking bounds at compile time or |
| 16967 // finalizing the type argument vector of a recursive type. | 16962 // finalizing the type argument vector of a recursive type. |
| 16968 const Class& cls = Class::Handle(zone, type_class()); | 16963 const Class& cls = Class::Handle(zone, type_class()); |
| 16969 TypeArguments& type_arguments = TypeArguments::Handle(zone, arguments()); | 16964 TypeArguments& type_arguments = TypeArguments::Handle(zone, arguments()); |
| 16970 ASSERT(type_arguments.Length() == cls.NumTypeArguments()); | 16965 ASSERT(type_arguments.Length() == cls.NumTypeArguments()); |
| 16971 type_arguments = | 16966 type_arguments = |
| 16972 type_arguments.InstantiateFrom(instantiator_type_arguments, bound_error, | 16967 type_arguments.InstantiateFrom(instantiator_type_arguments, bound_error, |
| 16973 instantiation_trail, bound_trail, space); | 16968 instantiation_trail, bound_trail, space); |
| 16974 // This uninstantiated type is not modified, as it can be instantiated | 16969 // This uninstantiated type is not modified, as it can be instantiated |
| 16975 // with different instantiators. Allocate a new instantiated version of it. | 16970 // with different instantiators. Allocate a new instantiated version of it. |
| 16976 const Type& instantiated_type = | 16971 const Type& instantiated_type = |
| 16977 Type::Handle(zone, Type::New(cls, type_arguments, token_pos(), space)); | 16972 Type::Handle(zone, Type::New(cls, type_arguments, token_pos(), space)); |
| 16978 // Preserve the bound error if any. | 16973 // Preserve the bound error if any. |
| 16979 if (IsMalbounded()) { | 16974 if (IsMalbounded()) { |
| 16980 const LanguageError& bound_error = LanguageError::Handle(zone, error()); | 16975 const LanguageError& bound_error = LanguageError::Handle(zone, error()); |
| 16981 instantiated_type.set_error(bound_error); | 16976 instantiated_type.set_error(bound_error); |
| 16982 } | 16977 } |
| 16983 // Preserve the signature if this type represents a function type. | 16978 // Preserve the signature if this type represents a function type. |
| 16984 // Note that the types in the signature remain unchanged. They get indirectly | 16979 // Note that the types in the signature remain unchanged. They get indirectly |
| 16985 // instantiated by instantiating the type arguments above. | 16980 // instantiated by instantiating the type arguments above. |
| 16986 const Function& sig_fun = Function::Handle(zone, signature()); | 16981 const Function& sig_fun = Function::Handle(zone, signature()); |
| 16987 if (!sig_fun.IsNull()) { | 16982 if (!sig_fun.IsNull()) { |
| 16988 instantiated_type.set_signature(sig_fun); | 16983 instantiated_type.set_signature(sig_fun); |
| 16989 } | 16984 } |
| 16990 if (IsFinalized()) { | 16985 if (IsFinalized()) { |
| 16991 instantiated_type.SetIsFinalized(); | 16986 instantiated_type.SetIsFinalized(); |
| 16992 } else { | 16987 } else { |
| 16993 instantiated_type.SetIsResolved(); | 16988 instantiated_type.SetIsResolved(); |
| 16989 if (IsBeingFinalized()) { |
| 16990 instantiated_type.SetIsBeingFinalized(); |
| 16991 } |
| 16994 } | 16992 } |
| 16995 // Canonicalization is not part of instantiation. | 16993 // Canonicalization is not part of instantiation. |
| 16996 return instantiated_type.raw(); | 16994 return instantiated_type.raw(); |
| 16997 } | 16995 } |
| 16998 | 16996 |
| 16999 | 16997 |
| 17000 bool Type::IsEquivalent(const Instance& other, TrailPtr trail) const { | 16998 bool Type::IsEquivalent(const Instance& other, TrailPtr trail) const { |
| 17001 ASSERT(!IsNull()); | 16999 ASSERT(!IsNull()); |
| 17002 if (raw() == other.raw()) { | 17000 if (raw() == other.raw()) { |
| 17003 return true; | 17001 return true; |
| (...skipping 6129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23133 return UserTag::null(); | 23131 return UserTag::null(); |
| 23134 } | 23132 } |
| 23135 | 23133 |
| 23136 | 23134 |
| 23137 const char* UserTag::ToCString() const { | 23135 const char* UserTag::ToCString() const { |
| 23138 const String& tag_label = String::Handle(label()); | 23136 const String& tag_label = String::Handle(label()); |
| 23139 return tag_label.ToCString(); | 23137 return tag_label.ToCString(); |
| 23140 } | 23138 } |
| 23141 | 23139 |
| 23142 } // namespace dart | 23140 } // namespace dart |
| OLD | NEW |