| 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 : Sun Aug 28 22:39:00 2016
|
|---|
| 13 | // Update Count : 85
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #ifndef TYPEDATA_H
|
|---|
| 17 | #define TYPEDATA_H
|
|---|
| 18 |
|
|---|
| 19 | #include <bitset>
|
|---|
| 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 | struct Basic_t {
|
|---|
| 29 | std::list< DeclarationNode::BasicType > typeSpec;
|
|---|
| 30 | std::list< DeclarationNode::Modifier > modifiers;
|
|---|
| 31 | };
|
|---|
| 32 |
|
|---|
| 33 | struct Aggregate_t {
|
|---|
| 34 | DeclarationNode::Aggregate kind;
|
|---|
| 35 | std::string name;
|
|---|
| 36 | DeclarationNode * params;
|
|---|
| 37 | ExpressionNode * actuals; // holds actual parameters later applied to AggInst
|
|---|
| 38 | DeclarationNode * fields;
|
|---|
| 39 | bool body;
|
|---|
| 40 | };
|
|---|
| 41 |
|
|---|
| 42 | struct AggInst_t {
|
|---|
| 43 | TypeData * aggregate;
|
|---|
| 44 | ExpressionNode * params;
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 | struct Array_t {
|
|---|
| 48 | ExpressionNode * dimension;
|
|---|
| 49 | bool isVarLen;
|
|---|
| 50 | bool isStatic;
|
|---|
| 51 | };
|
|---|
| 52 |
|
|---|
| 53 | struct Enumeration_t {
|
|---|
| 54 | std::string name;
|
|---|
| 55 | DeclarationNode * constants;
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | struct Function_t {
|
|---|
| 59 | DeclarationNode * params;
|
|---|
| 60 | DeclarationNode * idList; // old-style
|
|---|
| 61 | DeclarationNode * oldDeclList;
|
|---|
| 62 | StatementNode * body;
|
|---|
| 63 | bool hasBody;
|
|---|
| 64 | bool newStyle;
|
|---|
| 65 | };
|
|---|
| 66 |
|
|---|
| 67 | struct Symbolic_t {
|
|---|
| 68 | std::string name;
|
|---|
| 69 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname
|
|---|
| 70 | DeclarationNode * params;
|
|---|
| 71 | ExpressionNode * actuals;
|
|---|
| 72 | DeclarationNode * assertions;
|
|---|
| 73 | };
|
|---|
| 74 |
|
|---|
| 75 | struct Variable_t {
|
|---|
| 76 | DeclarationNode::TypeClass tyClass;
|
|---|
| 77 | std::string name;
|
|---|
| 78 | DeclarationNode * assertions;
|
|---|
| 79 | };
|
|---|
| 80 |
|
|---|
| 81 | struct Tuple_t {
|
|---|
| 82 | DeclarationNode * members;
|
|---|
| 83 | };
|
|---|
| 84 |
|
|---|
| 85 | struct Typeof_t {
|
|---|
| 86 | ExpressionNode * expr;
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 | struct Builtin_t {
|
|---|
| 90 | DeclarationNode::BuiltinType type;
|
|---|
| 91 | };
|
|---|
| 92 |
|
|---|
| 93 | struct Attr_t {
|
|---|
| 94 | std::string name;
|
|---|
| 95 | ExpressionNode * expr;
|
|---|
| 96 | DeclarationNode * type;
|
|---|
| 97 | };
|
|---|
| 98 |
|
|---|
| 99 | TypeData * base;
|
|---|
| 100 | typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers;
|
|---|
| 101 | Qualifiers qualifiers;
|
|---|
| 102 | DeclarationNode * forall;
|
|---|
| 103 |
|
|---|
| 104 | union {
|
|---|
| 105 | Basic_t * basic;
|
|---|
| 106 | Aggregate_t * aggregate;
|
|---|
| 107 | AggInst_t * aggInst;
|
|---|
| 108 | Array_t * array;
|
|---|
| 109 | Enumeration_t * enumeration;
|
|---|
| 110 | Function_t * function;
|
|---|
| 111 | Symbolic_t * symbolic;
|
|---|
| 112 | Variable_t * variable;
|
|---|
| 113 | Tuple_t * tuple;
|
|---|
| 114 | Typeof_t * typeexpr;
|
|---|
| 115 | Attr_t * attr;
|
|---|
| 116 | Builtin_t * builtin;
|
|---|
| 117 | };
|
|---|
| 118 |
|
|---|
| 119 | TypeData( Kind k = Unknown );
|
|---|
| 120 | ~TypeData();
|
|---|
| 121 | void print( std::ostream &, int indent = 0 ) const;
|
|---|
| 122 | TypeData * clone() const;
|
|---|
| 123 | };
|
|---|
| 124 |
|
|---|
| 125 | Type * typebuild( const TypeData * );
|
|---|
| 126 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
|
|---|
| 127 | Type::Qualifiers buildQualifiers( const TypeData * td );
|
|---|
| 128 | Type * buildBasicType( const TypeData * );
|
|---|
| 129 | PointerType * buildPointer( const TypeData * );
|
|---|
| 130 | ArrayType * buildArray( const TypeData * );
|
|---|
| 131 | AggregateDecl * buildAggregate( const TypeData * );
|
|---|
| 132 | ReferenceToType * buildAggInst( const TypeData * );
|
|---|
| 133 | NamedTypeDecl * buildSymbolic( const TypeData *, const std::string &name, DeclarationNode::StorageClass sc );
|
|---|
| 134 | TypeDecl * buildVariable( const TypeData * );
|
|---|
| 135 | EnumDecl * buildEnum( const TypeData * );
|
|---|
| 136 | TypeInstType * buildSymbolicInst( const TypeData * );
|
|---|
| 137 | TupleType * buildTuple( const TypeData * );
|
|---|
| 138 | TypeofType * buildTypeof( const TypeData * );
|
|---|
| 139 | AttrType * buildAttr( const TypeData * );
|
|---|
| 140 | Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 );
|
|---|
| 141 | FunctionType * buildFunction( const TypeData * );
|
|---|
| 142 |
|
|---|
| 143 | #endif // TYPEDATA_H
|
|---|
| 144 |
|
|---|
| 145 | // Local Variables: //
|
|---|
| 146 | // tab-width: 4 //
|
|---|
| 147 | // mode: c++ //
|
|---|
| 148 | // compile-command: "make install" //
|
|---|
| 149 | // End: //
|
|---|