source: src/Parser/TypeData.h@ 1e8b02f5

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 1e8b02f5 was c1c1112, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

fix segment fault when printing syntax error, 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 : Thu Aug 25 17:34:06 2016
13// Update Count : 26
14//
15
16#ifndef TYPEDATA_H
17#define TYPEDATA_H
18
19#include <bitset>
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 typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers;
38 Qualifiers qualifiers;
39 DeclarationNode * forall;
40
41 struct Basic_t {
42 std::list< DeclarationNode::BasicType > typeSpec;
43 std::list< DeclarationNode::Modifier > modifiers;
44 };
45
46 struct Aggregate_t {
47 DeclarationNode::Aggregate kind;
48 std::string name;
49 DeclarationNode * params;
50 ExpressionNode * actuals; // holds actual parameters later applied to AggInst
51 DeclarationNode * fields;
52 bool body;
53 };
54
55 struct AggInst_t {
56 TypeData * aggregate;
57 ExpressionNode * params;
58 };
59
60 struct Array_t {
61 ExpressionNode * dimension;
62 bool isVarLen;
63 bool isStatic;
64 };
65
66 struct Enumeration_t {
67 std::string name;
68 DeclarationNode * constants;
69 };
70
71 struct Function_t {
72 DeclarationNode * params;
73 DeclarationNode * idList; // old-style
74 DeclarationNode * oldDeclList;
75 StatementNode * body;
76 bool hasBody;
77 bool newStyle;
78 };
79
80 struct Symbolic_t {
81 std::string name;
82 bool isTypedef; // false => TYPEGENname, true => TYPEDEFname
83 DeclarationNode * params;
84 ExpressionNode * actuals;
85 DeclarationNode * assertions;
86 };
87
88 struct Variable_t {
89 DeclarationNode::TypeClass tyClass;
90 std::string name;
91 DeclarationNode * assertions;
92 };
93
94 struct Tuple_t {
95 DeclarationNode * members;
96 };
97
98 struct Typeof_t {
99 ExpressionNode * expr;
100 };
101
102 struct Builtin_t {
103 DeclarationNode::BuiltinType type;
104 };
105
106 struct Attr_t {
107 std::string name;
108 ExpressionNode * expr;
109 DeclarationNode * type;
110 };
111
112 union {
113 Basic_t * basic;
114 Aggregate_t * aggregate;
115 AggInst_t * aggInst;
116 Array_t * array;
117 Enumeration_t * enumeration;
118 Function_t * function;
119 Symbolic_t * symbolic;
120 Variable_t * variable;
121 Tuple_t * tuple;
122 Typeof_t * typeexpr;
123 Attr_t * attr;
124 Builtin_t * builtin;
125 };
126
127 TypeData * extractAggregate( bool toplevel = true ) const;
128 // helper function for DeclNodeImpl::build
129 Declaration * buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init = 0 ) const;
130 // helper functions for build()
131 Type::Qualifiers buildQualifiers() const;
132 Type * buildBasicType() const;
133 PointerType * buildPointer() const;
134 ArrayType * buildArray() const;
135 AggregateDecl * buildAggregate() const;
136 ReferenceToType * buildAggInst() const;
137 NamedTypeDecl * buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const;
138 TypeDecl* buildVariable() const;
139 EnumDecl* buildEnum() const;
140 TypeInstType * buildSymbolicInst() const;
141 TupleType * buildTuple() const;
142 TypeofType * buildTypeof() const;
143 AttrType * buildAttr() const;
144};
145
146#endif // TYPEDATA_H
147
148// Local Variables: //
149// tab-width: 4 //
150// mode: c++ //
151// compile-command: "make install" //
152// End: //
Note: See TracBrowser for help on using the repository browser.