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 16145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16156 void BoundedType::set_type(const AbstractType& value) const { | 16156 void BoundedType::set_type(const AbstractType& value) const { |
16157 ASSERT(value.IsFinalized() || value.IsBeingFinalized()); | 16157 ASSERT(value.IsFinalized() || value.IsBeingFinalized()); |
16158 ASSERT(!value.IsMalformed()); | 16158 ASSERT(!value.IsMalformed()); |
16159 StorePointer(&raw_ptr()->type_, value.raw()); | 16159 StorePointer(&raw_ptr()->type_, value.raw()); |
16160 } | 16160 } |
16161 | 16161 |
16162 | 16162 |
16163 void BoundedType::set_bound(const AbstractType& value) const { | 16163 void BoundedType::set_bound(const AbstractType& value) const { |
16164 // The bound may still be unfinalized because of legal cycles. | 16164 // The bound may still be unfinalized because of legal cycles. |
16165 // It must be finalized before it is checked at run time, though. | 16165 // It must be finalized before it is checked at run time, though. |
| 16166 ASSERT(value.IsFinalized() || value.IsBeingFinalized()); |
16166 StorePointer(&raw_ptr()->bound_, value.raw()); | 16167 StorePointer(&raw_ptr()->bound_, value.raw()); |
16167 } | 16168 } |
16168 | 16169 |
16169 | 16170 |
16170 void BoundedType::set_type_parameter(const TypeParameter& value) const { | 16171 void BoundedType::set_type_parameter(const TypeParameter& value) const { |
16171 // A null type parameter is set when marking a type malformed because of a | 16172 // A null type parameter is set when marking a type malformed because of a |
16172 // bound error at compile time. | 16173 // bound error at compile time. |
16173 ASSERT(value.IsNull() || value.IsFinalized()); | 16174 ASSERT(value.IsNull() || value.IsFinalized()); |
16174 StorePointer(&raw_ptr()->type_parameter_, value.raw()); | 16175 StorePointer(&raw_ptr()->type_parameter_, value.raw()); |
16175 } | 16176 } |
16176 | 16177 |
16177 | 16178 |
16178 RawAbstractType* BoundedType::InstantiateFrom( | 16179 RawAbstractType* BoundedType::InstantiateFrom( |
16179 const TypeArguments& instantiator_type_arguments, | 16180 const TypeArguments& instantiator_type_arguments, |
16180 Error* bound_error, | 16181 Error* bound_error, |
16181 GrowableObjectArray* trail) const { | 16182 GrowableObjectArray* trail) const { |
16182 ASSERT(IsFinalized()); | 16183 ASSERT(IsFinalized()); |
16183 AbstractType& bounded_type = AbstractType::Handle(type()); | 16184 AbstractType& bounded_type = AbstractType::Handle(type()); |
| 16185 ASSERT(bounded_type.IsFinalized()); |
16184 if (!bounded_type.IsInstantiated()) { | 16186 if (!bounded_type.IsInstantiated()) { |
16185 bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, | 16187 bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, |
16186 bound_error, | 16188 bound_error, |
16187 trail); | 16189 trail); |
| 16190 // In case types of instantiator_type_arguments are not finalized, then |
| 16191 // the instantiated bounded_type is not finalized either. |
| 16192 // Note that instantiator_type_arguments must have the final length, though. |
16188 } | 16193 } |
16189 if ((Isolate::Current()->flags().type_checks()) && | 16194 if ((Isolate::Current()->flags().type_checks()) && |
16190 (bound_error != NULL) && bound_error->IsNull()) { | 16195 (bound_error != NULL) && bound_error->IsNull()) { |
16191 AbstractType& upper_bound = AbstractType::Handle(bound()); | 16196 AbstractType& upper_bound = AbstractType::Handle(bound()); |
| 16197 ASSERT(upper_bound.IsFinalized()); |
16192 ASSERT(!upper_bound.IsObjectType() && !upper_bound.IsDynamicType()); | 16198 ASSERT(!upper_bound.IsObjectType() && !upper_bound.IsDynamicType()); |
16193 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); | 16199 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); |
16194 if (!upper_bound.IsInstantiated()) { | 16200 if (!upper_bound.IsInstantiated()) { |
16195 upper_bound = upper_bound.InstantiateFrom(instantiator_type_arguments, | 16201 upper_bound = upper_bound.InstantiateFrom(instantiator_type_arguments, |
16196 bound_error, | 16202 bound_error, |
16197 trail); | 16203 trail); |
| 16204 // Instantiated upper_bound may not be finalized. See comment above. |
16198 } | 16205 } |
16199 if (bound_error->IsNull()) { | 16206 if (bound_error->IsNull()) { |
16200 if (!type_param.CheckBound(bounded_type, upper_bound, bound_error) && | 16207 if (!type_param.CheckBound(bounded_type, upper_bound, bound_error) && |
16201 bound_error->IsNull()) { | 16208 bound_error->IsNull()) { |
16202 // We cannot determine yet whether the bounded_type is below the | 16209 // We cannot determine yet whether the bounded_type is below the |
16203 // upper_bound, because one or both of them is still uninstantiated. | 16210 // upper_bound, because one or both of them is still uninstantiated. |
16204 ASSERT(!bounded_type.IsInstantiated() || !upper_bound.IsInstantiated()); | 16211 ASSERT(!bounded_type.IsInstantiated() || !upper_bound.IsInstantiated()); |
16205 // Postpone bound check by returning a new BoundedType with partially | 16212 // Postpone bound check by returning a new BoundedType with partially |
16206 // instantiated bounded_type and upper_bound, but keeping type_param. | 16213 // instantiated bounded_type and upper_bound, but keeping type_param. |
16207 bounded_type = BoundedType::New(bounded_type, upper_bound, type_param); | 16214 bounded_type = BoundedType::New(bounded_type, upper_bound, type_param); |
(...skipping 4995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21203 return tag_label.ToCString(); | 21210 return tag_label.ToCString(); |
21204 } | 21211 } |
21205 | 21212 |
21206 | 21213 |
21207 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21214 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21208 Instance::PrintJSONImpl(stream, ref); | 21215 Instance::PrintJSONImpl(stream, ref); |
21209 } | 21216 } |
21210 | 21217 |
21211 | 21218 |
21212 } // namespace dart | 21219 } // namespace dart |
OLD | NEW |