Index: runtime/vm/class_finalizer.h |
=================================================================== |
--- runtime/vm/class_finalizer.h (revision 11113) |
+++ runtime/vm/class_finalizer.h (working copy) |
@@ -25,23 +25,16 @@ |
// Traverses all pending, unfinalized classes, validates and marks them as |
// finalized. |
-class ClassFinalizer : public AllStatic { |
+class ClassFinalizer : public ValueObject { |
public: |
+ // Malformed types will not be tolerated when generating a snapshot. |
enum { |
kGeneratingSnapshot = true, |
hausner
2012/08/22 00:15:39
Shouldn't the constants be named for what they aff
regis
2012/08/22 02:24:26
Agreed. Note that the enum predated this cl. Also,
|
kNotGeneratingSnapshot = false |
}; |
+ explicit ClassFinalizer(bool generating_snapshot) |
hausner
2012/08/22 00:15:39
cf above. I would call this parameter "tolerate_ma
regis
2012/08/22 02:24:26
Would it be strange to check for native resolver o
|
+ : generating_snapshot_(generating_snapshot) { } |
- // Add 'interface' to 'interface_list' if it is not already in the list and |
- // return true. Also return true if 'interface' is not added, because it is |
- // not unique, i.e. it is already in the list. |
- // Return false if 'interface' conflicts with an interface already in the list |
- // with the same class, but different type arguments. |
- // In the case of a conflict, set 'conflicting' to the existing interface. |
- static bool AddInterfaceIfUnique(const GrowableObjectArray& interface_list, |
- const AbstractType& interface, |
- AbstractType* conflicting); |
- |
// Modes for type resolution and finalization. The ordering is relevant. |
enum FinalizationKind { |
kIgnore, // Parsed type is ignored and replaced by Dynamic. |
@@ -57,63 +50,63 @@ |
// Finalize given type while parsing class cls. |
// Also canonicalize type if applicable. |
- static RawAbstractType* FinalizeType(const Class& cls, |
- const AbstractType& type, |
- FinalizationKind finalization); |
+ RawAbstractType* FinalizeType(const Class& cls, |
+ const AbstractType& type, |
+ FinalizationKind finalization) const; |
// Replace the malformed type with Dynamic and, depending on the given type |
// finalization mode and execution mode, mark the type as malformed or report |
// a compile time error. Prepend prev_error if not null. |
- static void FinalizeMalformedType(const Error& prev_error, |
- const Class& cls, |
- const Type& type, |
- FinalizationKind finalization, |
- const char* format, ...); |
+ void FinalizeMalformedType(const Error& prev_error, |
+ const Class& cls, |
+ const Type& type, |
+ FinalizationKind finalization, |
+ const char* format, ...) const; |
- // Return false if we still have classes pending to be finalized. |
+ // The function returns true if the finalization was successful. |
+ // If finalization fails, an error message is set in the sticky error field |
+ // in the object store. |
+ // Malformed types are tolerated or not, depending on the finalizer instance. |
+ bool FinalizePendingClasses() const; |
+ |
+ // Return false if we still have classes to be finalized. |
static bool AllClassesFinalized(); |
- // Return whether class finalization failed. |
+ // Convenience function finalizing all pending classes when not generating a |
+ // snapshot (malformed types are tolerated). |
// The function returns true if the finalization was successful. |
// If finalization fails, an error message is set in the sticky error field |
// in the object store. |
- static bool FinalizePendingClasses() { |
- return FinalizePendingClasses(kNotGeneratingSnapshot); |
- } |
- static bool FinalizePendingClassesForSnapshotCreation() { |
- return FinalizePendingClasses(kGeneratingSnapshot); |
- } |
+ static bool FinalizeAllClasses(); |
- // Verify that the pending classes have been properly prefinalized. This is |
+ // Verify that the classes have been properly prefinalized. This is |
// needed during bootstrapping where the classes have been preloaded. |
static void VerifyBootstrapClasses(); |
private: |
- static bool FinalizePendingClasses(bool generating_snapshot); |
- static void FinalizeClass(const Class& cls, bool generating_snapshot); |
+ void FinalizeClass(const Class& cls) const; |
static bool IsSuperCycleFree(const Class& cls); |
- static bool IsAliasCycleFree(const Class& cls, |
- GrowableArray<intptr_t>* visited); |
+ bool IsAliasCycleFree(const Class& cls, |
+ GrowableArray<intptr_t>* visited) const; |
static void CheckForLegalConstClass(const Class& cls); |
static RawClass* ResolveClass(const Class& cls, |
const UnresolvedClass& unresolved_class); |
- static void ResolveSuperType(const Class& cls); |
+ void ResolveSuperType(const Class& cls) const; |
static void ResolveFactoryClass(const Class& cls); |
- static void ResolveInterfaces(const Class& cls, |
- GrowableArray<intptr_t>* visited); |
- static void FinalizeTypeParameters(const Class& cls); |
- static void FinalizeTypeArguments(const Class& cls, |
- const AbstractTypeArguments& arguments, |
- FinalizationKind finalization); |
- static void ResolveType(const Class& cls, |
- const AbstractType& type, |
- FinalizationKind finalization); |
- static void ResolveAndFinalizeUpperBounds(const Class& cls); |
- static void ResolveAndFinalizeSignature(const Class& cls, |
- const Function& function); |
- static void ResolveAndFinalizeMemberTypes(const Class& cls); |
+ void ResolveInterfaces(const Class& cls, |
+ GrowableArray<intptr_t>* visited) const; |
+ void FinalizeTypeParameters(const Class& cls) const; |
+ void FinalizeTypeArguments(const Class& cls, |
+ const AbstractTypeArguments& arguments, |
+ FinalizationKind finalization) const; |
+ void ResolveType(const Class& cls, |
+ const AbstractType& type, |
+ FinalizationKind finalization) const; |
+ void ResolveAndFinalizeUpperBounds(const Class& cls) const; |
+ void ResolveAndFinalizeSignature(const Class& cls, |
+ const Function& function) const; |
+ void ResolveAndFinalizeMemberTypes(const Class& cls) const; |
static void PrintClassInformation(const Class& cls); |
- static void VerifyClassImplements(const Class& cls); |
static void CollectInterfaces(const Class& cls, |
const GrowableObjectArray& interfaces); |
static void ReportError(const Error& error); |
@@ -121,6 +114,10 @@ |
intptr_t token_index, |
const char* format, ...); |
static void ReportError(const char* format, ...); |
+ |
+ const bool generating_snapshot_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ClassFinalizer); |
}; |
} // namespace dart |