| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 9161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9172 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 9172 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 9173 // Most probably a malformed type. Do not fill up with "dynamic", | 9173 // Most probably a malformed type. Do not fill up with "dynamic", |
| 9174 // but use actual vector. | 9174 // but use actual vector. |
| 9175 num_type_params = num_args; | 9175 num_type_params = num_args; |
| 9176 } else { | 9176 } else { |
| 9177 ASSERT(num_args == 0); // Type is raw. | 9177 ASSERT(num_args == 0); // Type is raw. |
| 9178 // No need to fill up with "dynamic". | 9178 // No need to fill up with "dynamic". |
| 9179 num_type_params = 0; | 9179 num_type_params = 0; |
| 9180 } | 9180 } |
| 9181 } else { | 9181 } else { |
| 9182 first_type_param_index = num_args - num_type_params; | 9182 // The actual type argument vector can be longer than necessary, because |
| 9183 // of type optimizations. |
| 9184 if (IsFinalized() && cls.is_finalized()) { |
| 9185 first_type_param_index = cls.NumTypeArguments() - num_type_params; |
| 9186 } else { |
| 9187 first_type_param_index = num_args - num_type_params; |
| 9188 } |
| 9183 } | 9189 } |
| 9184 if (cls.IsSignatureClass()) { | 9190 if (cls.IsSignatureClass()) { |
| 9185 // We may be reporting an error about a malformed function type. In that | 9191 // We may be reporting an error about a malformed function type. In that |
| 9186 // case, avoid instantiating the signature, since it may lead to cycles. | 9192 // case, avoid instantiating the signature, since it may lead to cycles. |
| 9187 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 9193 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 9188 return class_name.raw(); | 9194 return class_name.raw(); |
| 9189 } | 9195 } |
| 9190 // In order to avoid cycles, print the name of a typedef (non-canonical | 9196 // In order to avoid cycles, print the name of a typedef (non-canonical |
| 9191 // signature class) as a regular, possibly parameterized, class. | 9197 // signature class) as a regular, possibly parameterized, class. |
| 9192 if (cls.IsCanonicalSignatureClass()) { | 9198 if (cls.IsCanonicalSignatureClass()) { |
| 9193 const Function& signature_function = Function::Handle( | 9199 const Function& signature_function = Function::Handle( |
| 9194 cls.signature_function()); | 9200 cls.signature_function()); |
| 9195 // Signature classes have no super type. | 9201 // Signature classes have no super type, however, they take as many |
| 9196 ASSERT(first_type_param_index == 0); | 9202 // type arguments as the owner class of their signature function (if it |
| 9203 // is non static and generic, see Class::NumTypeArguments()). Therefore, |
| 9204 // first_type_param_index may be greater than 0 here. |
| 9197 return signature_function.InstantiatedSignatureFrom(args, | 9205 return signature_function.InstantiatedSignatureFrom(args, |
| 9198 name_visibility); | 9206 name_visibility); |
| 9199 } | 9207 } |
| 9200 } | 9208 } |
| 9201 } else { | 9209 } else { |
| 9202 const UnresolvedClass& cls = UnresolvedClass::Handle(unresolved_class()); | 9210 const UnresolvedClass& cls = UnresolvedClass::Handle(unresolved_class()); |
| 9203 class_name = cls.Name(); | 9211 class_name = cls.Name(); |
| 9204 num_type_params = num_args; | 9212 num_type_params = num_args; |
| 9205 first_type_param_index = 0; | 9213 first_type_param_index = 0; |
| 9206 } | 9214 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9541 ASSERT(IsFinalized()); | 9549 ASSERT(IsFinalized()); |
| 9542 ASSERT(!IsInstantiated()); | 9550 ASSERT(!IsInstantiated()); |
| 9543 // Return the uninstantiated type unchanged if malformed. No copy needed. | 9551 // Return the uninstantiated type unchanged if malformed. No copy needed. |
| 9544 if (IsMalformed()) { | 9552 if (IsMalformed()) { |
| 9545 return raw(); | 9553 return raw(); |
| 9546 } | 9554 } |
| 9547 AbstractTypeArguments& type_arguments = | 9555 AbstractTypeArguments& type_arguments = |
| 9548 AbstractTypeArguments::Handle(arguments()); | 9556 AbstractTypeArguments::Handle(arguments()); |
| 9549 type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments, | 9557 type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments, |
| 9550 malformed_error); | 9558 malformed_error); |
| 9559 // Note that the type class has to be resolved at this time, but not |
| 9560 // necessarily finalized yet. We may be checking bounds at compile time. |
| 9551 const Class& cls = Class::Handle(type_class()); | 9561 const Class& cls = Class::Handle(type_class()); |
| 9552 ASSERT(cls.is_finalized()); | |
| 9553 // This uninstantiated type is not modified, as it can be instantiated | 9562 // This uninstantiated type is not modified, as it can be instantiated |
| 9554 // with different instantiators. | 9563 // with different instantiators. |
| 9555 Type& instantiated_type = Type::Handle( | 9564 Type& instantiated_type = Type::Handle( |
| 9556 Type::New(cls, type_arguments, token_pos())); | 9565 Type::New(cls, type_arguments, token_pos())); |
| 9557 ASSERT(type_arguments.IsNull() || | 9566 ASSERT(type_arguments.IsNull() || |
| 9558 (type_arguments.Length() == cls.NumTypeArguments())); | 9567 (type_arguments.Length() == cls.NumTypeArguments())); |
| 9559 instantiated_type.SetIsFinalized(); | 9568 instantiated_type.SetIsFinalized(); |
| 9560 return instantiated_type.raw(); | 9569 return instantiated_type.raw(); |
| 9561 } | 9570 } |
| 9562 | 9571 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9727 } | 9736 } |
| 9728 | 9737 |
| 9729 | 9738 |
| 9730 void TypeParameter::set_is_finalized() const { | 9739 void TypeParameter::set_is_finalized() const { |
| 9731 ASSERT(!IsFinalized()); | 9740 ASSERT(!IsFinalized()); |
| 9732 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 9741 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
| 9733 } | 9742 } |
| 9734 | 9743 |
| 9735 | 9744 |
| 9736 bool TypeParameter::Equals(const Instance& other) const { | 9745 bool TypeParameter::Equals(const Instance& other) const { |
| 9737 ASSERT(IsFinalized()); | |
| 9738 if (raw() == other.raw()) { | 9746 if (raw() == other.raw()) { |
| 9739 return true; | 9747 return true; |
| 9740 } | 9748 } |
| 9741 if (!other.IsTypeParameter()) { | 9749 if (!other.IsTypeParameter()) { |
| 9742 return false; | 9750 return false; |
| 9743 } | 9751 } |
| 9744 const TypeParameter& other_type_param = TypeParameter::Cast(other); | 9752 const TypeParameter& other_type_param = TypeParameter::Cast(other); |
| 9745 ASSERT(other_type_param.IsFinalized()); | 9753 ASSERT(other_type_param.IsFinalized()); |
| 9746 if (parameterized_class() != other_type_param.parameterized_class()) { | 9754 if (parameterized_class() != other_type_param.parameterized_class()) { |
| 9747 return false; | 9755 return false; |
| 9748 } | 9756 } |
| 9757 if (IsFinalized() != other_type_param.IsFinalized()) { |
| 9758 return false; |
| 9759 } |
| 9749 if (index() != other_type_param.index()) { | 9760 if (index() != other_type_param.index()) { |
| 9750 return false; | 9761 return false; |
| 9751 } | 9762 } |
| 9752 return true; | 9763 return true; |
| 9753 } | 9764 } |
| 9754 | 9765 |
| 9755 | 9766 |
| 9756 void TypeParameter::set_parameterized_class(const Class& value) const { | 9767 void TypeParameter::set_parameterized_class(const Class& value) const { |
| 9757 // Set value may be null. | 9768 // Set value may be null. |
| 9758 StorePointer(&raw_ptr()->parameterized_class_, value.raw()); | 9769 StorePointer(&raw_ptr()->parameterized_class_, value.raw()); |
| (...skipping 3880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13639 } | 13650 } |
| 13640 return result.raw(); | 13651 return result.raw(); |
| 13641 } | 13652 } |
| 13642 | 13653 |
| 13643 | 13654 |
| 13644 const char* WeakProperty::ToCString() const { | 13655 const char* WeakProperty::ToCString() const { |
| 13645 return "_WeakProperty"; | 13656 return "_WeakProperty"; |
| 13646 } | 13657 } |
| 13647 | 13658 |
| 13648 } // namespace dart | 13659 } // namespace dart |
| OLD | NEW |