source: src/Parser/TypeData.h @ e82aa9df

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since e82aa9df was e82aa9df, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

more refactoring of parser code

  • Property mode set to 100644
File size: 3.6 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           : Rodolfo G. Esteves
10// Created On       : Sat May 16 15:18:36 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon Aug 15 14:28:32 2016
13// Update Count     : 21
14//
15
16#ifndef TYPEDATA_H
17#define TYPEDATA_H
18
19#include <list>
20
21#include "ParseNode.h"
22#include "SynTree/Type.h"
23
24struct TypeData {
25        enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst,
26                                Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr } kind;
27
28        TypeData( Kind k = Unknown );
29        ~TypeData();
30        void print( std::ostream &, int indent = 0 ) const;
31        TypeData * clone() const;
32
33        Type * build() const;
34        FunctionType * buildFunction() const;
35
36        TypeData * base;
37        std::list< DeclarationNode::Qualifier > qualifiers;
38        DeclarationNode * forall;
39
40        struct Basic_t {
41                std::list< DeclarationNode::BasicType > typeSpec;
42                std::list< DeclarationNode::Modifier > modifiers;
43        };
44
45        struct Aggregate_t {
46                DeclarationNode::Aggregate kind;
47                std::string name;
48                DeclarationNode * params;
49                ExpressionNode  * actuals;                                              // holds actual parameters later applied to AggInst
50                DeclarationNode * fields;
51                bool body;
52        };
53
54        struct AggInst_t {
55                TypeData * aggregate;
56                ExpressionNode * params;
57        };
58
59        struct Array_t {
60                ExpressionNode * dimension;
61                bool isVarLen;
62                bool isStatic;
63        };
64
65        struct Enumeration_t {
66                std::string name;
67                DeclarationNode * constants;
68        };
69
70        struct Function_t {
71                DeclarationNode * params;
72                DeclarationNode * idList;                                               // old-style
73                DeclarationNode * oldDeclList;
74                StatementNode * body;
75                bool hasBody;
76                bool newStyle;
77        };
78
79        struct Symbolic_t {
80                std::string name;
81                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
82                DeclarationNode * params;
83                ExpressionNode * actuals;
84                DeclarationNode * assertions;
85        };
86
87        struct Variable_t {
88                DeclarationNode::TypeClass tyClass;
89                std::string name;
90                DeclarationNode * assertions;
91        };
92
93        struct Tuple_t {
94                DeclarationNode * members;
95        };
96 
97        struct Typeof_t {
98                ExpressionNode * expr;
99        };
100
101        struct Builtin_t {
102                DeclarationNode::BuiltinType type;
103        };
104
105        struct Attr_t {
106                std::string name;
107                ExpressionNode * expr;
108                DeclarationNode * type;
109        };
110
111        union {
112                Basic_t * basic;
113                Aggregate_t * aggregate;
114                AggInst_t * aggInst;
115                Array_t * array;
116                Enumeration_t * enumeration;
117                Function_t * function;
118                Symbolic_t * symbolic;
119                Variable_t * variable;
120                Tuple_t * tuple;
121                Typeof_t * typeexpr;
122                Attr_t * attr;
123                Builtin_t * builtin;
124        };
125
126        TypeData * extractAggregate( bool toplevel = true ) const;
127        // helper function for DeclNodeImpl::build
128        Declaration * buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Type linkage, Initializer * init = 0 ) const;
129        // helper functions for build()
130        Type::Qualifiers buildQualifiers() const;
131        Type * buildBasicType() const;
132        PointerType * buildPointer() const;
133        ArrayType * buildArray() const;
134        AggregateDecl * buildAggregate() const;
135        ReferenceToType * buildAggInst() const;
136        NamedTypeDecl * buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const;
137        TypeDecl* buildVariable() const;
138        EnumDecl* buildEnum() const;
139        TypeInstType * buildSymbolicInst() const;
140        TupleType * buildTuple() const;
141        TypeofType * buildTypeof() const;
142        AttrType * buildAttr() const;
143};
144
145#endif // TYPEDATA_H
146
147// Local Variables: //
148// tab-width: 4 //
149// mode: c++ //
150// compile-command: "make install" //
151// End: //
Note: See TracBrowser for help on using the repository browser.