Chromium Code Reviews| 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 9208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9219 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 9219 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 9220 // Most probably a malformed type. Do not fill up with "dynamic", | 9220 // Most probably a malformed type. Do not fill up with "dynamic", |
| 9221 // but use actual vector. | 9221 // but use actual vector. |
| 9222 num_type_params = num_args; | 9222 num_type_params = num_args; |
| 9223 } else { | 9223 } else { |
| 9224 ASSERT(num_args == 0); // Type is raw. | 9224 ASSERT(num_args == 0); // Type is raw. |
| 9225 // No need to fill up with "dynamic". | 9225 // No need to fill up with "dynamic". |
| 9226 num_type_params = 0; | 9226 num_type_params = 0; |
| 9227 } | 9227 } |
| 9228 } else { | 9228 } else { |
| 9229 first_type_param_index = num_args - num_type_params; | 9229 // The actual type argument vector can be longer than necessary, because |
| 9230 // of type optimizations. | |
| 9231 if (IsFinalized() && cls.is_finalized()) { | |
| 9232 first_type_param_index = cls.NumTypeArguments() - num_type_params; | |
| 9233 } else { | |
| 9234 first_type_param_index = num_args - num_type_params; | |
| 9235 } | |
| 9230 } | 9236 } |
| 9231 if (cls.IsSignatureClass()) { | 9237 if (cls.IsSignatureClass()) { |
| 9232 // We may be reporting an error about a malformed function type. In that | 9238 // We may be reporting an error about a malformed function type. In that |
| 9233 // case, avoid instantiating the signature, since it may lead to cycles. | 9239 // case, avoid instantiating the signature, since it may lead to cycles. |
| 9234 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 9240 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 9235 return class_name.raw(); | 9241 return class_name.raw(); |
| 9236 } | 9242 } |
| 9237 // In order to avoid cycles, print the name of a typedef (non-canonical | 9243 // In order to avoid cycles, print the name of a typedef (non-canonical |
| 9238 // signature class) as a regular, possibly parameterized, class. | 9244 // signature class) as a regular, possibly parameterized, class. |
| 9239 if (cls.IsCanonicalSignatureClass()) { | 9245 if (cls.IsCanonicalSignatureClass()) { |
| 9240 const Function& signature_function = Function::Handle( | 9246 const Function& signature_function = Function::Handle( |
| 9241 cls.signature_function()); | 9247 cls.signature_function()); |
| 9242 // Signature classes have no super type. | 9248 // Signature classes have no super type, however, they take as many |
| 9243 ASSERT(first_type_param_index == 0); | 9249 // type arguments as the owner class of their signature function (if it |
| 9250 // non static and generic, see Class::NumTypeArguments()). Therefore, | |
|
srdjan
2013/03/27 20:38:13
s/if it non static/if it is non static/
regis
2013/03/27 20:41:42
Done.
| |
| 9251 // first_type_param_index may be greater than 0 here. | |
| 9244 return signature_function.InstantiatedSignatureFrom(args, | 9252 return signature_function.InstantiatedSignatureFrom(args, |
| 9245 name_visibility); | 9253 name_visibility); |
| 9246 } | 9254 } |
| 9247 } | 9255 } |
| 9248 } else { | 9256 } else { |
| 9249 const UnresolvedClass& cls = UnresolvedClass::Handle(unresolved_class()); | 9257 const UnresolvedClass& cls = UnresolvedClass::Handle(unresolved_class()); |
| 9250 class_name = cls.Name(); | 9258 class_name = cls.Name(); |
| 9251 num_type_params = num_args; | 9259 num_type_params = num_args; |
| 9252 first_type_param_index = 0; | 9260 first_type_param_index = 0; |
| 9253 } | 9261 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9588 ASSERT(IsFinalized()); | 9596 ASSERT(IsFinalized()); |
| 9589 ASSERT(!IsInstantiated()); | 9597 ASSERT(!IsInstantiated()); |
| 9590 // Return the uninstantiated type unchanged if malformed. No copy needed. | 9598 // Return the uninstantiated type unchanged if malformed. No copy needed. |
| 9591 if (IsMalformed()) { | 9599 if (IsMalformed()) { |
| 9592 return raw(); | 9600 return raw(); |
| 9593 } | 9601 } |
| 9594 AbstractTypeArguments& type_arguments = | 9602 AbstractTypeArguments& type_arguments = |
| 9595 AbstractTypeArguments::Handle(arguments()); | 9603 AbstractTypeArguments::Handle(arguments()); |
| 9596 type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments, | 9604 type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments, |
| 9597 malformed_error); | 9605 malformed_error); |
| 9606 // Note that the type class has to be resolved at this time, but not | |
| 9607 // necessarily finalized yet. We may be checking bounds at compile time. | |
| 9598 const Class& cls = Class::Handle(type_class()); | 9608 const Class& cls = Class::Handle(type_class()); |
| 9599 ASSERT(cls.is_finalized()); | |
| 9600 // This uninstantiated type is not modified, as it can be instantiated | 9609 // This uninstantiated type is not modified, as it can be instantiated |
| 9601 // with different instantiators. | 9610 // with different instantiators. |
| 9602 Type& instantiated_type = Type::Handle( | 9611 Type& instantiated_type = Type::Handle( |
| 9603 Type::New(cls, type_arguments, token_pos())); | 9612 Type::New(cls, type_arguments, token_pos())); |
| 9604 ASSERT(type_arguments.IsNull() || | 9613 ASSERT(type_arguments.IsNull() || |
| 9605 (type_arguments.Length() == cls.NumTypeArguments())); | 9614 (type_arguments.Length() == cls.NumTypeArguments())); |
| 9606 instantiated_type.SetIsFinalized(); | 9615 instantiated_type.SetIsFinalized(); |
| 9607 return instantiated_type.raw(); | 9616 return instantiated_type.raw(); |
| 9608 } | 9617 } |
| 9609 | 9618 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9774 } | 9783 } |
| 9775 | 9784 |
| 9776 | 9785 |
| 9777 void TypeParameter::set_is_finalized() const { | 9786 void TypeParameter::set_is_finalized() const { |
| 9778 ASSERT(!IsFinalized()); | 9787 ASSERT(!IsFinalized()); |
| 9779 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 9788 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
| 9780 } | 9789 } |
| 9781 | 9790 |
| 9782 | 9791 |
| 9783 bool TypeParameter::Equals(const Instance& other) const { | 9792 bool TypeParameter::Equals(const Instance& other) const { |
| 9784 ASSERT(IsFinalized()); | |
| 9785 if (raw() == other.raw()) { | 9793 if (raw() == other.raw()) { |
| 9786 return true; | 9794 return true; |
| 9787 } | 9795 } |
| 9788 if (!other.IsTypeParameter()) { | 9796 if (!other.IsTypeParameter()) { |
| 9789 return false; | 9797 return false; |
| 9790 } | 9798 } |
| 9791 const TypeParameter& other_type_param = TypeParameter::Cast(other); | 9799 const TypeParameter& other_type_param = TypeParameter::Cast(other); |
| 9792 ASSERT(other_type_param.IsFinalized()); | 9800 ASSERT(other_type_param.IsFinalized()); |
| 9793 if (parameterized_class() != other_type_param.parameterized_class()) { | 9801 if (parameterized_class() != other_type_param.parameterized_class()) { |
| 9794 return false; | 9802 return false; |
| 9795 } | 9803 } |
| 9804 if (IsFinalized() != other_type_param.IsFinalized()) { | |
| 9805 return false; | |
| 9806 } | |
| 9796 if (index() != other_type_param.index()) { | 9807 if (index() != other_type_param.index()) { |
| 9797 return false; | 9808 return false; |
| 9798 } | 9809 } |
| 9799 return true; | 9810 return true; |
| 9800 } | 9811 } |
| 9801 | 9812 |
| 9802 | 9813 |
| 9803 void TypeParameter::set_parameterized_class(const Class& value) const { | 9814 void TypeParameter::set_parameterized_class(const Class& value) const { |
| 9804 // Set value may be null. | 9815 // Set value may be null. |
| 9805 StorePointer(&raw_ptr()->parameterized_class_, value.raw()); | 9816 StorePointer(&raw_ptr()->parameterized_class_, value.raw()); |
| (...skipping 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13647 } | 13658 } |
| 13648 return result.raw(); | 13659 return result.raw(); |
| 13649 } | 13660 } |
| 13650 | 13661 |
| 13651 | 13662 |
| 13652 const char* WeakProperty::ToCString() const { | 13663 const char* WeakProperty::ToCString() const { |
| 13653 return "_WeakProperty"; | 13664 return "_WeakProperty"; |
| 13654 } | 13665 } |
| 13655 | 13666 |
| 13656 } // namespace dart | 13667 } // namespace dart |
| OLD | NEW |