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
RevLine 
[b87a5ed]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
[e82aa9df]12// Last Modified On : Mon Aug 15 14:28:32 2016
13// Update Count     : 21
[b87a5ed]14//
15
[51b7345]16#ifndef TYPEDATA_H
17#define TYPEDATA_H
18
19#include <list>
[bdd516a]20
[51b7345]21#include "ParseNode.h"
22#include "SynTree/Type.h"
23
[c8ffe20b]24struct TypeData {
[b87a5ed]25        enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst,
[90c3b1c]26                                Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr } kind;
[b87a5ed]27
28        TypeData( Kind k = Unknown );
29        ~TypeData();
30        void print( std::ostream &, int indent = 0 ) const;
[7ee14bb7]31        TypeData * clone() const;
[b87a5ed]32
[7ee14bb7]33        Type * build() const;
34        FunctionType * buildFunction() const;
[b87a5ed]35
[7ee14bb7]36        TypeData * base;
[b87a5ed]37        std::list< DeclarationNode::Qualifier > qualifiers;
[7ee14bb7]38        DeclarationNode * forall;
[b87a5ed]39
40        struct Basic_t {
41                std::list< DeclarationNode::BasicType > typeSpec;
42                std::list< DeclarationNode::Modifier > modifiers;
43        };
44
45        struct Aggregate_t {
[68cd1ce]46                DeclarationNode::Aggregate kind;
[b87a5ed]47                std::string name;
[7ee14bb7]48                DeclarationNode * params;
49                ExpressionNode  * actuals;                                              // holds actual parameters later applied to AggInst
50                DeclarationNode * fields;
[5d125e4]51                bool body;
[b87a5ed]52        };
53
54        struct AggInst_t {
[7ee14bb7]55                TypeData * aggregate;
56                ExpressionNode * params;
[b87a5ed]57        };
58
59        struct Array_t {
[7ee14bb7]60                ExpressionNode * dimension;
[b87a5ed]61                bool isVarLen;
62                bool isStatic;
63        };
64
65        struct Enumeration_t {
66                std::string name;
[7ee14bb7]67                DeclarationNode * constants;
[b87a5ed]68        };
69
70        struct Function_t {
[7ee14bb7]71                DeclarationNode * params;
72                DeclarationNode * idList;                                               // old-style
73                DeclarationNode * oldDeclList;
74                StatementNode * body;
[b87a5ed]75                bool hasBody;
76                bool newStyle;
77        };
78
79        struct Symbolic_t {
80                std::string name;
[721f17a]81                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
[7ee14bb7]82                DeclarationNode * params;
83                ExpressionNode * actuals;
84                DeclarationNode * assertions;
[b87a5ed]85        };
86
87        struct Variable_t {
88                DeclarationNode::TypeClass tyClass;
89                std::string name;
[7ee14bb7]90                DeclarationNode * assertions;
[b87a5ed]91        };
92
93        struct Tuple_t {
[7ee14bb7]94                DeclarationNode * members;
[b87a5ed]95        };
[51b7345]96 
[b87a5ed]97        struct Typeof_t {
[7ee14bb7]98                ExpressionNode * expr;
[b87a5ed]99        };
100
[90c3b1c]101        struct Builtin_t {
102                DeclarationNode::BuiltinType type;
103        };
104
[b87a5ed]105        struct Attr_t {
106                std::string name;
[7ee14bb7]107                ExpressionNode * expr;
108                DeclarationNode * type;
[b87a5ed]109        };
110
111        union {
[7ee14bb7]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;
[90c3b1c]123                Builtin_t * builtin;
[b87a5ed]124        };
125
[7ee14bb7]126        TypeData * extractAggregate( bool toplevel = true ) const;
[b87a5ed]127        // helper function for DeclNodeImpl::build
[7ee14bb7]128        Declaration * buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Type linkage, Initializer * init = 0 ) const;
[b87a5ed]129        // helper functions for build()
130        Type::Qualifiers buildQualifiers() const;
[de62360d]131        Type * buildBasicType() const;
[b87a5ed]132        PointerType * buildPointer() const;
133        ArrayType * buildArray() const;
134        AggregateDecl * buildAggregate() const;
135        ReferenceToType * buildAggInst() const;
[68cd1ce]136        NamedTypeDecl * buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const;
[b87a5ed]137        TypeDecl* buildVariable() const;
138        EnumDecl* buildEnum() const;
139        TypeInstType * buildSymbolicInst() const;
140        TupleType * buildTuple() const;
141        TypeofType * buildTypeof() const;
142        AttrType * buildAttr() const;
[51b7345]143};
144
[c8ffe20b]145#endif // TYPEDATA_H
[b87a5ed]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.