source: translator/Parser.old/TypeData.h @ 3c70d38

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 3c70d38 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#ifndef TYPEDATA_H
2#define TYPEDATA_H
3
4#include <list>
5#include "ParseNode.h"
6#include "SynTree/SynTree.h"
7#include "SynTree/Type.h"
8#include "SynTree/Declaration.h"
9#include "SemanticError.h"
10#include "LinkageSpec.h"
11
12struct TypeData
13{
14  enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst,
15              Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof } kind;
16
17  TypeData( Kind k = Unknown );
18  ~TypeData();
19  void print( std::ostream &, int indent = 0 ) const;
20  TypeData *clone() const;
21
22  Type *build() const;
23  FunctionType *buildFunction() const;
24
25  TypeData *base;
26  std::list< DeclarationNode::Qualifier > qualifiers;
27  DeclarationNode *forall;
28
29  struct Basic_t {
30    std::list< DeclarationNode::BasicType > typeSpec;
31    std::list< DeclarationNode::Modifier > modifiers;
32  };
33
34  struct Aggregate_t {
35    DeclarationNode::TyCon kind;
36    std::string name;
37    DeclarationNode *params;
38    ExpressionNode *actuals;    // holds actual parameters that will later be applied to AggInst
39    DeclarationNode *members;
40  };
41
42  struct AggInst_t {
43    TypeData *aggregate;
44    ExpressionNode *params;
45  };
46
47  struct Array_t {
48    ExpressionNode *dimension;
49    bool isVarLen;
50    bool isStatic;
51  };
52
53  struct Enumeration_t {
54    std::string name;
55    DeclarationNode *constants;
56  };
57
58  struct Function_t {
59    DeclarationNode *params;
60    DeclarationNode *idList; // old-style
61    DeclarationNode *oldDeclList;
62    StatementNode *body;
63    bool hasBody;
64  };
65
66  struct Symbolic_t {
67    std::string name;
68    bool isTypedef;
69    DeclarationNode *params;
70    ExpressionNode *actuals;
71    DeclarationNode *assertions;
72  };
73
74  struct Variable_t {
75    DeclarationNode::TypeClass tyClass;
76    std::string name;
77    DeclarationNode *assertions;
78  };
79
80  struct Tuple_t {
81    DeclarationNode *members;
82  };
83 
84  struct Typeof_t {
85    ExpressionNode *expr;
86  };
87
88  union {
89    Basic_t *basic;
90    Aggregate_t *aggregate;
91    AggInst_t *aggInst;
92    Array_t *array;
93    Enumeration_t *enumeration;
94    Function_t *function;
95    Symbolic_t *symbolic;
96    Variable_t *variable;
97    Tuple_t *tuple;
98    Typeof_t *typeexpr;
99  };
100
101  TypeData *extractAggregate( bool toplevel = true ) const;
102  /* helper function for DeclNodeImpl::build */
103  Declaration * buildDecl( std::string name, Declaration::StorageClass sc, Expression *bitfieldWidth, bool isInline, LinkageSpec::Type linkage, Initializer *init = 0 ) const;
104  /* helper functions for build() */
105  Type::Qualifiers buildQualifiers() const;
106  Type *buildBasicType() const;
107  PointerType * buildPointer() const;
108  ArrayType * buildArray() const;
109  AggregateDecl * buildAggregate() const;
110  ReferenceToType * buildAggInst() const;
111  NamedTypeDecl * buildSymbolic( const std::string &name, Declaration::StorageClass sc ) const;
112  TypeDecl* buildVariable() const;
113  EnumDecl* buildEnum() const;
114  TypeInstType * buildSymbolicInst() const;
115  TupleType * buildTuple() const;
116  TypeofType * buildTypeof() const;
117};
118
119#endif /* #ifndef TYPEDATA_H */
Note: See TracBrowser for help on using the repository browser.