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/AstBase.h ----------------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2008-2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 // 00009 // This header contains forwards declarations for all AST nodes, and definitions 00010 // for a few choice fundamental nodes and types. 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 "llvm/Support/Casting.h" 00020 #include <iosfwd> 00021 00022 namespace comma { 00023 00024 // 00025 // Forward declarations for all Ast nodes. 00026 // 00027 class AbstractDomainDecl; 00028 class AccessDecl; 00029 class AccessType; 00030 class AddDecl; 00031 class AggregateExpr; 00032 class AllocatorExpr; 00033 class ArrayBoundAE; 00034 class ArrayDecl; 00035 class ArrayRangeAttrib; 00036 class ArrayType; 00037 class AssignmentStmt; 00038 class Ast; 00039 class AstRewriter; 00040 class AstResource; 00041 class AttribExpr; 00042 class BlockStmt; 00043 class CarrierDecl; 00044 class ComponentDecl; 00045 class CompositeType; 00046 class CompilationUnit; 00047 class ConversionExpr; 00048 class Decl; 00049 class DeclRegion; 00050 class DeclRefExpr; 00051 class DeclRewriter; 00052 class DereferenceExpr; 00053 class DiamondExpr; 00054 class DiscreteType; 00055 class DomainDecl; 00056 class DomainInstanceDecl; 00057 class DomainType; 00058 class DomainTypeDecl; 00059 class Domoid; 00060 class DSTDefinition; 00061 class EnumerationDecl; 00062 class EnumLiteral; 00063 class EnumerationType; 00064 class ExceptionDecl; 00065 class ExceptionRef; 00066 class Expr; 00067 class FirstAE; 00068 class FirstArrayAE; 00069 class ForStmt; 00070 class FunctionAttribDecl; 00071 class FunctionCallExpr; 00072 class FunctionDecl; 00073 class FunctionType; 00074 class FunctorDecl; 00075 class FunctorType; 00076 class HandlerStmt; 00077 class Identifier; 00078 class IfStmt; 00079 class ImportDecl; 00080 class IndexedArrayExpr; 00081 class IncompleteType; 00082 class IncompleteTypeDecl; 00083 class InjExpr; 00084 class IntegerDecl; 00085 class IntegerLiteral; 00086 class IntegerType; 00087 class KeywordSelector; 00088 class LastAE; 00089 class LastArrayAE; 00090 class LoopDecl; 00091 class LoopStmt; 00092 class ModelDecl; 00093 class NullExpr; 00094 class NullStmt; 00095 class ObjectDecl; 00096 class ParamValueDecl; 00097 class PercentDecl; 00098 class PosAD; 00099 class Pragma; 00100 class PragmaAssert; 00101 class PragmaImport; 00102 class PragmaStmt; 00103 class PrimaryType; 00104 class PrjExpr; 00105 class ProcedureCallStmt; 00106 class ProcedureDecl; 00107 class ProcedureType; 00108 class QualifiedExpr; 00109 class RaiseStmt; 00110 class Range; 00111 class RangeAttrib; 00112 class RecordDecl; 00113 class RecordType; 00114 class RenamedObjectDecl; 00115 class ReturnStmt; 00116 class ScalarBoundAE; 00117 class ScalarRangeAttrib; 00118 class SelectedExpr; 00119 class Sigoid; 00120 class SignatureDecl; 00121 class SigInstanceDecl; 00122 class Stmt; 00123 class StmtSequence; 00124 class StringLiteral; 00125 class SubroutineCall; 00126 class SubroutineDecl; 00127 class SubroutineRef; 00128 class SubroutineType; 00129 class Type; 00130 class TypeDecl; 00131 class TypeRef; 00132 class UniversalType; 00133 class ValAD; 00134 class ValueDecl; 00135 class VarietyDecl; 00136 class VarietyType; 00137 class WhileStmt; 00138 00148 class Ast { 00149 00150 public: 00165 enum AstKind { 00166 00167 // 00168 // Decl nodes. There are currently four sub-categories. 00169 // 00170 // - Model decls which denotes signatures and domains. 00171 // 00172 // - Type declarations (carriers, enums, etc). 00173 // 00174 // - Subroutine decls denoting functions and procedures. 00175 // 00176 // - Value decls denoting elements of a type. 00177 // 00178 AST_SignatureDecl, 00179 AST_DomainDecl, 00180 AST_VarietyDecl, 00181 AST_FunctorDecl, 00182 AST_AddDecl, 00183 00184 AST_AccessDecl, 00185 AST_CarrierDecl, 00186 AST_EnumerationDecl, 00187 AST_IncompleteTypeDecl, 00188 AST_IntegerDecl, 00189 AST_ArrayDecl, 00190 AST_RecordDecl, 00191 AST_AbstractDomainDecl, 00192 AST_DomainInstanceDecl, 00193 AST_PercentDecl, 00194 00195 AST_SigInstanceDecl, 00196 00197 // 00198 // Value declaration nodes. 00199 // 00200 AST_LoopDecl, 00201 AST_ObjectDecl, 00202 AST_ParamValueDecl, 00203 AST_RenamedObjectDecl, 00204 00205 // 00206 // Subroutine declaration nodes. 00207 // 00208 AST_ProcedureDecl, 00209 AST_FunctionDecl, 00210 AST_EnumLiteral, 00211 AST_PosAD, 00212 AST_ValAD, 00213 00214 AST_ImportDecl, 00215 AST_ExceptionDecl, 00216 AST_ComponentDecl, 00217 00218 // 00219 // Type nodes. 00220 // 00221 AST_UniversalType, 00222 AST_FunctionType, 00223 AST_ProcedureType, 00224 00225 // 00226 // Primary Types. 00227 // 00228 AST_AccessType, 00229 AST_ArrayType, 00230 AST_DomainType, 00231 AST_EnumerationType, 00232 AST_IncompleteType, 00233 AST_IntegerType, 00234 AST_RecordType, 00235 00236 // 00237 // Expr nodes. 00238 // 00239 AST_AllocatorExpr, 00240 AST_ConversionExpr, 00241 AST_DiamondExpr, 00242 AST_DeclRefExpr, 00243 AST_DereferenceExpr, 00244 AST_FunctionCallExpr, 00245 AST_IndexedArrayExpr, 00246 AST_InjExpr, 00247 AST_IntegerLiteral, 00248 AST_NullExpr, 00249 AST_AggregateExpr, 00250 AST_PrjExpr, 00251 AST_QualifiedExpr, 00252 AST_SelectedExpr, 00253 AST_StringLiteral, 00254 00255 // 00256 // Expr attributes. 00257 // 00258 AST_FirstAE, 00259 AST_FirstArrayAE, 00260 AST_LastArrayAE, 00261 AST_LastAE, 00262 00263 // 00264 // Stmt nodes. 00265 // 00266 AST_AssignmentStmt, 00267 AST_BlockStmt, 00268 AST_ForStmt, 00269 AST_HandlerStmt, 00270 AST_IfStmt, 00271 AST_LoopStmt, 00272 AST_NullStmt, 00273 AST_ProcedureCallStmt, 00274 AST_RaiseStmt, 00275 AST_ReturnStmt, 00276 AST_StmtSequence, 00277 AST_WhileStmt, 00278 AST_PragmaStmt, 00279 00280 // 00281 // Miscellaneous helper nodes. 00282 // 00283 AST_KeywordSelector, 00284 AST_DSTDefinition, 00285 AST_Range, 00286 AST_ArrayRangeAttrib, 00287 AST_ScalarRangeAttrib, 00288 AST_SubroutineRef, 00289 AST_TypeRef, 00290 AST_ExceptionRef, 00291 AST_Identifier, 00292 AST_ComponentKey, 00293 00294 // 00295 // Delimitiers providing classification of the above codes. 00296 // 00297 LAST_AstKind, 00298 00299 FIRST_Decl = AST_SignatureDecl, 00300 LAST_Decl = AST_ComponentDecl, 00301 00302 FIRST_ModelDecl = AST_SignatureDecl, 00303 LAST_ModelDecl = AST_FunctorDecl, 00304 00305 FIRST_TypeDecl = AST_AccessDecl, 00306 LAST_TypeDecl = AST_PercentDecl, 00307 00308 FIRST_DomainType = AST_AbstractDomainDecl, 00309 LAST_DomainType = AST_PercentDecl, 00310 00311 FIRST_ValueDecl = AST_LoopDecl, 00312 LAST_ValueDecl = AST_RenamedObjectDecl, 00313 00314 FIRST_SubroutineDecl = AST_ProcedureDecl, 00315 LAST_SubroutineDecl = AST_ValAD, 00316 00317 FIRST_Type = AST_UniversalType, 00318 LAST_Type = AST_RecordType, 00319 00320 FIRST_PrimaryType = AST_AccessType, 00321 LAST_PrimaryType = AST_RecordType, 00322 00323 FIRST_Expr = AST_AllocatorExpr, 00324 LAST_Expr = AST_LastAE, 00325 00326 FIRST_AttribExpr = AST_FirstAE, 00327 LAST_AttribExpr = AST_LastAE, 00328 00329 FIRST_Stmt = AST_AssignmentStmt, 00330 LAST_Stmt = AST_PragmaStmt 00331 }; 00332 00333 virtual ~Ast() { } 00334 00336 AstKind getKind() const { return kind; } 00337 00343 virtual Location getLocation() const { return Location(); } 00344 00351 bool isValid() const { return validFlag == true; } 00352 00354 void markInvalid() { validFlag = false; } 00355 00362 bool isDeletable() const { return deletable; } 00363 00365 bool denotesDecl() const { 00366 return (FIRST_Decl <= kind && kind <= LAST_Decl); 00367 } 00368 00370 bool denotesModelDecl() const { 00371 return (FIRST_ModelDecl <= kind && kind <= LAST_ModelDecl); 00372 } 00373 00375 bool denotesTypeDecl() const { 00376 return (FIRST_TypeDecl <= kind && kind <= LAST_TypeDecl); 00377 } 00378 00381 bool denotesSubroutineDecl() const { 00382 return (FIRST_SubroutineDecl <= kind && kind <= LAST_SubroutineDecl); 00383 } 00384 00386 bool denotesValueDecl() const { 00387 return (FIRST_ValueDecl <= kind && kind <= LAST_ValueDecl); 00388 } 00389 00391 bool denotesDomainTypeDecl() const { 00392 return (FIRST_DomainType <= kind && kind <= LAST_DomainType); 00393 } 00394 00396 bool denotesType() const { 00397 return (FIRST_Type <= kind && kind <= LAST_Type); 00398 } 00399 00401 bool denotesPrimaryType() const { 00402 return (FIRST_PrimaryType <= kind && kind <= LAST_PrimaryType); 00403 } 00404 00407 bool denotesSubroutineType() const { 00408 return (kind == AST_FunctionType || 00409 kind == AST_ProcedureType); 00410 } 00411 00413 bool denotesCompositeType() const { 00414 return (kind == AST_ArrayType || kind == AST_RecordType); 00415 } 00416 00418 bool denotesExpr() const { 00419 return (FIRST_Expr <= kind && kind <= LAST_Expr); 00420 } 00421 00423 bool denotesAttribExpr() const { 00424 return (FIRST_AttribExpr <= kind && kind <= LAST_AttribExpr); 00425 } 00426 00428 bool denotesStmt() const { 00429 return (FIRST_Stmt <= kind && kind <= LAST_Stmt); 00430 } 00431 00433 const char *getKindString() const { return kindStrings[kind]; } 00434 00436 virtual void dump(); 00437 00439 static bool classof(const Ast *node) { return true; } 00440 00441 protected: 00445 Ast(AstKind kind) 00446 : kind(kind), 00447 validFlag(true), 00448 deletable(true), 00449 bits(0) { } 00450 00451 AstKind kind : 8; 00452 bool validFlag : 1; 00453 bool deletable : 1; 00454 unsigned bits : 23; 00455 00456 static const char *kindStrings[LAST_AstKind]; 00457 }; 00458 00459 } // End comma namespace. 00460 00461 #endif