[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 |
---|
[e612146c] | 11 | // Last Modified By : Peter A. Buhr |
---|
[8f91c9ae] | 12 | // Last Modified On : Thu Jul 12 14:00:09 2018 |
---|
| 13 | // Update Count : 193 |
---|
[b87a5ed] | 14 | // |
---|
| 15 | |
---|
[6b0b624] | 16 | #pragma once |
---|
[51b7345] | 17 | |
---|
[d180746] | 18 | #include <iosfwd> // for ostream |
---|
| 19 | #include <list> // for list |
---|
| 20 | #include <string> // for string |
---|
| 21 | |
---|
| 22 | #include "ParseNode.h" // for DeclarationNode, DeclarationNode::Ag... |
---|
| 23 | #include "Parser/LinkageSpec.h" // for Spec |
---|
| 24 | #include "SynTree/Type.h" // for Type, ReferenceToType (ptr only) |
---|
| 25 | #include "SynTree/SynTree.h" // for Visitor Nodes |
---|
[51b7345] | 26 | |
---|
[c8ffe20b] | 27 | struct TypeData { |
---|
[ce8c12f] | 28 | enum Kind { Basic, Pointer, Array, Reference, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, |
---|
[c194661] | 29 | SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Qualified, Unknown }; |
---|
[b87a5ed] | 30 | |
---|
| 31 | struct Aggregate_t { |
---|
[68cd1ce] | 32 | DeclarationNode::Aggregate kind; |
---|
[2298f728] | 33 | const std::string * name; |
---|
[7ee14bb7] | 34 | DeclarationNode * params; |
---|
[2298f728] | 35 | ExpressionNode * actuals; // holds actual parameters later applied to AggInst |
---|
[7ee14bb7] | 36 | DeclarationNode * fields; |
---|
[5d125e4] | 37 | bool body; |
---|
[3d7e53b] | 38 | bool anon; |
---|
[8f91c9ae] | 39 | bool inLine; |
---|
[6ea87486] | 40 | |
---|
| 41 | bool tagged; |
---|
| 42 | const std::string * parent; |
---|
[b87a5ed] | 43 | }; |
---|
| 44 | |
---|
| 45 | struct AggInst_t { |
---|
[7ee14bb7] | 46 | TypeData * aggregate; |
---|
| 47 | ExpressionNode * params; |
---|
[43c89a7] | 48 | bool hoistType; |
---|
[8f91c9ae] | 49 | bool inLine; |
---|
[b87a5ed] | 50 | }; |
---|
| 51 | |
---|
| 52 | struct Array_t { |
---|
[7ee14bb7] | 53 | ExpressionNode * dimension; |
---|
[b87a5ed] | 54 | bool isVarLen; |
---|
| 55 | bool isStatic; |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | struct Enumeration_t { |
---|
[2298f728] | 59 | const std::string * name; |
---|
[7ee14bb7] | 60 | DeclarationNode * constants; |
---|
[ca1a547] | 61 | bool body; |
---|
[3d7e53b] | 62 | bool anon; |
---|
[b87a5ed] | 63 | }; |
---|
| 64 | |
---|
| 65 | struct Function_t { |
---|
[3a5131ed] | 66 | mutable DeclarationNode * params; // mutables modified in buildKRFunction |
---|
| 67 | mutable DeclarationNode * idList; // old-style |
---|
| 68 | mutable DeclarationNode * oldDeclList; |
---|
[7ee14bb7] | 69 | StatementNode * body; |
---|
[8f91c9ae] | 70 | ExpressionNode * withExprs; // expressions from function's with_clause |
---|
[b87a5ed] | 71 | }; |
---|
| 72 | |
---|
| 73 | struct Symbolic_t { |
---|
[2298f728] | 74 | const std::string * name; |
---|
[721f17a] | 75 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname |
---|
[7ee14bb7] | 76 | DeclarationNode * params; |
---|
| 77 | ExpressionNode * actuals; |
---|
| 78 | DeclarationNode * assertions; |
---|
[b87a5ed] | 79 | }; |
---|
| 80 | |
---|
[c194661] | 81 | struct Qualified_t { // qualified type S.T |
---|
| 82 | TypeData * parent; |
---|
| 83 | TypeData * child; |
---|
| 84 | }; |
---|
| 85 | |
---|
[0b0f1dd] | 86 | CodeLocation location; |
---|
| 87 | |
---|
[28307be] | 88 | Kind kind; |
---|
[413ad05] | 89 | TypeData * base; |
---|
[5b639ee] | 90 | DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType; |
---|
| 91 | DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType; |
---|
| 92 | DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness; |
---|
| 93 | DeclarationNode::Length length = DeclarationNode::NoLength; |
---|
[148f7290] | 94 | DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; |
---|
[c3396e0] | 95 | |
---|
[738e304] | 96 | Type::Qualifiers qualifiers; |
---|
[413ad05] | 97 | DeclarationNode * forall; |
---|
| 98 | |
---|
[c3396e0] | 99 | Aggregate_t aggregate; |
---|
| 100 | AggInst_t aggInst; |
---|
| 101 | Array_t array; |
---|
| 102 | Enumeration_t enumeration; |
---|
| 103 | Function_t function; |
---|
| 104 | Symbolic_t symbolic; |
---|
[c194661] | 105 | Qualified_t qualified; |
---|
[c3396e0] | 106 | DeclarationNode * tuple; |
---|
| 107 | ExpressionNode * typeexpr; |
---|
[b87a5ed] | 108 | |
---|
[413ad05] | 109 | TypeData( Kind k = Unknown ); |
---|
| 110 | ~TypeData(); |
---|
| 111 | void print( std::ostream &, int indent = 0 ) const; |
---|
| 112 | TypeData * clone() const; |
---|
[7de22b28] | 113 | |
---|
| 114 | const std::string * leafName() const; |
---|
[51b7345] | 115 | }; |
---|
| 116 | |
---|
[413ad05] | 117 | Type * typebuild( const TypeData * ); |
---|
| 118 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true ); |
---|
| 119 | Type::Qualifiers buildQualifiers( const TypeData * td ); |
---|
| 120 | Type * buildBasicType( const TypeData * ); |
---|
| 121 | PointerType * buildPointer( const TypeData * ); |
---|
| 122 | ArrayType * buildArray( const TypeData * ); |
---|
[ce8c12f] | 123 | ReferenceType * buildReference( const TypeData * ); |
---|
[c0aa336] | 124 | AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > ); |
---|
[fa4805f] | 125 | ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ); |
---|
[413ad05] | 126 | ReferenceToType * buildAggInst( const TypeData * ); |
---|
| 127 | TypeDecl * buildVariable( const TypeData * ); |
---|
[bd46af4] | 128 | EnumDecl * buildEnum( const TypeData *, std::list< Attribute * >, LinkageSpec::Spec ); |
---|
[413ad05] | 129 | TypeInstType * buildSymbolicInst( const TypeData * ); |
---|
| 130 | TupleType * buildTuple( const TypeData * ); |
---|
| 131 | TypeofType * buildTypeof( const TypeData * ); |
---|
[8f91c9ae] | 132 | Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, |
---|
| 133 | Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); |
---|
[413ad05] | 134 | FunctionType * buildFunction( const TypeData * ); |
---|
[3a5131ed] | 135 | void buildKRFunction( const TypeData::Function_t & function ); |
---|
[413ad05] | 136 | |
---|
[b87a5ed] | 137 | // Local Variables: // |
---|
| 138 | // tab-width: 4 // |
---|
| 139 | // mode: c++ // |
---|
| 140 | // compile-command: "make install" // |
---|
| 141 | // End: // |
---|