Add associated type name typeref

This tracks the names 'T' and 'Index' in a T.Index dependent member type.
This commit is contained in:
David Farler
2016-02-05 15:35:04 -08:00
committed by Slava Pestov
parent ab12335041
commit 9f76eb61c4
3 changed files with 36 additions and 2 deletions

View File

@@ -333,6 +333,23 @@ public:
}
};
class AssociatedTypeRef : public TypeRef {
StringRef Name;
AssociatedTypeRef(StringRef Name);
public:
static AssociatedTypeRef *create(ReflectionContext &RC, StringRef Name);
StringRef getName() const {
return Name;
}
static bool classof(const TypeRef *TR) {
return TR->getKind() == TypeRefKind::Associated;
}
};
template <typename ImplClass, typename RetTy = void, typename... Args>
class TypeRefVisitor {
public:
@@ -455,8 +472,14 @@ public:
void visitDependentMemberTypeRef(const DependentMemberTypeRef *DM) {
printHeader("dependent-member");
printRec(DM->getMember());
printRec(DM->getBase());
printRec(DM->getMember());
OS << ')';
}
void visitAssociatedTypeRef(const AssociatedTypeRef *AT) {
printHeader("associated-type");
printField("name", AT->getName());
OS << ')';
}
};

View File

@@ -27,5 +27,6 @@ TYPEREF(Metatype, TypeRef)
TYPEREF(ExistentialMetatype, TypeRef)
TYPEREF(GenericTypeParameter, TypeRef)
TYPEREF(DependentMember, TypeRef)
TYPEREF(Associated, TypeRef)
#undef TYPEREF