source: src/Parser/TypeData.h @ 44adf1b

Last change on this file since 44adf1b was 4eb3a7c5, checked in by Peter A. Buhr <pabuhr@…>, 4 months ago

first attempt at correct distribution of attributes for aggregates

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