[b87a5ed] | 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 |
---|
[7d05e7e] | 12 | // Last Modified On : Fri Sep 9 23:20:55 2016 |
---|
| 13 | // Update Count : 117 |
---|
[b87a5ed] | 14 | // |
---|
| 15 | |
---|
[51b7345] | 16 | #ifndef TYPEDATA_H |
---|
| 17 | #define TYPEDATA_H |
---|
| 18 | |
---|
[c1c1112] | 19 | #include <bitset> |
---|
[bdd516a] | 20 | |
---|
[51b7345] | 21 | #include "ParseNode.h" |
---|
| 22 | #include "SynTree/Type.h" |
---|
| 23 | |
---|
[c8ffe20b] | 24 | struct TypeData { |
---|
[b87a5ed] | 25 | enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst, |
---|
[28307be] | 26 | Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr }; |
---|
[b87a5ed] | 27 | |
---|
| 28 | struct Basic_t { |
---|
| 29 | std::list< DeclarationNode::BasicType > typeSpec; |
---|
| 30 | std::list< DeclarationNode::Modifier > modifiers; |
---|
| 31 | }; |
---|
| 32 | |
---|
| 33 | struct Aggregate_t { |
---|
[68cd1ce] | 34 | DeclarationNode::Aggregate kind; |
---|
[b87a5ed] | 35 | std::string name; |
---|
[7ee14bb7] | 36 | DeclarationNode * params; |
---|
| 37 | ExpressionNode * actuals; // holds actual parameters later applied to AggInst |
---|
| 38 | DeclarationNode * fields; |
---|
[5d125e4] | 39 | bool body; |
---|
[b87a5ed] | 40 | }; |
---|
| 41 | |
---|
| 42 | struct AggInst_t { |
---|
[7ee14bb7] | 43 | TypeData * aggregate; |
---|
| 44 | ExpressionNode * params; |
---|
[b87a5ed] | 45 | }; |
---|
| 46 | |
---|
| 47 | struct Array_t { |
---|
[7ee14bb7] | 48 | ExpressionNode * dimension; |
---|
[b87a5ed] | 49 | bool isVarLen; |
---|
| 50 | bool isStatic; |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | struct Enumeration_t { |
---|
| 54 | std::string name; |
---|
[7ee14bb7] | 55 | DeclarationNode * constants; |
---|
[b87a5ed] | 56 | }; |
---|
| 57 | |
---|
| 58 | struct Function_t { |
---|
[7ee14bb7] | 59 | DeclarationNode * params; |
---|
| 60 | DeclarationNode * idList; // old-style |
---|
| 61 | DeclarationNode * oldDeclList; |
---|
| 62 | StatementNode * body; |
---|
[b87a5ed] | 63 | bool hasBody; |
---|
| 64 | bool newStyle; |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | struct Symbolic_t { |
---|
| 68 | std::string name; |
---|
[721f17a] | 69 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname |
---|
[7ee14bb7] | 70 | DeclarationNode * params; |
---|
| 71 | ExpressionNode * actuals; |
---|
| 72 | DeclarationNode * assertions; |
---|
[b87a5ed] | 73 | }; |
---|
| 74 | |
---|
[8f6f47d7] | 75 | // struct Tuple_t { |
---|
| 76 | // DeclarationNode * members; |
---|
| 77 | // }; |
---|
[51b7345] | 78 | |
---|
[8f6f47d7] | 79 | // struct Typeof_t { |
---|
| 80 | // ExpressionNode * expr; |
---|
| 81 | // }; |
---|
[b87a5ed] | 82 | |
---|
[8f6f47d7] | 83 | // struct Builtin_t { |
---|
| 84 | // DeclarationNode::BuiltinType type; |
---|
| 85 | // }; |
---|
[90c3b1c] | 86 | |
---|
[28307be] | 87 | Kind kind; |
---|
[413ad05] | 88 | TypeData * base; |
---|
| 89 | typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers; |
---|
| 90 | Qualifiers qualifiers; |
---|
| 91 | DeclarationNode * forall; |
---|
| 92 | |
---|
[8f6f47d7] | 93 | Basic_t basic; |
---|
| 94 | Aggregate_t aggregate; |
---|
| 95 | AggInst_t aggInst; |
---|
| 96 | Array_t array; |
---|
| 97 | Enumeration_t enumeration; |
---|
[7d05e7e] | 98 | // Variable_t variable; |
---|
[8f6f47d7] | 99 | Function_t function; |
---|
| 100 | Symbolic_t symbolic; |
---|
| 101 | DeclarationNode * tuple; |
---|
| 102 | ExpressionNode * typeexpr; |
---|
[7d05e7e] | 103 | // Attr_t attr; |
---|
[8f6f47d7] | 104 | // DeclarationNode::BuiltinType builtin; |
---|
[b87a5ed] | 105 | |
---|
[413ad05] | 106 | TypeData( Kind k = Unknown ); |
---|
| 107 | ~TypeData(); |
---|
| 108 | void print( std::ostream &, int indent = 0 ) const; |
---|
| 109 | TypeData * clone() const; |
---|
[51b7345] | 110 | }; |
---|
| 111 | |
---|
[413ad05] | 112 | Type * typebuild( const TypeData * ); |
---|
| 113 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true ); |
---|
| 114 | Type::Qualifiers buildQualifiers( const TypeData * td ); |
---|
| 115 | Type * buildBasicType( const TypeData * ); |
---|
| 116 | PointerType * buildPointer( const TypeData * ); |
---|
| 117 | ArrayType * buildArray( const TypeData * ); |
---|
| 118 | AggregateDecl * buildAggregate( const TypeData * ); |
---|
| 119 | ReferenceToType * buildAggInst( const TypeData * ); |
---|
| 120 | NamedTypeDecl * buildSymbolic( const TypeData *, const std::string &name, DeclarationNode::StorageClass sc ); |
---|
| 121 | TypeDecl * buildVariable( const TypeData * ); |
---|
| 122 | EnumDecl * buildEnum( const TypeData * ); |
---|
| 123 | TypeInstType * buildSymbolicInst( const TypeData * ); |
---|
| 124 | TupleType * buildTuple( const TypeData * ); |
---|
| 125 | TypeofType * buildTypeof( const TypeData * ); |
---|
| 126 | AttrType * buildAttr( const TypeData * ); |
---|
| 127 | Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 ); |
---|
| 128 | FunctionType * buildFunction( const TypeData * ); |
---|
| 129 | |
---|
[c8ffe20b] | 130 | #endif // TYPEDATA_H |
---|
[b87a5ed] | 131 | |
---|
| 132 | // Local Variables: // |
---|
| 133 | // tab-width: 4 // |
---|
| 134 | // mode: c++ // |
---|
| 135 | // compile-command: "make install" // |
---|
| 136 | // End: // |
---|