-
-// Define some inline methods for the AbstractTypeUser.h:PATypeHandle class.
-// These are defined here because they MUST be inlined, yet are dependent on
-// the definition of the Type class. Of course Type derives from Value, which
-// contains an AbstractTypeUser instance, so there is no good way to factor out
-// the code. Hence this bit of uglyness.
-//
-inline void PATypeHandle::addUser() {
- assert(Ty && "Type Handle has a null type!");
- if (Ty->isAbstract())
- cast<DerivedType>(Ty)->addAbstractTypeUser(User);
-}
-inline void PATypeHandle::removeUser() {
- if (Ty->isAbstract())
- cast<DerivedType>(Ty)->removeAbstractTypeUser(User);
-}
-
-inline void PATypeHandle::removeUserFromConcrete() {
- if (!Ty->isAbstract())
- cast<DerivedType>(Ty)->removeAbstractTypeUser(User);
-}
-
-// Define inline methods for PATypeHolder...
-
-inline void PATypeHolder::addRef() {
- if (Ty->isAbstract())
- cast<DerivedType>(Ty)->addRef();
-}
-
-inline void PATypeHolder::dropRef() {
- if (Ty->isAbstract())
- cast<DerivedType>(Ty)->dropRef();
-}
-
-/// get - This implements the forwarding part of the union-find algorithm for
-/// abstract types. Before every access to the Type*, we check to see if the
-/// type we are pointing to is forwarding to a new type. If so, we drop our
-/// reference to the type.
-inline const Type* PATypeHolder::get() const {
- const Type *NewTy = Ty->getForwardedType();
- if (!NewTy) return Ty;
- return *const_cast<PATypeHolder*>(this) = NewTy;
-}