source: src/Parser/TypeData.h @ 4520b77e

ADTast-experimentalpthread-emulation
Last change on this file since 4520b77e was 4520b77e, checked in by JiadaL <j82liang@…>, 20 months ago

Merge to Master Sept 19

  • Property mode set to 100644
File size: 4.7 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 : Tue May 10 22:18:49 2022
13// Update Count     : 203
14//
15
16#pragma once
17
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 "SynTree/LinkageSpec.h"                                                // for Spec
24#include "SynTree/Type.h"                                                               // for Type, ReferenceToType (ptr only)
25#include "SynTree/SynTree.h"                                                    // for Visitor Nodes
26
27struct TypeData {
28        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
29                                SymbolicInst, Tuple, Basetypeof, Typeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
30
31        struct Aggregate_t {
32                AggregateDecl::Aggregate kind;
33                const std::string * name = nullptr;
34                DeclarationNode * params = nullptr;
35                ExpressionNode * actuals = nullptr;                             // holds actual parameters later applied to AggInst
36                DeclarationNode * fields = nullptr;
37                bool body;
38                bool anon;
39
40                bool tagged;
41                const std::string * parent = nullptr;
42        };
43
44        struct AggInst_t {
45                TypeData * aggregate = nullptr;
46                ExpressionNode * params = nullptr;
47                bool hoistType;
48        };
49
50        struct Array_t {
51                ExpressionNode * dimension = nullptr;
52                bool isVarLen;
53                bool isStatic;
54        };
55
56        struct Enumeration_t {
57                const std::string * name = nullptr;
58                DeclarationNode * constants = nullptr;
59                bool body;
60                bool anon;
61                bool typed;
62        };
63
64        struct Function_t {
65                mutable DeclarationNode * params = nullptr;             // mutables modified in buildKRFunction
66                mutable DeclarationNode * idList = nullptr;             // old-style
67                mutable DeclarationNode * oldDeclList = nullptr;
68                StatementNode * body = nullptr;
69                ExpressionNode * withExprs = nullptr;                   // expressions from function's with_clause
70        };
71
72        struct Symbolic_t {
73                const std::string * name = nullptr;
74                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
75                DeclarationNode * params = nullptr;
76                ExpressionNode * actuals = nullptr;
77                DeclarationNode * assertions = nullptr;
78        };
79
80        struct Qualified_t {                                                            // qualified type S.T
81                TypeData * parent = nullptr;
82                TypeData * child = nullptr;
83        };
84
85        CodeLocation location;
86
87        Kind kind;
88        TypeData * base;
89        DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
90        DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
91        DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
92        DeclarationNode::Length length = DeclarationNode::NoLength;
93        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
94
95        Type::Qualifiers qualifiers;
96        DeclarationNode * forall = nullptr;
97
98        Aggregate_t aggregate;
99        AggInst_t aggInst;
100        Array_t array;
101        Enumeration_t enumeration;
102        Function_t function;
103        Symbolic_t symbolic;
104        Qualified_t qualified;
105        DeclarationNode * tuple = nullptr;
106        ExpressionNode * typeexpr = nullptr;
107
108        TypeData( Kind k = Unknown );
109        ~TypeData();
110        void print( std::ostream &, int indent = 0 ) const;
111        TypeData * clone() const;
112
113        const std::string * leafName() const;
114};
115
116Type * typebuild( const TypeData * );
117TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
118Type::Qualifiers buildQualifiers( const TypeData * td );
119Type * buildBasicType( const TypeData * );
120PointerType * buildPointer( const TypeData * );
121ArrayType * buildArray( const TypeData * );
122ReferenceType * buildReference( const TypeData * );
123AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > );
124ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage );
125ReferenceToType * buildAggInst( const TypeData * );
126TypeDecl * buildVariable( const TypeData * );
127EnumDecl * buildEnum( const TypeData *, std::list< Attribute * >, LinkageSpec::Spec );
128TypeInstType * buildSymbolicInst( const TypeData * );
129TupleType * buildTuple( const TypeData * );
130TypeofType * buildTypeof( const TypeData * );
131VTableType * buildVtable( const TypeData * );
132Declaration * 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 * >() );
134FunctionType * buildFunction( const TypeData * );
135Declaration * 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.