-// ValTypeBase - This is the base class that is used by the various
-// instantiations of TypeMap. This class is an AbstractType user that notifies
-// the underlying TypeMap when it gets modified.
-//
-template<class ValType, class TypeClass>
-class ValTypeBase : public AbstractTypeUser {
- TypeMap<ValType, TypeClass> &MyTable;
-protected:
- inline ValTypeBase(TypeMap<ValType, TypeClass> &tab) : MyTable(tab) {}
-
- // Subclass should override this... to update self as usual
- virtual void doRefinement(const DerivedType *OldTy, const Type *NewTy) = 0;
-
- // typeBecameConcrete - This callback occurs when a contained type refines
- // to itself, but becomes concrete in the process. Our subclass should remove
- // itself from the ATU list of the specified type.
- //
- virtual void typeBecameConcrete(const DerivedType *Ty) = 0;
-
- virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
- assert(OldTy == NewTy || OldTy->isAbstract());
-
- if (!OldTy->isAbstract())
- typeBecameConcrete(OldTy);
-
- TypeMap<ValType, TypeClass> &Table = MyTable; // Copy MyTable reference
- ValType Tmp(*(ValType*)this); // Copy this.
- PATypeHandle OldType(Table.get(*(ValType*)this), this);
- Table.remove(*(ValType*)this); // Destroy's this!
-
- // Refine temporary to new state...
- if (OldTy != NewTy)
- Tmp.doRefinement(OldTy, NewTy);
-
- // FIXME: when types are not const!
- Table.add((ValType&)Tmp, (TypeClass*)OldType.get());
- }
-
- void dump() const {
- std::cerr << "ValTypeBase instance!\n";
- }
-};
-
-