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/Pragma.h ------------------------------------------ -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 //===----------------------------------------------------------------------===// 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef COMMA_AST_PRAGMA_HDR_GUARD 00016 #define COMMA_AST_PRAGMA_HDR_GUARD 00017 00018 #include "comma/ast/AstBase.h" 00019 #include "comma/basic/Pragmas.h" 00020 00021 #include "llvm/ADT/ilist.h" 00022 #include "llvm/ADT/StringRef.h" 00023 00024 namespace comma { 00025 00026 //===----------------------------------------------------------------------===// 00027 // Pragma 00028 class Pragma { 00029 00030 public: 00031 virtual ~Pragma() { } 00032 00033 pragma::PragmaID getKind() const { return ID; } 00034 00035 Location getLocation() const { return loc; } 00036 00038 00039 00040 Pragma *getNext() { return nextLink; } 00041 Pragma *getPrev() { return prevLink; } 00042 00043 const Pragma *getNext() const { return nextLink; } 00044 const Pragma *getPrev() const { return prevLink; } 00045 00046 void setNext(Pragma *P) { nextLink = P; } 00047 void setPrev(Pragma *P) { prevLink = P; } 00049 00050 // Support isa and dyn_cast. 00051 static bool classof(const Pragma *pragma) { return true; } 00052 00053 protected: 00054 Pragma(pragma::PragmaID ID, Location loc) 00055 : ID(ID), loc(loc), nextLink(0), prevLink(0) { } 00056 00060 Pragma() : ID(pragma::UNKNOWN_PRAGMA), loc(0), nextLink(0), prevLink(0) { } 00061 friend class llvm::ilist_sentinel_traits<Pragma>; 00062 00063 pragma::PragmaID ID; 00064 Location loc; 00065 Pragma *nextLink; 00066 Pragma *prevLink; 00067 }; 00068 00069 //===----------------------------------------------------------------------===// 00070 // PragmaAssert 00071 class PragmaAssert : public Pragma { 00072 00073 public: 00074 PragmaAssert(Location loc, Expr *condition, Expr *message = 0) 00075 : Pragma(pragma::Assert, loc), 00076 condition(condition), 00077 message(message) { } 00078 00080 00081 const Expr *getCondition() const { return condition; } 00082 Expr *getCondition() { return condition; } 00084 00086 00087 00088 const Expr *getMessage() const { return message; } 00089 Expr *getMessage() { return message; } 00091 00093 bool hasMessage() const { return message != 0; } 00094 00096 void setCondition(Expr *condition) { this->condition = condition; } 00097 00099 void setMessage(Expr *message) { this->message = message; } 00100 00101 // Support isa and dyn_cast. 00102 static bool classof(const PragmaAssert *pragma) { return true; } 00103 static bool classof(const Pragma *pragma) { 00104 return pragma->getKind() == pragma::Assert; 00105 } 00106 00107 private: 00108 Expr *condition; 00109 Expr *message; 00110 }; 00111 00112 //===----------------------------------------------------------------------===// 00113 // PragmaImport 00114 class PragmaImport : public Pragma { 00115 00116 public: 00120 enum Convention { 00121 UNKNOWN_CONVENTION, 00122 C 00123 }; 00124 00125 PragmaImport(Location loc, Convention convention, 00126 IdentifierInfo *entity, Expr *externalName); 00127 00130 static Convention getConventionID(llvm::StringRef &ref); 00131 00133 Convention getConvention() const { return convention; } 00134 00136 IdentifierInfo *getEntityIdInfo() const { return entity; } 00137 00139 00140 00141 Expr *getExternalNameExpr() { return externalNameExpr; } 00142 const Expr *getExternalNameExpr() const { return externalNameExpr; } 00144 00146 const std::string &getExternalName() const { return externalName; } 00147 00148 private: 00149 Convention convention; 00150 IdentifierInfo *entity; 00151 Expr *externalNameExpr; 00152 std::string externalName; 00153 }; 00154 00155 } // end comma namespace. 00156 00157 #endif