| 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 : Fri Feb 26 14:21:38 2016
 | 
|---|
| 13 | // Update Count     : 19
 | 
|---|
| 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, Builtin, 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::Aggregate kind;
 | 
|---|
| 47 |                 std::string name;
 | 
|---|
| 48 |                 DeclarationNode * params;
 | 
|---|
| 49 |                 ExpressionNode  * actuals;                                              // holds actual parameters later applied to AggInst
 | 
|---|
| 50 |                 DeclarationNode * fields;
 | 
|---|
| 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;                                                                 // false => TYPEGENname, true => TYPEDEFname
 | 
|---|
| 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 Builtin_t {
 | 
|---|
| 101 |                 DeclarationNode::BuiltinType type;
 | 
|---|
| 102 |         };
 | 
|---|
| 103 | 
 | 
|---|
| 104 |         struct Attr_t {
 | 
|---|
| 105 |                 std::string name;
 | 
|---|
| 106 |                 ExpressionNode * expr;
 | 
|---|
| 107 |                 DeclarationNode * type;
 | 
|---|
| 108 |         };
 | 
|---|
| 109 | 
 | 
|---|
| 110 |         union {
 | 
|---|
| 111 |                 Basic_t * basic;
 | 
|---|
| 112 |                 Aggregate_t * aggregate;
 | 
|---|
| 113 |                 AggInst_t * aggInst;
 | 
|---|
| 114 |                 Array_t * array;
 | 
|---|
| 115 |                 Enumeration_t * enumeration;
 | 
|---|
| 116 |                 Function_t * function;
 | 
|---|
| 117 |                 Symbolic_t * symbolic;
 | 
|---|
| 118 |                 Variable_t * variable;
 | 
|---|
| 119 |                 Tuple_t * tuple;
 | 
|---|
| 120 |                 Typeof_t * typeexpr;
 | 
|---|
| 121 |                 Attr_t * attr;
 | 
|---|
| 122 |                 Builtin_t * builtin;
 | 
|---|
| 123 |         };
 | 
|---|
| 124 | 
 | 
|---|
| 125 |         TypeData * extractAggregate( bool toplevel = true ) const;
 | 
|---|
| 126 |         // helper function for DeclNodeImpl::build
 | 
|---|
| 127 |         Declaration * buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Type linkage, Initializer * init = 0 ) const;
 | 
|---|
| 128 |         // helper functions for build()
 | 
|---|
| 129 |         Type::Qualifiers buildQualifiers() const;
 | 
|---|
| 130 |         Type * buildBasicType() const;
 | 
|---|
| 131 |         PointerType * buildPointer() const;
 | 
|---|
| 132 |         ArrayType * buildArray() const;
 | 
|---|
| 133 |         AggregateDecl * buildAggregate() const;
 | 
|---|
| 134 |         ReferenceToType * buildAggInst() const;
 | 
|---|
| 135 |         NamedTypeDecl * buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const;
 | 
|---|
| 136 |         TypeDecl* buildVariable() const;
 | 
|---|
| 137 |         EnumDecl* buildEnum() const;
 | 
|---|
| 138 |         TypeInstType * buildSymbolicInst() const;
 | 
|---|
| 139 |         TupleType * buildTuple() const;
 | 
|---|
| 140 |         TypeofType * buildTypeof() const;
 | 
|---|
| 141 |         AttrType * buildAttr() const;
 | 
|---|
| 142 | };
 | 
|---|
| 143 | 
 | 
|---|
| 144 | #endif // TYPEDATA_H
 | 
|---|
| 145 | 
 | 
|---|
| 146 | // Local Variables: //
 | 
|---|
| 147 | // tab-width: 4 //
 | 
|---|
| 148 | // mode: c++ //
 | 
|---|
| 149 | // compile-command: "make install" //
 | 
|---|
| 150 | // End: //
 | 
|---|