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 #ifndef VM_CLASS_FINALIZER_H_ | 5 #ifndef VM_CLASS_FINALIZER_H_ |
6 #define VM_CLASS_FINALIZER_H_ | 6 #define VM_CLASS_FINALIZER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 const Script& script, | 53 const Script& script, |
54 const Type& type, | 54 const Type& type, |
55 const char* format, ...) | 55 const char* format, ...) |
56 PRINTF_ATTRIBUTE(4, 5); | 56 PRINTF_ATTRIBUTE(4, 5); |
57 | 57 |
58 // Mark the given type as malbounded. | 58 // Mark the given type as malbounded. |
59 // If not null, prepend prev_error to the error message built from the format | 59 // If not null, prepend prev_error to the error message built from the format |
60 // string and its arguments. | 60 // string and its arguments. |
61 static void FinalizeMalboundedType(const Error& prev_error, | 61 static void FinalizeMalboundedType(const Error& prev_error, |
62 const Script& script, | 62 const Script& script, |
63 const Type& type, | 63 const AbstractType& type, |
64 const char* format, ...) | 64 const char* format, ...) |
65 PRINTF_ATTRIBUTE(4, 5); | 65 PRINTF_ATTRIBUTE(4, 5); |
66 | 66 |
67 // Return false if we still have classes pending to be finalized. | 67 // Return false if we still have classes pending to be finalized. |
68 static bool AllClassesFinalized(); | 68 static bool AllClassesFinalized(); |
69 | 69 |
70 // Return whether processing pending classes (ObjectStore::pending_classes_) | 70 // Return whether processing pending classes (ObjectStore::pending_classes_) |
71 // failed. The function returns true if the processing was successful. | 71 // failed. The function returns true if the processing was successful. |
72 // If processing fails, an error message is set in the sticky error field | 72 // If processing fails, an error message is set in the sticky error field |
73 // in the object store. | 73 // in the object store. |
74 static bool ProcessPendingClasses(); | 74 static bool ProcessPendingClasses(); |
75 | 75 |
76 // Finalize the types appearing in the declaration of class 'cls', i.e. its | 76 // Finalize the types appearing in the declaration of class 'cls', i.e. its |
77 // type parameters and their upper bounds, its super type and interfaces. | 77 // type parameters and their upper bounds, its super type and interfaces. |
78 // Note that the fields and functions have not been parsed yet (unless cls | 78 // Note that the fields and functions have not been parsed yet (unless cls |
79 // is an anonymous top level class). | 79 // is an anonymous top level class). |
80 static void FinalizeTypesInClass(const Class& cls); | 80 static void FinalizeTypesInClass(const Class& cls); |
81 | 81 |
82 // Finalize the class including its fields and functions. | 82 // Finalize the class including its fields and functions. |
83 static void FinalizeClass(const Class& cls); | 83 static void FinalizeClass(const Class& cls); |
84 | 84 |
85 #if defined(DART_NO_SNAPSHOT) | 85 #if defined(DART_NO_SNAPSHOT) |
86 // Verify that the classes have been properly prefinalized. This is | 86 // Verify that the classes have been properly prefinalized. This is |
87 // needed during bootstrapping where the classes have been preloaded. | 87 // needed during bootstrapping where the classes have been preloaded. |
88 static void VerifyBootstrapClasses(); | 88 static void VerifyBootstrapClasses(); |
89 #endif // defined(DART_NO_SNAPSHOT). | 89 #endif // defined(DART_NO_SNAPSHOT). |
90 | 90 |
91 // Resolve the class of the type, but not the type's type arguments. | 91 // Resolve the class of the type, but not the type's type arguments. |
92 static void ResolveTypeClass(const Class& cls, const AbstractType& type); | 92 // May promote the type from Type to FunctionType. |
| 93 static RawAbstractType* ResolveTypeClass(const Class& cls, const Type& type); |
93 | 94 |
94 // Resolve the type and target of the redirecting factory. | 95 // Resolve the type and target of the redirecting factory. |
95 static void ResolveRedirectingFactory(const Class& cls, | 96 static void ResolveRedirectingFactory(const Class& cls, |
96 const Function& factory); | 97 const Function& factory); |
97 | 98 |
98 // Apply the mixin type to the mixin application class. | 99 // Apply the mixin type to the mixin application class. |
99 static void ApplyMixinType(const Class& mixin_app_class, | 100 static void ApplyMixinType(const Class& mixin_app_class, |
100 PendingTypes* pending_types = NULL); | 101 PendingTypes* pending_types = NULL); |
101 | 102 |
102 private: | 103 private: |
103 static void AllocateEnumValues(const Class& enum_cls); | 104 static void AllocateEnumValues(const Class& enum_cls); |
104 static bool IsSuperCycleFree(const Class& cls); | 105 static bool IsSuperCycleFree(const Class& cls); |
105 static bool IsTypeCycleFree(const Class& cls, | 106 static bool IsTypedefCycleFree(const Class& cls, |
106 const AbstractType& type, | 107 const AbstractType& type, |
107 GrowableArray<intptr_t>* visited); | 108 GrowableArray<intptr_t>* visited); |
108 static bool IsAliasCycleFree(const Class& cls, | |
109 GrowableArray<intptr_t>* visited); | |
110 static bool IsMixinCycleFree(const Class& cls, | 109 static bool IsMixinCycleFree(const Class& cls, |
111 GrowableArray<intptr_t>* visited); | 110 GrowableArray<intptr_t>* visited); |
112 static void CheckForLegalConstClass(const Class& cls); | 111 static void CheckForLegalConstClass(const Class& cls); |
113 static RawClass* ResolveClass(const Class& cls, | 112 static RawClass* ResolveClass(const Class& cls, |
114 const UnresolvedClass& unresolved_class); | 113 const UnresolvedClass& unresolved_class); |
115 static void ResolveType(const Class& cls, const AbstractType& type); | 114 static RawAbstractType* ResolveType(const Class& cls, |
| 115 const AbstractType& type); |
116 static void ResolveRedirectingFactoryTarget( | 116 static void ResolveRedirectingFactoryTarget( |
117 const Class& cls, | 117 const Class& cls, |
118 const Function& factory, | 118 const Function& factory, |
119 const GrowableObjectArray& visited_factories); | 119 const GrowableObjectArray& visited_factories); |
120 static void CloneMixinAppTypeParameters(const Class& mixin_app_class); | 120 static void CloneMixinAppTypeParameters(const Class& mixin_app_class); |
121 static void ApplyMixinAppAlias(const Class& mixin_app_class, | 121 static void ApplyMixinAppAlias(const Class& mixin_app_class, |
122 const TypeArguments& instantiator); | 122 const TypeArguments& instantiator); |
123 static void ApplyMixinMembers(const Class& cls); | 123 static void ApplyMixinMembers(const Class& cls); |
124 static void CreateForwardingConstructors( | 124 static void CreateForwardingConstructors( |
125 const Class& mixin_app, | 125 const Class& mixin_app, |
126 const Class& mixin_cls, | 126 const Class& mixin_cls, |
127 const GrowableObjectArray& cloned_funcs); | 127 const GrowableObjectArray& cloned_funcs); |
128 static void CollectTypeArguments(const Class& cls, | 128 static void CollectTypeArguments(const Class& cls, |
129 const Type& type, | 129 const Type& type, |
130 const GrowableObjectArray& collected_args); | 130 const GrowableObjectArray& collected_args); |
131 static RawType* ResolveMixinAppType(const Class& cls, | 131 static RawType* ResolveMixinAppType(const Class& cls, |
132 const MixinAppType& mixin_app_type); | 132 const MixinAppType& mixin_app_type); |
133 static void ResolveSuperTypeAndInterfaces(const Class& cls, | 133 static void ResolveSuperTypeAndInterfaces(const Class& cls, |
134 GrowableArray<intptr_t>* visited); | 134 GrowableArray<intptr_t>* visited); |
135 static void FinalizeTypeParameters(const Class& cls, | 135 static void FinalizeTypeParameters(const Class& cls, |
136 PendingTypes* pending_types = NULL); | 136 PendingTypes* pending_types = NULL); |
| 137 static intptr_t ExpandAndFinalizeTypeArguments(const Class& cls, |
| 138 const AbstractType& type, |
| 139 PendingTypes* pending_types); |
137 static void FinalizeTypeArguments(const Class& cls, | 140 static void FinalizeTypeArguments(const Class& cls, |
138 const TypeArguments& arguments, | 141 const TypeArguments& arguments, |
139 intptr_t num_uninitialized_arguments, | 142 intptr_t num_uninitialized_arguments, |
140 Error* bound_error, | 143 Error* bound_error, |
141 PendingTypes* pending_types, | 144 PendingTypes* pending_types, |
142 TrailPtr trail); | 145 TrailPtr trail); |
143 static void CheckRecursiveType(const Class& cls, | 146 static void CheckRecursiveType(const Class& cls, |
144 const Type& type, | 147 const AbstractType& type, |
145 PendingTypes* pending_types); | 148 PendingTypes* pending_types); |
146 static void CheckTypeBounds(const Class& cls, const Type& type); | 149 static void CheckTypeBounds(const Class& cls, const AbstractType& type); |
147 static void CheckTypeArgumentBounds(const Class& cls, | 150 static void CheckTypeArgumentBounds(const Class& cls, |
148 const TypeArguments& arguments, | 151 const TypeArguments& arguments, |
149 Error* bound_error); | 152 Error* bound_error); |
150 static void ResolveUpperBounds(const Class& cls); | 153 static void ResolveUpperBounds(const Class& cls); |
151 static void FinalizeUpperBounds(const Class& cls); | 154 static void FinalizeUpperBounds(const Class& cls); |
152 static void ResolveAndFinalizeSignature(const Class& cls, | 155 static void ResolveSignature(const Class& cls, const Function& function); |
153 const Function& function); | 156 static void FinalizeSignature(const Class& cls, const Function& function); |
154 static void ResolveAndFinalizeMemberTypes(const Class& cls); | 157 static void ResolveAndFinalizeMemberTypes(const Class& cls); |
155 static void PrintClassInformation(const Class& cls); | 158 static void PrintClassInformation(const Class& cls); |
156 static void CollectInterfaces( | 159 static void CollectInterfaces( |
157 const Class& cls, GrowableArray<const Class*>* collected); | 160 const Class& cls, GrowableArray<const Class*>* collected); |
158 | 161 |
159 static void MarkTypeMalformed(const Error& prev_error, | 162 static void MarkTypeMalformed(const Error& prev_error, |
160 const Script& script, | 163 const Script& script, |
161 const Type& type, | 164 const Type& type, |
162 const char* format, | 165 const char* format, |
163 va_list args); | 166 va_list args); |
164 static void ReportError(const Error& error); | 167 static void ReportError(const Error& error); |
165 static void ReportError(const Class& cls, | 168 static void ReportError(const Class& cls, |
166 intptr_t token_pos, | 169 intptr_t token_pos, |
167 const char* format, ...) PRINTF_ATTRIBUTE(3, 4); | 170 const char* format, ...) PRINTF_ATTRIBUTE(3, 4); |
168 static void ReportErrors(const Error& prev_error, | 171 static void ReportErrors(const Error& prev_error, |
169 const Class& cls, | 172 const Class& cls, |
170 intptr_t token_pos, | 173 intptr_t token_pos, |
171 const char* format, ...) PRINTF_ATTRIBUTE(4, 5); | 174 const char* format, ...) PRINTF_ATTRIBUTE(4, 5); |
172 | 175 |
173 // Verify implicit offsets recorded in the VM for direct access to fields of | 176 // Verify implicit offsets recorded in the VM for direct access to fields of |
174 // Dart instances (e.g: _TypedListView, _ByteDataView). | 177 // Dart instances (e.g: _TypedListView, _ByteDataView). |
175 static void VerifyImplicitFieldOffsets(); | 178 static void VerifyImplicitFieldOffsets(); |
176 }; | 179 }; |
177 | 180 |
178 } // namespace dart | 181 } // namespace dart |
179 | 182 |
180 #endif // VM_CLASS_FINALIZER_H_ | 183 #endif // VM_CLASS_FINALIZER_H_ |
OLD | NEW |