00001
00002
00003
00004
00005
00006
00007
00008
00009
00013
00014
00015 #ifndef COMMA_AST_TYPEREF_HDR_GUARD
00016 #define COMMA_AST_TYPEREF_HDR_GUARD
00017
00018 namespace comma {
00019
00020 #include "comma/ast/Decl.h"
00021
00033 class TypeRef : public Ast {
00034
00035 public:
00037 TypeRef(Location loc, FunctorDecl *functor)
00038 : Ast(AST_TypeRef), loc(loc), target(functor) { }
00039
00041 TypeRef(Location loc, VarietyDecl *variety)
00042 : Ast(AST_TypeRef), loc(loc), target(variety) { }
00043
00045 TypeRef(Location loc, SigInstanceDecl *instance)
00046 : Ast(AST_TypeRef), loc(loc), target(instance) { }
00047
00049 TypeRef(Location loc, TypeDecl *tyDecl)
00050 : Ast(AST_TypeRef), loc(loc), target(tyDecl) { }
00051
00053 Location getLocation() const { return loc; }
00054
00056 IdentifierInfo *getIdInfo() const { return target->getIdInfo(); }
00057
00059 bool isIncomplete() const {
00060 return llvm::isa<FunctorDecl>(target) || llvm::isa<VarietyDecl>(target);
00061 }
00062
00064 bool isComplete() const { return !isIncomplete(); }
00065
00067 bool referencesVariety() const {
00068 return llvm::isa<VarietyDecl>(target);
00069 }
00070
00072 bool referencesFunctor() const {
00073 return llvm::isa<FunctorDecl>(target);
00074 }
00075
00077 bool referencesSigInstance() const {
00078 return llvm::isa<SigInstanceDecl>(target);
00079 }
00080
00082 bool referencesTypeDecl() const {
00083 return llvm::isa<TypeDecl>(target);
00084 }
00085
00087 Decl *getDecl() const { return target; }
00088
00091 ModelDecl *getModelDecl() const {
00092 return llvm::dyn_cast<ModelDecl>(target);
00093 }
00094
00096 VarietyDecl *getVarietyDecl() const {
00097 return llvm::dyn_cast<VarietyDecl>(target);
00098 }
00099
00101 FunctorDecl *getFunctorDecl() const {
00102 return llvm::dyn_cast<FunctorDecl>(target);
00103 }
00104
00106 SigInstanceDecl *getSigInstanceDecl() const {
00107 return llvm::dyn_cast<SigInstanceDecl>(target);
00108 }
00109
00111 TypeDecl *getTypeDecl() const {
00112 return llvm::dyn_cast<TypeDecl>(target);
00113 }
00114
00115
00116 static bool classof(const TypeRef *node) { return true; }
00117 static bool classof(const Ast *node) {
00118 return node->getKind() == AST_TypeRef;
00119 }
00120
00121 private:
00122 Location loc;
00123 Decl *target;
00124 };
00125
00126 }
00127
00128 #endif