00001 //===-- ast/DSTDefinition.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 #ifndef COMMA_AST_DSTDEFINITION_HDR_GUARD 00010 #define COMMA_AST_DSTDEFINITION_HDR_GUARD 00011 00012 #include "comma/ast/AstBase.h" 00013 #include "comma/ast/Type.h" 00014 00015 #include "llvm/ADT/PointerIntPair.h" 00016 00017 namespace comma { 00018 00019 //===----------------------------------------------------------------------===// 00023 //===----------------------------------------------------------------------===// 00024 00025 //===----------------------------------------------------------------------===// 00036 class DSTDefinition : public Ast { 00037 00038 public: 00042 enum DSTTag { 00043 Attribute_DST, 00044 Range_DST, 00045 Type_DST, 00046 Constrained_DST, 00047 Unconstrained_DST 00048 }; 00049 00053 DSTDefinition(Location loc, Ast *base, DSTTag tag); 00054 00056 DSTTag getTag() const { return static_cast<DSTTag>(bits); } 00057 00059 Location getLocation() const { return loc; } 00060 00062 00063 const DiscreteType *getType() const { 00064 return const_cast<DSTDefinition*>(this)->getType(); 00065 } 00066 DiscreteType *getType(); 00068 00070 bool definedUsingRange() const { return getTag() == Range_DST; } 00071 00073 00074 00075 const Range *getRange() const; 00076 Range *getRange(); 00078 00081 bool definedUsingAttrib() const { return getTag() == Attribute_DST; } 00082 00084 00085 00086 00087 const RangeAttrib *getAttrib() const; 00088 RangeAttrib *getAttrib(); 00090 00097 bool definedUsingSubtype() const { return getTag() == Type_DST; } 00098 00101 bool definedUsingConstraint() const { return getTag() == Constrained_DST; } 00102 00105 bool definedUsingDiamond() const { return getTag() == Unconstrained_DST; } 00106 00107 // Support isa/dyn_cast. 00108 static bool classof(const DSTDefinition *node) { return true; } 00109 static bool classof(const Ast *node) { 00110 return node->getKind() == AST_DSTDefinition; 00111 } 00112 00113 private: 00114 Location loc; 00115 Ast *definition; 00116 }; 00117 00118 } // end comma namespace. 00119 00120 #endif