[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 |
---|
| 12 | // Last Modified On : Fri Sep 1 23:33:45 2017 |
---|
| 13 | // Update Count : 190 |
---|
[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, |
---|
[faddbd8] | 29 | SymbolicInst, Tuple, Typeof, Builtin, 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; |
---|
[6ea87486] | 38 | |
---|
| 39 | bool tagged; |
---|
| 40 | const std::string * parent; |
---|
[b87a5ed] | 41 | }; |
---|
| 42 | |
---|
| 43 | struct AggInst_t { |
---|
[7ee14bb7] | 44 | TypeData * aggregate; |
---|
| 45 | ExpressionNode * params; |
---|
[43c89a7] | 46 | bool hoistType; |
---|
[b87a5ed] | 47 | }; |
---|
| 48 | |
---|
| 49 | struct Array_t { |
---|
[7ee14bb7] | 50 | ExpressionNode * dimension; |
---|
[b87a5ed] | 51 | bool isVarLen; |
---|
| 52 | bool isStatic; |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | struct Enumeration_t { |
---|
[2298f728] | 56 | const std::string * name; |
---|
[7ee14bb7] | 57 | DeclarationNode * constants; |
---|
[ca1a547] | 58 | bool body; |
---|
[b87a5ed] | 59 | }; |
---|
| 60 | |
---|
| 61 | struct Function_t { |
---|
[3a5131ed] | 62 | mutable DeclarationNode * params; // mutables modified in buildKRFunction |
---|
| 63 | mutable DeclarationNode * idList; // old-style |
---|
| 64 | mutable DeclarationNode * oldDeclList; |
---|
[7ee14bb7] | 65 | StatementNode * body; |
---|
[b87a5ed] | 66 | bool newStyle; |
---|
[84276ba] | 67 | ExpressionNode * withExprs; // expressions from function's with_clause |
---|
[b87a5ed] | 68 | }; |
---|
| 69 | |
---|
| 70 | struct Symbolic_t { |
---|
[2298f728] | 71 | const std::string * name; |
---|
[721f17a] | 72 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname |
---|
[7ee14bb7] | 73 | DeclarationNode * params; |
---|
| 74 | ExpressionNode * actuals; |
---|
| 75 | DeclarationNode * assertions; |
---|
[b87a5ed] | 76 | }; |
---|
| 77 | |
---|
[28307be] | 78 | Kind kind; |
---|
[413ad05] | 79 | TypeData * base; |
---|
[5b639ee] | 80 | DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType; |
---|
| 81 | DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType; |
---|
| 82 | DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness; |
---|
| 83 | DeclarationNode::Length length = DeclarationNode::NoLength; |
---|
[148f7290] | 84 | DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; |
---|
[c3396e0] | 85 | |
---|
[738e304] | 86 | Type::Qualifiers qualifiers; |
---|
[413ad05] | 87 | DeclarationNode * forall; |
---|
| 88 | |
---|
[c3396e0] | 89 | // Basic_t basic; |
---|
| 90 | Aggregate_t aggregate; |
---|
| 91 | AggInst_t aggInst; |
---|
| 92 | Array_t array; |
---|
| 93 | Enumeration_t enumeration; |
---|
| 94 | // Variable_t variable; |
---|
| 95 | Function_t function; |
---|
| 96 | Symbolic_t symbolic; |
---|
| 97 | DeclarationNode * tuple; |
---|
| 98 | ExpressionNode * typeexpr; |
---|
[b87a5ed] | 99 | |
---|
[413ad05] | 100 | TypeData( Kind k = Unknown ); |
---|
| 101 | ~TypeData(); |
---|
| 102 | void print( std::ostream &, int indent = 0 ) const; |
---|
| 103 | TypeData * clone() const; |
---|
[51b7345] | 104 | }; |
---|
| 105 | |
---|
[413ad05] | 106 | Type * typebuild( const TypeData * ); |
---|
| 107 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true ); |
---|
| 108 | Type::Qualifiers buildQualifiers( const TypeData * td ); |
---|
| 109 | Type * buildBasicType( const TypeData * ); |
---|
| 110 | PointerType * buildPointer( const TypeData * ); |
---|
| 111 | ArrayType * buildArray( const TypeData * ); |
---|
[ce8c12f] | 112 | ReferenceType * buildReference( const TypeData * ); |
---|
[c0aa336] | 113 | AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > ); |
---|
[fa4805f] | 114 | ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ); |
---|
[413ad05] | 115 | ReferenceToType * buildAggInst( const TypeData * ); |
---|
| 116 | TypeDecl * buildVariable( const TypeData * ); |
---|
[bd46af4] | 117 | EnumDecl * buildEnum( const TypeData *, std::list< Attribute * >, LinkageSpec::Spec ); |
---|
[413ad05] | 118 | TypeInstType * buildSymbolicInst( const TypeData * ); |
---|
| 119 | TupleType * buildTuple( const TypeData * ); |
---|
| 120 | TypeofType * buildTypeof( const TypeData * ); |
---|
[e612146c] | 121 | Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); |
---|
[413ad05] | 122 | FunctionType * buildFunction( const TypeData * ); |
---|
[3a5131ed] | 123 | void buildKRFunction( const TypeData::Function_t & function ); |
---|
[413ad05] | 124 | |
---|
[b87a5ed] | 125 | // Local Variables: // |
---|
| 126 | // tab-width: 4 // |
---|
| 127 | // mode: c++ // |
---|
| 128 | // compile-command: "make install" // |
---|
| 129 | // End: // |
---|