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 16857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16868 intptr_t len = num_type_args; // Check the full vector of type args. | 16868 intptr_t len = num_type_args; // Check the full vector of type args. |
16869 ASSERT(num_type_args > 0); | 16869 ASSERT(num_type_args > 0); |
16870 // This type is not instantiated if it refers to type parameters. | 16870 // This type is not instantiated if it refers to type parameters. |
16871 // Although this type may still be unresolved, the type parameters it may | 16871 // Although this type may still be unresolved, the type parameters it may |
16872 // refer to are resolved by definition. We can therefore return the correct | 16872 // refer to are resolved by definition. We can therefore return the correct |
16873 // result even for an unresolved type. We just need to look at all type | 16873 // result even for an unresolved type. We just need to look at all type |
16874 // arguments and not just at the type parameters. | 16874 // arguments and not just at the type parameters. |
16875 if (HasResolvedTypeClass()) { | 16875 if (HasResolvedTypeClass()) { |
16876 const Class& cls = Class::Handle(type_class()); | 16876 const Class& cls = Class::Handle(type_class()); |
16877 len = cls.NumTypeParameters(); // Check the type parameters only. | 16877 len = cls.NumTypeParameters(); // Check the type parameters only. |
| 16878 if (len > num_type_args) { |
| 16879 // This type has the wrong number of arguments and is not finalized yet. |
| 16880 // Type arguments are reset to null when finalizing such a type. |
| 16881 ASSERT(!IsFinalized()); |
| 16882 len = num_type_args; |
| 16883 } |
16878 } | 16884 } |
16879 return (len == 0) || | 16885 return (len == 0) || |
16880 args.IsSubvectorInstantiated(num_type_args - len, len, genericity, | 16886 args.IsSubvectorInstantiated(num_type_args - len, len, genericity, |
16881 trail); | 16887 trail); |
16882 } | 16888 } |
16883 | 16889 |
16884 | 16890 |
16885 RawAbstractType* Type::InstantiateFrom( | 16891 RawAbstractType* Type::InstantiateFrom( |
16886 const TypeArguments& instantiator_type_arguments, | 16892 const TypeArguments& instantiator_type_arguments, |
16887 Error* bound_error, | 16893 Error* bound_error, |
(...skipping 26 matching lines...) Expand all Loading... |
16914 } | 16920 } |
16915 // This uninstantiated type is not modified, as it can be instantiated | 16921 // This uninstantiated type is not modified, as it can be instantiated |
16916 // with different instantiators. Allocate a new instantiated version of it. | 16922 // with different instantiators. Allocate a new instantiated version of it. |
16917 const Type& instantiated_type = | 16923 const Type& instantiated_type = |
16918 Type::Handle(zone, Type::New(cls, type_arguments, token_pos(), space)); | 16924 Type::Handle(zone, Type::New(cls, type_arguments, token_pos(), space)); |
16919 // Preserve the bound error if any. | 16925 // Preserve the bound error if any. |
16920 if (IsMalbounded()) { | 16926 if (IsMalbounded()) { |
16921 const LanguageError& bound_error = LanguageError::Handle(zone, error()); | 16927 const LanguageError& bound_error = LanguageError::Handle(zone, error()); |
16922 instantiated_type.set_error(bound_error); | 16928 instantiated_type.set_error(bound_error); |
16923 } | 16929 } |
16924 // If this type is a function type, instantiate its signature. | 16930 // For a function type, possibly instantiate and set its signature. |
16925 if (!sig_fun.IsNull()) { | 16931 if (!sig_fun.IsNull()) { |
16926 // If we are finalizing a typedef, do not yet instantiate its signature. | 16932 // If we are finalizing a typedef, do not yet instantiate its signature, |
16927 // Other function types should never be instantiated while unfinalized. | 16933 // since it gets instantiated just before the type is marked as finalized. |
| 16934 // Other function types should never get instantiated while unfinalized, |
| 16935 // even while checking bounds of recursive types. |
16928 if (IsFinalized()) { | 16936 if (IsFinalized()) { |
16929 // A generic typedef may actually declare an instantiated signature. | 16937 // A generic typedef may actually declare an instantiated signature. |
16930 if (!sig_fun.HasInstantiatedSignature()) { | 16938 if (!sig_fun.HasInstantiatedSignature()) { |
16931 sig_fun = sig_fun.InstantiateSignatureFrom(instantiator_type_arguments, | 16939 sig_fun = sig_fun.InstantiateSignatureFrom(instantiator_type_arguments, |
16932 space); | 16940 space); |
16933 } | 16941 } |
16934 } else { | 16942 } else { |
16935 ASSERT(cls.IsTypedefClass()); | 16943 // The Kernel frontend does not keep the information that a function type |
| 16944 // is a typedef, so we cannot assert that cls.IsTypedefClass(). |
16936 } | 16945 } |
16937 instantiated_type.set_signature(sig_fun); | 16946 instantiated_type.set_signature(sig_fun); |
16938 } | 16947 } |
16939 if (IsFinalized()) { | 16948 if (IsFinalized()) { |
16940 instantiated_type.SetIsFinalized(); | 16949 instantiated_type.SetIsFinalized(); |
16941 } else { | 16950 } else { |
16942 instantiated_type.SetIsResolved(); | 16951 instantiated_type.SetIsResolved(); |
16943 if (IsBeingFinalized()) { | 16952 if (IsBeingFinalized()) { |
16944 instantiated_type.SetIsBeingFinalized(); | 16953 instantiated_type.SetIsBeingFinalized(); |
16945 } | 16954 } |
(...skipping 6129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23075 return UserTag::null(); | 23084 return UserTag::null(); |
23076 } | 23085 } |
23077 | 23086 |
23078 | 23087 |
23079 const char* UserTag::ToCString() const { | 23088 const char* UserTag::ToCString() const { |
23080 const String& tag_label = String::Handle(label()); | 23089 const String& tag_label = String::Handle(label()); |
23081 return tag_label.ToCString(); | 23090 return tag_label.ToCString(); |
23082 } | 23091 } |
23083 | 23092 |
23084 } // namespace dart | 23093 } // namespace dart |
OLD | NEW |