source: src/Parser/TypeData.h @ 5007618

ast-experimental
Last change on this file since 5007618 was c468150, checked in by Andrew Beach <ajbeach@…>, 14 months ago

Split up ParseNode?.h so that headers match implementation. May have a bit less to include total because of it.

  • 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 : Andrew Beach
12// Last Modified On : Wed Mar  1 10:44:00 2023
13// Update Count     : 206
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                DeclarationNode * params = nullptr;
33                ExpressionNode * actuals = nullptr;                             // holds actual parameters later applied to AggInst
34                DeclarationNode * fields = nullptr;
35                bool body;
36                bool anon;
37                bool tagged;
38                const std::string * parent = nullptr;
39        };
40
41        struct AggInst_t {
42                TypeData * aggregate = nullptr;
43                ExpressionNode * params = nullptr;
44                bool hoistType;
45        };
46
47        struct Array_t {
48                ExpressionNode * dimension = nullptr;
49                bool isVarLen;
50                bool isStatic;
51        };
52
53        struct Enumeration_t {
54                const std::string * name = nullptr;
55                DeclarationNode * constants = nullptr;
56                bool body;
57                bool anon;
58                bool typed;
59                EnumHiding hiding;
60        };
61
62        struct Function_t {
63                mutable DeclarationNode * params = nullptr;             // mutables modified in buildKRFunction
64                mutable DeclarationNode * idList = nullptr;             // old-style
65                mutable DeclarationNode * oldDeclList = nullptr;
66                StatementNode * body = nullptr;
67                ExpressionNode * withExprs = nullptr;                   // expressions from function's with_clause
68        };
69
70        struct Symbolic_t {
71                const std::string * name = nullptr;
72                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
73                DeclarationNode * params = nullptr;
74                ExpressionNode * actuals = nullptr;
75                DeclarationNode * assertions = nullptr;
76        };
77
78        struct Qualified_t {                                                            // qualified type S.T
79                TypeData * parent = nullptr;
80                TypeData * child = nullptr;
81        };
82
83        CodeLocation location;
84
85        Kind kind;
86        TypeData * base;
87        DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
88        DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
89        DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
90        DeclarationNode::Length length = DeclarationNode::NoLength;
91        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
92
93        ast::CV::Qualifiers qualifiers;
94        DeclarationNode * forall = nullptr;
95
96        Aggregate_t aggregate;
97        AggInst_t aggInst;
98        Array_t array;
99        Enumeration_t enumeration;
100        Function_t function;
101        Symbolic_t symbolic;
102        Qualified_t qualified;
103        DeclarationNode * tuple = nullptr;
104        ExpressionNode * typeexpr = nullptr;
105
106        TypeData( Kind k = Unknown );
107        ~TypeData();
108        void print( std::ostream &, int indent = 0 ) const;
109        TypeData * clone() const;
110
111        const std::string * leafName() const;
112};
113
114ast::Type * typebuild( const TypeData * );
115TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
116ast::CV::Qualifiers buildQualifiers( const TypeData * td );
117ast::Type * buildBasicType( const TypeData * );
118ast::PointerType * buildPointer( const TypeData * );
119ast::ArrayType * buildArray( const TypeData * );
120ast::ReferenceType * buildReference( const TypeData * );
121ast::AggregateDecl * buildAggregate( const TypeData *, std::vector<ast::ptr<ast::Attribute>> );
122ast::BaseInstType * buildComAggInst( const TypeData *, std::vector<ast::ptr<ast::Attribute>> && attributes, ast::Linkage::Spec linkage );
123ast::BaseInstType * buildAggInst( const TypeData * );
124ast::TypeDecl * buildVariable( const TypeData * );
125ast::EnumDecl * buildEnum( const TypeData *, std::vector<ast::ptr<ast::Attribute>> &&, ast::Linkage::Spec );
126ast::TypeInstType * buildSymbolicInst( const TypeData * );
127ast::TupleType * buildTuple( const TypeData * );
128ast::TypeofType * buildTypeof( const TypeData * );
129ast::VTableType * buildVtable( const TypeData * );
130ast::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>>() );
134ast::FunctionType * buildFunctionType( const TypeData * );
135ast::Decl * addEnumBase( Declaration *, 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.