This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- ast/AttribDecl.h -------------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #ifndef COMMA_AST_ATTRIBDECL_HDR_GUARD 00010 #define COMMA_AST_ATTRIBDECL_HDR_GUARD 00011 00012 #include "comma/ast/Decl.h" 00013 00014 namespace comma { 00015 00016 //===----------------------------------------------------------------------===// 00017 // FunctionAttribDecl 00018 // 00021 class FunctionAttribDecl : public FunctionDecl { 00022 00023 public: 00025 attrib::AttributeID getAttributeID() const { 00026 // AttributeID's are stored in the lower Ast bits field. 00027 return static_cast<attrib::AttributeID>(bits); 00028 } 00029 00031 00032 00033 00034 const PrimaryType *getPrefix() const { return prefix; } 00035 PrimaryType *getPrefix() { return prefix; } 00037 00038 // Support isa/dyn_cast. 00039 static bool classof(const FunctionAttribDecl *node) { return true; } 00040 static bool classof(const Ast *node) { 00041 return denotesFunctionAttribDecl(node); 00042 } 00043 00044 protected: 00045 FunctionAttribDecl(AstKind kind, PrimaryType *prefix, 00046 IdentifierInfo *name, Location loc, 00047 IdentifierInfo **keywords, FunctionType *type, 00048 DeclRegion *parent) 00049 : FunctionDecl(kind, name, loc, keywords, type, parent), 00050 prefix(prefix) { 00051 bits = correspondingID(kind); 00052 } 00053 00054 private: 00055 static bool denotesFunctionAttribDecl(const Ast *node) { 00056 AstKind kind = node->getKind(); 00057 return kind == AST_PosAD || kind == AST_ValAD; 00058 } 00059 00060 static attrib::AttributeID correspondingID(AstKind kind) { 00061 attrib::AttributeID ID; 00062 switch (kind) { 00063 default: 00064 assert(false && "Bad ast kind for this attribute!"); 00065 ID = attrib::UNKNOWN_ATTRIBUTE; 00066 break; 00067 case AST_PosAD: 00068 ID = attrib::Pos; 00069 case AST_ValAD: 00070 ID = attrib::Val; 00071 } 00072 return ID; 00073 } 00074 00075 PrimaryType *prefix; 00076 }; 00077 00078 //===----------------------------------------------------------------------===// 00079 // PosAD 00080 // 00083 class PosAD : public FunctionAttribDecl { 00084 00085 public: 00087 00088 const DiscreteType *getPrefix() const { 00089 return llvm::cast<DiscreteType>(FunctionAttribDecl::getPrefix()); 00090 } 00091 DiscreteType *getPrefix() { 00092 return llvm::cast<DiscreteType>(FunctionAttribDecl::getPrefix()); 00093 } 00095 00096 // Support isa/dyn_cast. 00097 static bool classof(const PosAD *node) { return true; } 00098 static bool classof(const Ast *node) { 00099 return node->getKind() == AST_PosAD; 00100 } 00101 00102 private: 00105 static PosAD *create(AstResource &resource, IntegerDecl *prefixDecl); 00106 static PosAD *create(AstResource &resource, EnumerationDecl *prefixDecl); 00107 00108 friend class IntegerDecl; 00109 friend class EnumerationDecl; 00110 00112 PosAD(DiscreteType *prefix, IdentifierInfo *name, Location loc, 00113 IdentifierInfo **keywords, FunctionType *type, 00114 DeclRegion *parent) 00115 : FunctionAttribDecl(AST_PosAD, prefix, name, loc, 00116 keywords, type, parent) { } 00117 }; 00118 00119 //===----------------------------------------------------------------------===// 00120 // ValAD 00121 // 00124 class ValAD : public FunctionAttribDecl { 00125 00126 public: 00128 00129 const DiscreteType *getPrefix() const { 00130 return llvm::cast<DiscreteType>(FunctionAttribDecl::getPrefix()); 00131 } 00132 DiscreteType *getPrefix() { 00133 return llvm::cast<DiscreteType>(FunctionAttribDecl::getPrefix()); 00134 } 00136 00137 // Support isa/dyn_cast. 00138 static bool classof(const ValAD *node) { return true; } 00139 static bool classof(const Ast *node) { 00140 return node->getKind() == AST_ValAD; 00141 } 00142 00143 private: 00146 static ValAD *create(AstResource &resource, IntegerDecl *prefixDecl); 00147 static ValAD *create(AstResource &resource, EnumerationDecl *prefixDecl); 00148 00149 friend class IntegerDecl; 00150 friend class EnumerationDecl; 00151 00153 ValAD(DiscreteType *prefix, IdentifierInfo *name, Location loc, 00154 IdentifierInfo **keywords, FunctionType *type, 00155 DeclRegion *parent) 00156 : FunctionAttribDecl(AST_ValAD, prefix, name, loc, 00157 keywords, type, parent) { } 00158 }; 00159 00160 } // end comma namespace. 00161 00162 #endif 00163