| 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 RUNTIME_VM_CLASS_FINALIZER_H_ | 5 #ifndef RUNTIME_VM_CLASS_FINALIZER_H_ |
| 6 #define RUNTIME_VM_CLASS_FINALIZER_H_ | 6 #define RUNTIME_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" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 // Traverses all pending, unfinalized classes, validates and marks them as | 14 // Traverses all pending, unfinalized classes, validates and marks them as |
| 15 // finalized. | 15 // finalized. |
| 16 class ClassFinalizer : public AllStatic { | 16 class ClassFinalizer : public AllStatic { |
| 17 public: | 17 public: |
| 18 typedef ZoneGrowableHandlePtrArray<const AbstractType> PendingTypes; | 18 typedef ZoneGrowableHandlePtrArray<const AbstractType> PendingTypes; |
| 19 | 19 |
| 20 // Modes for type resolution and finalization. The ordering is relevant. | 20 // Modes for type resolution and finalization. The ordering is relevant. |
| 21 enum FinalizationKind { | 21 enum FinalizationKind { |
| 22 kIgnore, // Type is ignored and replaced by dynamic. | 22 kIgnore, // Type is ignored and replaced by dynamic. |
| 23 kDoNotResolve, // Type resolution is postponed. | 23 kDoNotResolve, // Type resolution is postponed. |
| 24 kResolveTypeParameters, // Resolve type parameters only. | 24 kResolveTypeParameters, // Resolve type parameters only. |
| 25 kFinalize, // Type resolution and finalization are required. | 25 kFinalize, // Resolve and finalize type and type arguments. |
| 26 kCanonicalize, // Same as kFinalize, but with canonicalization. | 26 kCanonicalize // Finalize, check bounds, and canonicalize. |
| 27 kCanonicalizeWellFormed // Error-free resolution, finalization, and | |
| 28 // canonicalization are required. | |
| 29 }; | 27 }; |
| 30 | 28 |
| 31 // Finalize given type while parsing class cls. | 29 // Finalize given type while parsing class cls. |
| 32 // Also canonicalize type if applicable. | 30 // Also canonicalize and bound check type if applicable. |
| 33 static RawAbstractType* FinalizeType(const Class& cls, | 31 static RawAbstractType* FinalizeType( |
| 34 const AbstractType& type, | 32 const Class& cls, |
| 35 FinalizationKind finalization, | 33 const AbstractType& type, |
| 36 PendingTypes* pending_types = NULL); | 34 FinalizationKind finalization = kCanonicalize, |
| 35 PendingTypes* pending_types = NULL); |
| 37 | 36 |
| 38 // Finalize the types in the functions's signature while parsing class cls. | 37 // Finalize the types in the functions's signature while parsing class cls. |
| 39 static void FinalizeSignature(const Class& cls, const Function& function); | 38 static void FinalizeSignature(const Class& cls, |
| 39 const Function& function, |
| 40 FinalizationKind finalization = kCanonicalize); |
| 40 | 41 |
| 41 // Allocate, finalize, and return a new malformed type as if it was declared | 42 // Allocate, finalize, and return a new malformed type as if it was declared |
| 42 // in class cls at the given token position. | 43 // in class cls at the given token position. |
| 43 // If not null, prepend prev_error to the error message built from the format | 44 // If not null, prepend prev_error to the error message built from the format |
| 44 // string and its arguments. | 45 // string and its arguments. |
| 45 static RawType* NewFinalizedMalformedType(const Error& prev_error, | 46 static RawType* NewFinalizedMalformedType(const Error& prev_error, |
| 46 const Script& script, | 47 const Script& script, |
| 47 TokenPosition type_pos, | 48 TokenPosition type_pos, |
| 48 const char* format, | 49 const char* format, |
| 49 ...) PRINTF_ATTRIBUTE(4, 5); | 50 ...) PRINTF_ATTRIBUTE(4, 5); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 PendingTypes* pending_types, | 152 PendingTypes* pending_types, |
| 152 TrailPtr trail); | 153 TrailPtr trail); |
| 153 static void CheckRecursiveType(const Class& cls, | 154 static void CheckRecursiveType(const Class& cls, |
| 154 const AbstractType& type, | 155 const AbstractType& type, |
| 155 PendingTypes* pending_types); | 156 PendingTypes* pending_types); |
| 156 static void CheckTypeBounds(const Class& cls, const AbstractType& type); | 157 static void CheckTypeBounds(const Class& cls, const AbstractType& type); |
| 157 static void CheckTypeArgumentBounds(const Class& cls, | 158 static void CheckTypeArgumentBounds(const Class& cls, |
| 158 const TypeArguments& arguments, | 159 const TypeArguments& arguments, |
| 159 Error* bound_error); | 160 Error* bound_error); |
| 160 static void ResolveUpperBounds(const Class& cls); | 161 static void ResolveUpperBounds(const Class& cls); |
| 161 static void FinalizeUpperBounds(const Class& cls, | 162 static void FinalizeUpperBounds( |
| 162 FinalizationKind finalization); | 163 const Class& cls, |
| 164 FinalizationKind finalization = kCanonicalize); |
| 163 static void ResolveSignature(const Class& cls, const Function& function); | 165 static void ResolveSignature(const Class& cls, const Function& function); |
| 164 static void ResolveAndFinalizeMemberTypes(const Class& cls); | 166 static void ResolveAndFinalizeMemberTypes(const Class& cls); |
| 165 static void PrintClassInformation(const Class& cls); | 167 static void PrintClassInformation(const Class& cls); |
| 166 static void CollectInterfaces(const Class& cls, | 168 static void CollectInterfaces(const Class& cls, |
| 167 GrowableArray<const Class*>* collected); | 169 GrowableArray<const Class*>* collected); |
| 168 | 170 |
| 169 static void MarkTypeMalformed(const Error& prev_error, | 171 static void MarkTypeMalformed(const Error& prev_error, |
| 170 const Script& script, | 172 const Script& script, |
| 171 const Type& type, | 173 const Type& type, |
| 172 const char* format, | 174 const char* format, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 ...) PRINTF_ATTRIBUTE(4, 5); | 185 ...) PRINTF_ATTRIBUTE(4, 5); |
| 184 | 186 |
| 185 // Verify implicit offsets recorded in the VM for direct access to fields of | 187 // Verify implicit offsets recorded in the VM for direct access to fields of |
| 186 // Dart instances (e.g: _TypedListView, _ByteDataView). | 188 // Dart instances (e.g: _TypedListView, _ByteDataView). |
| 187 static void VerifyImplicitFieldOffsets(); | 189 static void VerifyImplicitFieldOffsets(); |
| 188 }; | 190 }; |
| 189 | 191 |
| 190 } // namespace dart | 192 } // namespace dart |
| 191 | 193 |
| 192 #endif // RUNTIME_VM_CLASS_FINALIZER_H_ | 194 #endif // RUNTIME_VM_CLASS_FINALIZER_H_ |
| OLD | NEW |