| 1 | // | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
| 3 | // | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
| 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| 6 | // | 
|---|
| 7 | // TypeData.h -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Rodolfo G. Esteves | 
|---|
| 10 | // Created On       : Sat May 16 15:18:36 2015 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr | 
|---|
| 12 | // Last Modified On : Sat May 16 15:20:00 2015 | 
|---|
| 13 | // Update Count     : 2 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #ifndef TYPEDATA_H | 
|---|
| 17 | #define TYPEDATA_H | 
|---|
| 18 |  | 
|---|
| 19 | #include <list> | 
|---|
| 20 |  | 
|---|
| 21 | #include "ParseNode.h" | 
|---|
| 22 | #include "SynTree/Type.h" | 
|---|
| 23 |  | 
|---|
| 24 | struct TypeData { | 
|---|
| 25 | enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst, | 
|---|
| 26 | Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Attr } kind; | 
|---|
| 27 |  | 
|---|
| 28 | TypeData( Kind k = Unknown ); | 
|---|
| 29 | ~TypeData(); | 
|---|
| 30 | void print( std::ostream &, int indent = 0 ) const; | 
|---|
| 31 | TypeData *clone() const; | 
|---|
| 32 |  | 
|---|
| 33 | Type *build() const; | 
|---|
| 34 | FunctionType *buildFunction() const; | 
|---|
| 35 |  | 
|---|
| 36 | TypeData *base; | 
|---|
| 37 | std::list< DeclarationNode::Qualifier > qualifiers; | 
|---|
| 38 | DeclarationNode *forall; | 
|---|
| 39 |  | 
|---|
| 40 | struct Basic_t { | 
|---|
| 41 | std::list< DeclarationNode::BasicType > typeSpec; | 
|---|
| 42 | std::list< DeclarationNode::Modifier > modifiers; | 
|---|
| 43 | }; | 
|---|
| 44 |  | 
|---|
| 45 | struct Aggregate_t { | 
|---|
| 46 | DeclarationNode::TyCon kind; | 
|---|
| 47 | std::string name; | 
|---|
| 48 | DeclarationNode *params; | 
|---|
| 49 | ExpressionNode *actuals;                                                // holds actual parameters later applied to AggInst | 
|---|
| 50 | DeclarationNode *members; | 
|---|
| 51 | }; | 
|---|
| 52 |  | 
|---|
| 53 | struct AggInst_t { | 
|---|
| 54 | TypeData *aggregate; | 
|---|
| 55 | ExpressionNode *params; | 
|---|
| 56 | }; | 
|---|
| 57 |  | 
|---|
| 58 | struct Array_t { | 
|---|
| 59 | ExpressionNode *dimension; | 
|---|
| 60 | bool isVarLen; | 
|---|
| 61 | bool isStatic; | 
|---|
| 62 | }; | 
|---|
| 63 |  | 
|---|
| 64 | struct Enumeration_t { | 
|---|
| 65 | std::string name; | 
|---|
| 66 | DeclarationNode *constants; | 
|---|
| 67 | }; | 
|---|
| 68 |  | 
|---|
| 69 | struct Function_t { | 
|---|
| 70 | DeclarationNode *params; | 
|---|
| 71 | DeclarationNode *idList;                                                // old-style | 
|---|
| 72 | DeclarationNode *oldDeclList; | 
|---|
| 73 | StatementNode *body; | 
|---|
| 74 | bool hasBody; | 
|---|
| 75 | bool newStyle; | 
|---|
| 76 | }; | 
|---|
| 77 |  | 
|---|
| 78 | struct Symbolic_t { | 
|---|
| 79 | std::string name; | 
|---|
| 80 | bool isTypedef; | 
|---|
| 81 | DeclarationNode *params; | 
|---|
| 82 | ExpressionNode *actuals; | 
|---|
| 83 | DeclarationNode *assertions; | 
|---|
| 84 | }; | 
|---|
| 85 |  | 
|---|
| 86 | struct Variable_t { | 
|---|
| 87 | DeclarationNode::TypeClass tyClass; | 
|---|
| 88 | std::string name; | 
|---|
| 89 | DeclarationNode *assertions; | 
|---|
| 90 | }; | 
|---|
| 91 |  | 
|---|
| 92 | struct Tuple_t { | 
|---|
| 93 | DeclarationNode *members; | 
|---|
| 94 | }; | 
|---|
| 95 |  | 
|---|
| 96 | struct Typeof_t { | 
|---|
| 97 | ExpressionNode *expr; | 
|---|
| 98 | }; | 
|---|
| 99 |  | 
|---|
| 100 | struct Attr_t { | 
|---|
| 101 | std::string name; | 
|---|
| 102 | ExpressionNode *expr; | 
|---|
| 103 | DeclarationNode *type; | 
|---|
| 104 | }; | 
|---|
| 105 |  | 
|---|
| 106 | union { | 
|---|
| 107 | Basic_t *basic; | 
|---|
| 108 | Aggregate_t *aggregate; | 
|---|
| 109 | AggInst_t *aggInst; | 
|---|
| 110 | Array_t *array; | 
|---|
| 111 | Enumeration_t *enumeration; | 
|---|
| 112 | Function_t *function; | 
|---|
| 113 | Symbolic_t *symbolic; | 
|---|
| 114 | Variable_t *variable; | 
|---|
| 115 | Tuple_t *tuple; | 
|---|
| 116 | Typeof_t *typeexpr; | 
|---|
| 117 | Attr_t *attr; | 
|---|
| 118 | }; | 
|---|
| 119 |  | 
|---|
| 120 | TypeData *extractAggregate( bool toplevel = true ) const; | 
|---|
| 121 | // helper function for DeclNodeImpl::build | 
|---|
| 122 | Declaration * buildDecl( std::string name, Declaration::StorageClass sc, Expression *bitfieldWidth, bool isInline, LinkageSpec::Type linkage, Initializer *init = 0 ) const; | 
|---|
| 123 | // helper functions for build() | 
|---|
| 124 | Type::Qualifiers buildQualifiers() const; | 
|---|
| 125 | Type *buildBasicType() const; | 
|---|
| 126 | PointerType * buildPointer() const; | 
|---|
| 127 | ArrayType * buildArray() const; | 
|---|
| 128 | AggregateDecl * buildAggregate() const; | 
|---|
| 129 | ReferenceToType * buildAggInst() const; | 
|---|
| 130 | NamedTypeDecl * buildSymbolic( const std::string &name, Declaration::StorageClass sc ) const; | 
|---|
| 131 | TypeDecl* buildVariable() const; | 
|---|
| 132 | EnumDecl* buildEnum() const; | 
|---|
| 133 | TypeInstType * buildSymbolicInst() const; | 
|---|
| 134 | TupleType * buildTuple() const; | 
|---|
| 135 | TypeofType * buildTypeof() const; | 
|---|
| 136 | AttrType * buildAttr() const; | 
|---|
| 137 | }; | 
|---|
| 138 |  | 
|---|
| 139 | #endif // TYPEDATA_H | 
|---|
| 140 |  | 
|---|
| 141 | // Local Variables: // | 
|---|
| 142 | // tab-width: 4 // | 
|---|
| 143 | // mode: c++ // | 
|---|
| 144 | // compile-command: "make install" // | 
|---|
| 145 | // End: // | 
|---|