00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef COMMA_AST_ASTBASE_HDR_GUARD
00015 #define COMMA_AST_ASTBASE_HDR_GUARD
00016
00017 #include "comma/basic/Location.h"
00018 #include "comma/basic/IdentifierInfo.h"
00019 #include <iosfwd>
00020
00021 namespace comma {
00022
00023
00024
00025
00026 class AbstractDomainType;
00027 class Ast;
00028 class AstRewriter;
00029 class CompilationUnit;
00030 class ConcreteDomainType;
00031 class Decl;
00032 class DomainDecl;
00033 class DomainType;
00034 class Domoid;
00035 class FunctionDecl;
00036 class FunctionType;
00037 class FunctorDecl;
00038 class FunctorType;
00039 class ModelDecl;
00040 class ModelType;
00041 class NamedDecl;
00042 class PercentType;
00043 class ParameterizedModel;
00044 class ParameterizedType;
00045 class Sigoid;
00046 class SignatureDecl;
00047 class SignatureType;
00048 class Type;
00049 class TypeDecl;
00050 class VarietyDecl;
00051 class VarietyType;
00052
00062 class Ast {
00063
00064 public:
00076 enum AstKind {
00077
00078
00079
00080
00081 AST_SignatureDecl,
00082 AST_DomainDecl,
00083 AST_VarietyDecl,
00084 AST_FunctorDecl,
00085 AST_FunctionDecl,
00086
00087
00088
00089
00090 AST_SignatureType,
00091 AST_VarietyType,
00092 AST_FunctorType,
00093 AST_DomainType,
00094 AST_ConcreteDomainType,
00095 AST_AbstractDomainType,
00096 AST_PercentType,
00097 AST_FunctionType,
00098
00099
00100
00101
00102 FIRST_Decl = AST_SignatureDecl,
00103 LAST_Decl = AST_FunctionDecl,
00104
00105 FIRST_TypeDecl = AST_SignatureDecl,
00106 LAST_TypeDecl = AST_FunctorDecl,
00107
00108 FIRST_ModelDecl = AST_SignatureDecl,
00109 LAST_ModelDecl = AST_FunctorDecl,
00110
00111 FIRST_Type = AST_SignatureType,
00112 LAST_Type = AST_FunctionType
00113 };
00114
00115 virtual ~Ast() { }
00116
00118 AstKind getKind() const { return kind; }
00119
00125 virtual Location getLocation() const { return Location(); }
00126
00133 bool isValid() const { return validFlag == true; }
00134
00136 void markInvalid() { validFlag = false; }
00137
00144 bool isDeletable() const { return deletable; }
00145
00147 bool denotesDecl() const {
00148 return (FIRST_Decl <= this->getKind() &&
00149 this->getKind() <= LAST_Decl);
00150 }
00151
00154 bool denotesTypeDecl() const {
00155 return (FIRST_TypeDecl <= this->getKind() &&
00156 this->getKind() <= LAST_TypeDecl);
00157 }
00158
00160 bool denotesModelDecl() const {
00161 return (FIRST_ModelDecl <= this->getKind() &&
00162 this->getKind() <= LAST_ModelDecl);
00163 }
00164
00166 bool denotesType() const {
00167 return (FIRST_Type <= this->getKind() &&
00168 this->getKind() <= LAST_Type);
00169 }
00170
00172 bool denotesDomainType() const {
00173 return (kind == AST_ConcreteDomainType ||
00174 kind == AST_AbstractDomainType ||
00175 kind == AST_PercentType);
00176 }
00177
00179 bool denotesModelType() const {
00180 return (denotesDomainType() ||
00181 kind == AST_SignatureType ||
00182 kind == AST_VarietyType ||
00183 kind == AST_FunctorType);
00184 }
00185
00187 static bool classof(const Ast *node) { return true; }
00188
00189 protected:
00193 Ast(AstKind kind)
00194 : kind(kind),
00195 validFlag(true),
00196 deletable(true) { }
00197
00198
00199 AstKind kind : 8;
00200 bool validFlag : 1;
00201 bool deletable : 1;
00202 unsigned bits : 23;
00203 };
00204
00205 }
00206
00207 #endif