[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 | // |
---|
[148f7290] | 7 | // TypeData.h -- |
---|
[b87a5ed] | 8 | // |
---|
| 9 | // Author : Rodolfo G. Esteves |
---|
| 10 | // Created On : Sat May 16 15:18:36 2015 |
---|
[fa4805f] | 11 | // Last Modified By : Andrew Beach |
---|
| 12 | // Last Modified On : Wed Jun 28 15:29:00 2017 |
---|
| 13 | // Update Count : 186 |
---|
[b87a5ed] | 14 | // |
---|
| 15 | |
---|
[51b7345] | 16 | #ifndef TYPEDATA_H |
---|
| 17 | #define TYPEDATA_H |
---|
| 18 | |
---|
| 19 | #include "ParseNode.h" |
---|
| 20 | #include "SynTree/Type.h" |
---|
| 21 | |
---|
[c8ffe20b] | 22 | struct TypeData { |
---|
[faddbd8] | 23 | enum Kind { Basic, Pointer, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, |
---|
| 24 | SymbolicInst, Tuple, Typeof, Builtin, Unknown }; |
---|
[b87a5ed] | 25 | |
---|
| 26 | struct Aggregate_t { |
---|
[68cd1ce] | 27 | DeclarationNode::Aggregate kind; |
---|
[2298f728] | 28 | const std::string * name; |
---|
[7ee14bb7] | 29 | DeclarationNode * params; |
---|
[2298f728] | 30 | ExpressionNode * actuals; // holds actual parameters later applied to AggInst |
---|
[7ee14bb7] | 31 | DeclarationNode * fields; |
---|
[5d125e4] | 32 | bool body; |
---|
[b87a5ed] | 33 | }; |
---|
| 34 | |
---|
| 35 | struct AggInst_t { |
---|
[7ee14bb7] | 36 | TypeData * aggregate; |
---|
| 37 | ExpressionNode * params; |
---|
[43c89a7] | 38 | bool hoistType; |
---|
[b87a5ed] | 39 | }; |
---|
| 40 | |
---|
| 41 | struct Array_t { |
---|
[7ee14bb7] | 42 | ExpressionNode * dimension; |
---|
[b87a5ed] | 43 | bool isVarLen; |
---|
| 44 | bool isStatic; |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | struct Enumeration_t { |
---|
[2298f728] | 48 | const std::string * name; |
---|
[7ee14bb7] | 49 | DeclarationNode * constants; |
---|
[ca1a547] | 50 | bool body; |
---|
[b87a5ed] | 51 | }; |
---|
| 52 | |
---|
| 53 | struct Function_t { |
---|
[3a5131ed] | 54 | mutable DeclarationNode * params; // mutables modified in buildKRFunction |
---|
| 55 | mutable DeclarationNode * idList; // old-style |
---|
| 56 | mutable DeclarationNode * oldDeclList; |
---|
[7ee14bb7] | 57 | StatementNode * body; |
---|
[b87a5ed] | 58 | bool newStyle; |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | struct Symbolic_t { |
---|
[2298f728] | 62 | const std::string * name; |
---|
[721f17a] | 63 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname |
---|
[7ee14bb7] | 64 | DeclarationNode * params; |
---|
| 65 | ExpressionNode * actuals; |
---|
| 66 | DeclarationNode * assertions; |
---|
[b87a5ed] | 67 | }; |
---|
| 68 | |
---|
[28307be] | 69 | Kind kind; |
---|
[413ad05] | 70 | TypeData * base; |
---|
[5b639ee] | 71 | DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType; |
---|
| 72 | DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType; |
---|
| 73 | DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness; |
---|
| 74 | DeclarationNode::Length length = DeclarationNode::NoLength; |
---|
[148f7290] | 75 | DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; |
---|
[c3396e0] | 76 | |
---|
[738e304] | 77 | Type::Qualifiers qualifiers; |
---|
[413ad05] | 78 | DeclarationNode * forall; |
---|
| 79 | |
---|
[c3396e0] | 80 | // Basic_t basic; |
---|
| 81 | Aggregate_t aggregate; |
---|
| 82 | AggInst_t aggInst; |
---|
| 83 | Array_t array; |
---|
| 84 | Enumeration_t enumeration; |
---|
| 85 | // Variable_t variable; |
---|
| 86 | Function_t function; |
---|
| 87 | Symbolic_t symbolic; |
---|
| 88 | DeclarationNode * tuple; |
---|
| 89 | ExpressionNode * typeexpr; |
---|
[b87a5ed] | 90 | |
---|
[413ad05] | 91 | TypeData( Kind k = Unknown ); |
---|
| 92 | ~TypeData(); |
---|
| 93 | void print( std::ostream &, int indent = 0 ) const; |
---|
| 94 | TypeData * clone() const; |
---|
[51b7345] | 95 | }; |
---|
| 96 | |
---|
[413ad05] | 97 | Type * typebuild( const TypeData * ); |
---|
| 98 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true ); |
---|
| 99 | Type::Qualifiers buildQualifiers( const TypeData * td ); |
---|
| 100 | Type * buildBasicType( const TypeData * ); |
---|
| 101 | PointerType * buildPointer( const TypeData * ); |
---|
| 102 | ArrayType * buildArray( const TypeData * ); |
---|
[c0aa336] | 103 | AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > ); |
---|
[fa4805f] | 104 | ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ); |
---|
[413ad05] | 105 | ReferenceToType * buildAggInst( const TypeData * ); |
---|
| 106 | TypeDecl * buildVariable( const TypeData * ); |
---|
[c0aa336] | 107 | EnumDecl * buildEnum( const TypeData *, std::list< Attribute * > ); |
---|
[413ad05] | 108 | TypeInstType * buildSymbolicInst( const TypeData * ); |
---|
| 109 | TupleType * buildTuple( const TypeData * ); |
---|
| 110 | TypeofType * buildTypeof( const TypeData * ); |
---|
[ddfd945] | 111 | Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); |
---|
[413ad05] | 112 | FunctionType * buildFunction( const TypeData * ); |
---|
[3a5131ed] | 113 | void buildKRFunction( const TypeData::Function_t & function ); |
---|
[413ad05] | 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: // |
---|