[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 |
---|
[faddbd8] | 12 | // Last Modified On : Mon Oct 3 12:34:08 2016 |
---|
| 13 | // Update Count : 142 |
---|
[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 { |
---|
[faddbd8] | 25 | enum Kind { Basic, Pointer, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, |
---|
| 26 | SymbolicInst, Tuple, Typeof, Builtin, Unknown }; |
---|
[b87a5ed] | 27 | |
---|
| 28 | struct Aggregate_t { |
---|
[68cd1ce] | 29 | DeclarationNode::Aggregate kind; |
---|
[2298f728] | 30 | const std::string * name; |
---|
[7ee14bb7] | 31 | DeclarationNode * params; |
---|
[2298f728] | 32 | ExpressionNode * actuals; // holds actual parameters later applied to AggInst |
---|
[7ee14bb7] | 33 | DeclarationNode * fields; |
---|
[5d125e4] | 34 | bool body; |
---|
[b87a5ed] | 35 | }; |
---|
| 36 | |
---|
| 37 | struct AggInst_t { |
---|
[7ee14bb7] | 38 | TypeData * aggregate; |
---|
| 39 | ExpressionNode * params; |
---|
[b87a5ed] | 40 | }; |
---|
| 41 | |
---|
| 42 | struct Array_t { |
---|
[7ee14bb7] | 43 | ExpressionNode * dimension; |
---|
[b87a5ed] | 44 | bool isVarLen; |
---|
| 45 | bool isStatic; |
---|
| 46 | }; |
---|
| 47 | |
---|
| 48 | struct Enumeration_t { |
---|
[2298f728] | 49 | const std::string * name; |
---|
[7ee14bb7] | 50 | DeclarationNode * constants; |
---|
[b87a5ed] | 51 | }; |
---|
| 52 | |
---|
| 53 | struct Function_t { |
---|
[7ee14bb7] | 54 | DeclarationNode * params; |
---|
| 55 | DeclarationNode * idList; // old-style |
---|
| 56 | DeclarationNode * oldDeclList; |
---|
| 57 | StatementNode * body; |
---|
[b87a5ed] | 58 | bool hasBody; |
---|
| 59 | bool newStyle; |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | struct Symbolic_t { |
---|
[2298f728] | 63 | const std::string * name; |
---|
[721f17a] | 64 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname |
---|
[7ee14bb7] | 65 | DeclarationNode * params; |
---|
| 66 | ExpressionNode * actuals; |
---|
| 67 | DeclarationNode * assertions; |
---|
[b87a5ed] | 68 | }; |
---|
| 69 | |
---|
[28307be] | 70 | Kind kind; |
---|
[413ad05] | 71 | TypeData * base; |
---|
[5b639ee] | 72 | DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType; |
---|
| 73 | DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType; |
---|
| 74 | DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness; |
---|
| 75 | DeclarationNode::Length length = DeclarationNode::NoLength; |
---|
| 76 | typedef std::bitset< DeclarationNode::NoQualifier > Qualifiers; |
---|
[413ad05] | 77 | Qualifiers qualifiers; |
---|
| 78 | DeclarationNode * forall; |
---|
| 79 | |
---|
[5b639ee] | 80 | // Basic_t basic; |
---|
[8f6f47d7] | 81 | Aggregate_t aggregate; |
---|
| 82 | AggInst_t aggInst; |
---|
| 83 | Array_t array; |
---|
| 84 | Enumeration_t enumeration; |
---|
[7d05e7e] | 85 | // Variable_t variable; |
---|
[8f6f47d7] | 86 | Function_t function; |
---|
| 87 | Symbolic_t symbolic; |
---|
| 88 | DeclarationNode * tuple; |
---|
| 89 | ExpressionNode * typeexpr; |
---|
| 90 | // DeclarationNode::BuiltinType builtin; |
---|
[b87a5ed] | 91 | |
---|
[413ad05] | 92 | TypeData( Kind k = Unknown ); |
---|
| 93 | ~TypeData(); |
---|
| 94 | void print( std::ostream &, int indent = 0 ) const; |
---|
| 95 | TypeData * clone() const; |
---|
[51b7345] | 96 | }; |
---|
| 97 | |
---|
[413ad05] | 98 | Type * typebuild( const TypeData * ); |
---|
| 99 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true ); |
---|
| 100 | Type::Qualifiers buildQualifiers( const TypeData * td ); |
---|
| 101 | Type * buildBasicType( const TypeData * ); |
---|
| 102 | PointerType * buildPointer( const TypeData * ); |
---|
| 103 | ArrayType * buildArray( const TypeData * ); |
---|
| 104 | AggregateDecl * buildAggregate( const TypeData * ); |
---|
| 105 | ReferenceToType * buildAggInst( const TypeData * ); |
---|
| 106 | NamedTypeDecl * buildSymbolic( const TypeData *, const std::string &name, DeclarationNode::StorageClass sc ); |
---|
| 107 | TypeDecl * buildVariable( const TypeData * ); |
---|
| 108 | EnumDecl * buildEnum( const TypeData * ); |
---|
| 109 | TypeInstType * buildSymbolicInst( const TypeData * ); |
---|
| 110 | TupleType * buildTuple( const TypeData * ); |
---|
| 111 | TypeofType * buildTypeof( const TypeData * ); |
---|
[2298f728] | 112 | Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = nullptr ); |
---|
[413ad05] | 113 | FunctionType * buildFunction( const TypeData * ); |
---|
| 114 | |
---|
[c8ffe20b] | 115 | #endif // TYPEDATA_H |
---|
[b87a5ed] | 116 | |
---|
| 117 | // Local Variables: // |
---|
| 118 | // tab-width: 4 // |
---|
| 119 | // mode: c++ // |
---|
| 120 | // compile-command: "make install" // |
---|
| 121 | // End: // |
---|