| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 class AbstractType; | 13 class AbstractType; |
| 14 class Class; | 14 class Class; |
| 15 class Function; | 15 class Function; |
| 16 class RawAbstractType; | 16 class RawAbstractType; |
| 17 class RawClass; | 17 class RawClass; |
| 18 class RawType; |
| 18 class Script; | 19 class Script; |
| 19 class String; | 20 class String; |
| 21 class Type; |
| 20 class TypeArguments; | 22 class TypeArguments; |
| 21 class UnresolvedClass; | 23 class UnresolvedClass; |
| 22 | 24 |
| 23 // Traverses all pending, unfinalized classes, validates and marks them as | 25 // Traverses all pending, unfinalized classes, validates and marks them as |
| 24 // finalized. | 26 // finalized. |
| 25 class ClassFinalizer : public AllStatic { | 27 class ClassFinalizer : public AllStatic { |
| 26 public: | 28 public: |
| 27 enum { | 29 enum { |
| 28 kGeneratingSnapshot = true, | 30 kGeneratingSnapshot = true, |
| 29 kNotGeneratingSnapshot = false | 31 kNotGeneratingSnapshot = false |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 // Add 'interface' to 'interface_list' if it is not already in the list and | 34 // Add 'interface' to 'interface_list' if it is not already in the list and |
| 33 // return true. Also return true if 'interface' is not added, because it is | 35 // return true. Also return true if 'interface' is not added, because it is |
| 34 // not unique, i.e. it is already in the list. | 36 // not unique, i.e. it is already in the list. |
| 35 // Return false if 'interface' conflicts with an interface already in the list | 37 // Return false if 'interface' conflicts with an interface already in the list |
| 36 // with the same class, but different type arguments. | 38 // with the same class, but different type arguments. |
| 37 // In the case of a conflict, set 'conflicting' to the existing interface. | 39 // In the case of a conflict, set 'conflicting' to the existing interface. |
| 38 static bool AddInterfaceIfUnique(GrowableArray<AbstractType*>* interface_list, | 40 static bool AddInterfaceIfUnique(GrowableArray<AbstractType*>* interface_list, |
| 39 AbstractType* interface, | 41 AbstractType* interface, |
| 40 AbstractType* conflicting); | 42 AbstractType* conflicting); |
| 41 | 43 |
| 42 // Finalize and canonicalize type while parsing. | 44 // Finalize and canonicalize type while parsing. |
| 43 // Set the error message on failure (to String::null() if no error). | 45 // Set the error message on failure (to String::null() if no error). |
| 44 static RawAbstractType* FinalizeAndCanonicalizeType( | 46 static RawType* FinalizeAndCanonicalizeType(const Type& type, String* errmsg); |
| 45 const AbstractType& type, String* errmsg); | |
| 46 | 47 |
| 47 // Pending classes are classes that need to be finalized. | 48 // Pending classes are classes that need to be finalized. |
| 48 static void AddPendingClasses(const GrowableArray<const Class*>& classes); | 49 static void AddPendingClasses(const GrowableArray<const Class*>& classes); |
| 49 | 50 |
| 50 // Return false if we still have classes pending to be finalized. | 51 // Return false if we still have classes pending to be finalized. |
| 51 static bool AllClassesFinalized(); | 52 static bool AllClassesFinalized(); |
| 52 | 53 |
| 53 // Return whether class finalization failed. | 54 // Return whether class finalization failed. |
| 54 // The function returns true if the finalization was successful. | 55 // The function returns true if the finalization was successful. |
| 55 // If finalization fails, an error message is set in the sticky error field | 56 // If finalization fails, an error message is set in the sticky error field |
| (...skipping 15 matching lines...) Expand all Loading... |
| 71 static bool IsSuperCycleFree(const Class& cls); | 72 static bool IsSuperCycleFree(const Class& cls); |
| 72 static void CheckForLegalConstClass(const Class& cls); | 73 static void CheckForLegalConstClass(const Class& cls); |
| 73 static RawClass* ResolveClass(const Class& cls, | 74 static RawClass* ResolveClass(const Class& cls, |
| 74 const UnresolvedClass& unresolved_class); | 75 const UnresolvedClass& unresolved_class); |
| 75 static void ResolveSuperType(const Class& cls); | 76 static void ResolveSuperType(const Class& cls); |
| 76 static void ResolveFactoryClass(const Class& cls); | 77 static void ResolveFactoryClass(const Class& cls); |
| 77 static void ResolveInterfaces(const Class& cls, | 78 static void ResolveInterfaces(const Class& cls, |
| 78 GrowableArray<const Class*>* visited); | 79 GrowableArray<const Class*>* visited); |
| 79 static void FinalizeTypeArguments(const Class& cls, | 80 static void FinalizeTypeArguments(const Class& cls, |
| 80 const TypeArguments& arguments); | 81 const TypeArguments& arguments); |
| 81 static RawAbstractType* ResolveType( | 82 static void ResolveType(const Class& cls, const AbstractType& type); |
| 82 const Class& cls, const AbstractType& type); | |
| 83 static RawAbstractType* FinalizeType(const AbstractType& type); | 83 static RawAbstractType* FinalizeType(const AbstractType& type); |
| 84 static void ResolveAndFinalizeUpperBounds(const Class& cls); | 84 static void ResolveAndFinalizeUpperBounds(const Class& cls); |
| 85 static void VerifyUpperBounds(const Class& cls, | 85 static void VerifyUpperBounds(const Class& cls, |
| 86 const TypeArguments& arguments); | 86 const TypeArguments& arguments); |
| 87 static void ResolveAndFinalizeSignature(const Class& cls, | 87 static void ResolveAndFinalizeSignature(const Class& cls, |
| 88 const Function& function); | 88 const Function& function); |
| 89 static void ResolveAndFinalizeMemberTypes(const Class& cls); | 89 static void ResolveAndFinalizeMemberTypes(const Class& cls); |
| 90 static void PrintClassInformation(const Class& cls); | 90 static void PrintClassInformation(const Class& cls); |
| 91 static void VerifyClassImplements(const Class& cls); | 91 static void VerifyClassImplements(const Class& cls); |
| 92 static void CollectInterfaces(const Class& cls, | 92 static void CollectInterfaces(const Class& cls, |
| 93 GrowableArray<const Class*>* interfaces); | 93 GrowableArray<const Class*>* interfaces); |
| 94 static void ReportError(const Script& script, | 94 static void ReportError(const Script& script, |
| 95 intptr_t token_index, | 95 intptr_t token_index, |
| 96 const char* format, ...); | 96 const char* format, ...); |
| 97 static void ReportError(const char* format, ...); | 97 static void ReportError(const char* format, ...); |
| 98 static void ReportWarning(const Script& script, | 98 static void ReportWarning(const Script& script, |
| 99 intptr_t token_index, | 99 intptr_t token_index, |
| 100 const char* format, ...); | 100 const char* format, ...); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace dart | 103 } // namespace dart |
| 104 | 104 |
| 105 #endif // VM_CLASS_FINALIZER_H_ | 105 #endif // VM_CLASS_FINALIZER_H_ |
| OLD | NEW |