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 : Sat Mar 27 09:05:35 2021 |
---|
13 | // Update Count : 200 |
---|
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 | |
---|
27 | struct TypeData { |
---|
28 | enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, |
---|
29 | SymbolicInst, Tuple, Typeof, Basetypeof, 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 | }; |
---|
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 | Type::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 | |
---|
115 | Type * typebuild( const TypeData * ); |
---|
116 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true ); |
---|
117 | Type::Qualifiers buildQualifiers( const TypeData * td ); |
---|
118 | Type * buildBasicType( const TypeData * ); |
---|
119 | PointerType * buildPointer( const TypeData * ); |
---|
120 | ArrayType * buildArray( const TypeData * ); |
---|
121 | ReferenceType * buildReference( const TypeData * ); |
---|
122 | AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > ); |
---|
123 | ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ); |
---|
124 | ReferenceToType * buildAggInst( const TypeData * ); |
---|
125 | TypeDecl * buildVariable( const TypeData * ); |
---|
126 | EnumDecl * buildEnum( const TypeData *, std::list< Attribute * >, LinkageSpec::Spec ); |
---|
127 | TypeInstType * buildSymbolicInst( const TypeData * ); |
---|
128 | TupleType * buildTuple( const TypeData * ); |
---|
129 | TypeofType * buildTypeof( const TypeData * ); |
---|
130 | Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, |
---|
131 | Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); |
---|
132 | FunctionType * buildFunction( const TypeData * ); |
---|
133 | void buildKRFunction( const TypeData::Function_t & function ); |
---|
134 | |
---|
135 | // Local Variables: // |
---|
136 | // tab-width: 4 // |
---|
137 | // mode: c++ // |
---|
138 | // compile-command: "make install" // |
---|
139 | // End: // |
---|