source: src/Parser/TypeData.h @ cb2e8ce

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 cb2e8ce was 90c3b1c, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

compile CFA with C++11, further update refrat with lstlisting macros, support varags, enumeration initialization, add implicit separators to output streams, update example programs that print

  • 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
[90c3b1c]12// Last Modified On : Fri Feb 26 14:21:38 2016
13// Update Count     : 19
[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;
[b87a5ed]51        };
52
53        struct AggInst_t {
[7ee14bb7]54                TypeData * aggregate;
55                ExpressionNode * params;
[b87a5ed]56        };
57
58        struct Array_t {
[7ee14bb7]59                ExpressionNode * dimension;
[b87a5ed]60                bool isVarLen;
61                bool isStatic;
62        };
63
64        struct Enumeration_t {
65                std::string name;
[7ee14bb7]66                DeclarationNode * constants;
[b87a5ed]67        };
68
69        struct Function_t {
[7ee14bb7]70                DeclarationNode * params;
71                DeclarationNode * idList;                                               // old-style
72                DeclarationNode * oldDeclList;
73                StatementNode * body;
[b87a5ed]74                bool hasBody;
75                bool newStyle;
76        };
77
78        struct Symbolic_t {
79                std::string name;
[721f17a]80                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
[7ee14bb7]81                DeclarationNode * params;
82                ExpressionNode * actuals;
83                DeclarationNode * assertions;
[b87a5ed]84        };
85
86        struct Variable_t {
87                DeclarationNode::TypeClass tyClass;
88                std::string name;
[7ee14bb7]89                DeclarationNode * assertions;
[b87a5ed]90        };
91
92        struct Tuple_t {
[7ee14bb7]93                DeclarationNode * members;
[b87a5ed]94        };
[51b7345]95 
[b87a5ed]96        struct Typeof_t {
[7ee14bb7]97                ExpressionNode * expr;
[b87a5ed]98        };
99
[90c3b1c]100        struct Builtin_t {
101                DeclarationNode::BuiltinType type;
102        };
103
[b87a5ed]104        struct Attr_t {
105                std::string name;
[7ee14bb7]106                ExpressionNode * expr;
107                DeclarationNode * type;
[b87a5ed]108        };
109
110        union {
[7ee14bb7]111                Basic_t * basic;
112                Aggregate_t * aggregate;
113                AggInst_t * aggInst;
114                Array_t * array;
115                Enumeration_t * enumeration;
116                Function_t * function;
117                Symbolic_t * symbolic;
118                Variable_t * variable;
119                Tuple_t * tuple;
120                Typeof_t * typeexpr;
121                Attr_t * attr;
[90c3b1c]122                Builtin_t * builtin;
[b87a5ed]123        };
124
[7ee14bb7]125        TypeData * extractAggregate( bool toplevel = true ) const;
[b87a5ed]126        // helper function for DeclNodeImpl::build
[7ee14bb7]127        Declaration * buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Type linkage, Initializer * init = 0 ) const;
[b87a5ed]128        // helper functions for build()
129        Type::Qualifiers buildQualifiers() const;
[de62360d]130        Type * buildBasicType() const;
[b87a5ed]131        PointerType * buildPointer() const;
132        ArrayType * buildArray() const;
133        AggregateDecl * buildAggregate() const;
134        ReferenceToType * buildAggInst() const;
[68cd1ce]135        NamedTypeDecl * buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const;
[b87a5ed]136        TypeDecl* buildVariable() const;
137        EnumDecl* buildEnum() const;
138        TypeInstType * buildSymbolicInst() const;
139        TupleType * buildTuple() const;
140        TypeofType * buildTypeof() const;
141        AttrType * buildAttr() const;
[51b7345]142};
143
[c8ffe20b]144#endif // TYPEDATA_H
[b87a5ed]145
146// Local Variables: //
147// tab-width: 4 //
148// mode: c++ //
149// compile-command: "make install" //
150// End: //
Note: See TracBrowser for help on using the repository browser.