Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, 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 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 34 // 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 |
| 35 // 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 |
| 36 // not unique, i.e. it is already in the list. | 36 // not unique, i.e. it is already in the list. |
| 37 // 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 |
| 38 // with the same class, but different type arguments. | 38 // with the same class, but different type arguments. |
| 39 // 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. |
| 40 static bool AddInterfaceIfUnique(GrowableArray<AbstractType*>* interface_list, | 40 static bool AddInterfaceIfUnique(GrowableArray<AbstractType*>* interface_list, |
| 41 AbstractType* interface, | 41 AbstractType* interface, |
| 42 AbstractType* conflicting); | 42 AbstractType* conflicting); |
| 43 | 43 |
| 44 enum TypeFinalization { | |
|
srdjan
2012/02/29 00:15:54
Maybe FinalizationKind is a better name?
regis
2012/02/29 02:10:01
Renamed to FinalizationMode.
| |
| 45 kIgnore, // Parsed type is ignored and replaced by Dynamic. | |
| 46 kDoNotResolve, // Type resolution is postponed. | |
| 47 kTryResolve, // Type resolution is attempted, but not required. | |
| 48 kFinalize, // Type resolution and type finalization are required. | |
| 49 // A malformed type is tolerated. | |
| 50 kFinalizeWellFormed // Error-free resolution and finalization are required. | |
|
hausner
2012/02/28 23:52:59
There is at least one place in the parser where yo
regis
2012/02/29 00:05:23
Done.
| |
| 51 // A malformed type is not tolerated. | |
| 52 }; | |
| 53 | |
| 44 // Finalize given type while parsing class cls. | 54 // Finalize given type while parsing class cls. |
| 45 // Also canonicalize type if applicable. | 55 // Also canonicalize type if applicable. |
| 46 static RawAbstractType* FinalizeType(const Class& cls, | 56 static RawAbstractType* FinalizeType(const Class& cls, |
| 47 const AbstractType& type); | 57 const AbstractType& type, |
| 58 TypeFinalization finalization); | |
| 59 | |
| 60 // Replace the malformed type with Dynamic and, depending on the given type | |
| 61 // finalization mode and execution mode, mark the type as malformed or report | |
| 62 // a compile time error. | |
| 63 static void FinalizeMalformedType(const Class& cls, | |
| 64 const Type& type, | |
| 65 TypeFinalization finalization, | |
| 66 const char* format, ...); | |
| 48 | 67 |
| 49 // Pending classes are classes that need to be finalized. | 68 // Pending classes are classes that need to be finalized. |
| 50 static void AddPendingClasses(const GrowableArray<const Class*>& classes); | 69 static void AddPendingClasses(const GrowableArray<const Class*>& classes); |
| 51 | 70 |
| 52 // Return false if we still have classes pending to be finalized. | 71 // Return false if we still have classes pending to be finalized. |
| 53 static bool AllClassesFinalized(); | 72 static bool AllClassesFinalized(); |
| 54 | 73 |
| 55 // Return whether class finalization failed. | 74 // Return whether class finalization failed. |
| 56 // The function returns true if the finalization was successful. | 75 // The function returns true if the finalization was successful. |
| 57 // If finalization fails, an error message is set in the sticky error field | 76 // If finalization fails, an error message is set in the sticky error field |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 72 static void FinalizeClass(const Class& cls, bool generating_snapshot); | 91 static void FinalizeClass(const Class& cls, bool generating_snapshot); |
| 73 static bool IsSuperCycleFree(const Class& cls); | 92 static bool IsSuperCycleFree(const Class& cls); |
| 74 static void CheckForLegalConstClass(const Class& cls); | 93 static void CheckForLegalConstClass(const Class& cls); |
| 75 static RawClass* ResolveClass(const Class& cls, | 94 static RawClass* ResolveClass(const Class& cls, |
| 76 const UnresolvedClass& unresolved_class); | 95 const UnresolvedClass& unresolved_class); |
| 77 static void ResolveSuperType(const Class& cls); | 96 static void ResolveSuperType(const Class& cls); |
| 78 static void ResolveDefaultClass(const Class& cls); | 97 static void ResolveDefaultClass(const Class& cls); |
| 79 static void ResolveInterfaces(const Class& cls, | 98 static void ResolveInterfaces(const Class& cls, |
| 80 GrowableArray<const Class*>* visited); | 99 GrowableArray<const Class*>* visited); |
| 81 static void FinalizeTypeArguments(const Class& cls, | 100 static void FinalizeTypeArguments(const Class& cls, |
| 82 const AbstractTypeArguments& arguments); | 101 const AbstractTypeArguments& arguments, |
| 83 static void ResolveType(const Class& cls, const AbstractType& type); | 102 TypeFinalization finalization); |
| 103 static void ResolveType(const Class& cls, | |
| 104 const AbstractType& type, | |
| 105 TypeFinalization finalization); | |
| 84 static void ResolveAndFinalizeUpperBounds(const Class& cls); | 106 static void ResolveAndFinalizeUpperBounds(const Class& cls); |
| 85 static void ResolveAndFinalizeSignature(const Class& cls, | 107 static void ResolveAndFinalizeSignature(const Class& cls, |
| 86 const Function& function); | 108 const Function& function); |
| 87 static void ResolveAndFinalizeMemberTypes(const Class& cls); | 109 static void ResolveAndFinalizeMemberTypes(const Class& cls); |
| 88 static void PrintClassInformation(const Class& cls); | 110 static void PrintClassInformation(const Class& cls); |
| 89 static void VerifyClassImplements(const Class& cls); | 111 static void VerifyClassImplements(const Class& cls); |
| 90 static void CollectInterfaces(const Class& cls, | 112 static void CollectInterfaces(const Class& cls, |
| 91 GrowableArray<const Class*>* interfaces); | 113 GrowableArray<const Class*>* interfaces); |
| 114 static void ReportError(const Error& error); | |
| 92 static void ReportError(const Script& script, | 115 static void ReportError(const Script& script, |
| 93 intptr_t token_index, | 116 intptr_t token_index, |
| 94 const char* format, ...); | 117 const char* format, ...); |
| 95 static void ReportError(const char* format, ...); | 118 static void ReportError(const char* format, ...); |
| 96 static void ReportWarning(const Script& script, | |
| 97 intptr_t token_index, | |
| 98 const char* format, ...); | |
| 99 }; | 119 }; |
| 100 | 120 |
| 101 } // namespace dart | 121 } // namespace dart |
| 102 | 122 |
| 103 #endif // VM_CLASS_FINALIZER_H_ | 123 #endif // VM_CLASS_FINALIZER_H_ |
| OLD | NEW |