2edb4ae9c7
Review URL: https://chromiumcodereview.appspot.com//9325047 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3965 260f80e4-7a28-3924-810f-c04153c831b5
106 lines
4.2 KiB
C++
106 lines
4.2 KiB
C++
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef VM_CLASS_FINALIZER_H_
|
|
#define VM_CLASS_FINALIZER_H_
|
|
|
|
#include "vm/allocation.h"
|
|
#include "vm/growable_array.h"
|
|
|
|
namespace dart {
|
|
|
|
class AbstractType;
|
|
class AbstractTypeArguments;
|
|
class Class;
|
|
class Error;
|
|
class Function;
|
|
class RawAbstractType;
|
|
class RawClass;
|
|
class RawType;
|
|
class Script;
|
|
class Type;
|
|
class UnresolvedClass;
|
|
|
|
// Traverses all pending, unfinalized classes, validates and marks them as
|
|
// finalized.
|
|
class ClassFinalizer : public AllStatic {
|
|
public:
|
|
enum {
|
|
kGeneratingSnapshot = true,
|
|
kNotGeneratingSnapshot = false
|
|
};
|
|
|
|
// 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(GrowableArray<AbstractType*>* interface_list,
|
|
AbstractType* interface,
|
|
AbstractType* conflicting);
|
|
|
|
// Finalize given type while parsing class cls.
|
|
// Also canonicalize type if applicable.
|
|
static RawAbstractType* FinalizeType(const Class& cls,
|
|
const AbstractType& type);
|
|
|
|
// Pending classes are classes that need to be finalized.
|
|
static void AddPendingClasses(const GrowableArray<const Class*>& classes);
|
|
|
|
// Return false if we still have classes pending to be finalized.
|
|
static bool AllClassesFinalized();
|
|
|
|
// Return whether class finalization failed.
|
|
// 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);
|
|
}
|
|
|
|
// Verify that the pending 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);
|
|
static bool IsSuperCycleFree(const Class& cls);
|
|
static void CheckForLegalConstClass(const Class& cls);
|
|
static RawClass* ResolveClass(const Class& cls,
|
|
const UnresolvedClass& unresolved_class);
|
|
static void ResolveSuperType(const Class& cls);
|
|
static void ResolveDefaultClass(const Class& cls);
|
|
static void ResolveInterfaces(const Class& cls,
|
|
GrowableArray<const Class*>* visited);
|
|
static void FinalizeTypeArguments(const Class& cls,
|
|
const AbstractTypeArguments& arguments);
|
|
static void ResolveType(const Class& cls, const AbstractType& type);
|
|
static void ResolveAndFinalizeUpperBounds(const Class& cls);
|
|
static void VerifyUpperBounds(const Class& cls,
|
|
const AbstractTypeArguments& arguments);
|
|
static void ResolveAndFinalizeSignature(const Class& cls,
|
|
const Function& function);
|
|
static void ResolveAndFinalizeMemberTypes(const Class& cls);
|
|
static void PrintClassInformation(const Class& cls);
|
|
static void VerifyClassImplements(const Class& cls);
|
|
static void CollectInterfaces(const Class& cls,
|
|
GrowableArray<const Class*>* interfaces);
|
|
static void ReportError(const Script& script,
|
|
intptr_t token_index,
|
|
const char* format, ...);
|
|
static void ReportError(const char* format, ...);
|
|
static void ReportWarning(const Script& script,
|
|
intptr_t token_index,
|
|
const char* format, ...);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // VM_CLASS_FINALIZER_H_
|