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