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 : Wed Mar 8 22:28:33 2017
|
---|
13 | // Update Count : 174
|
---|
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 |
|
---|
24 | struct TypeData {
|
---|
25 | enum Kind { Basic, Pointer, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
|
---|
26 | SymbolicInst, Tuple, Typeof, Builtin, Unknown };
|
---|
27 |
|
---|
28 | struct Aggregate_t {
|
---|
29 | DeclarationNode::Aggregate kind;
|
---|
30 | const std::string * name;
|
---|
31 | DeclarationNode * params;
|
---|
32 | ExpressionNode * actuals; // holds actual parameters later applied to AggInst
|
---|
33 | DeclarationNode * fields;
|
---|
34 | bool body;
|
---|
35 | };
|
---|
36 |
|
---|
37 | struct AggInst_t {
|
---|
38 | TypeData * aggregate;
|
---|
39 | ExpressionNode * params;
|
---|
40 | bool hoistType;
|
---|
41 | };
|
---|
42 |
|
---|
43 | struct Array_t {
|
---|
44 | ExpressionNode * dimension;
|
---|
45 | bool isVarLen;
|
---|
46 | bool isStatic;
|
---|
47 | };
|
---|
48 |
|
---|
49 | struct Enumeration_t {
|
---|
50 | const std::string * name;
|
---|
51 | DeclarationNode * constants;
|
---|
52 | bool body;
|
---|
53 | };
|
---|
54 |
|
---|
55 | struct Function_t {
|
---|
56 | mutable DeclarationNode * params; // mutables modified in buildKRFunction
|
---|
57 | mutable DeclarationNode * idList; // old-style
|
---|
58 | mutable DeclarationNode * oldDeclList;
|
---|
59 | StatementNode * body;
|
---|
60 | bool newStyle;
|
---|
61 | };
|
---|
62 |
|
---|
63 | struct Symbolic_t {
|
---|
64 | const std::string * name;
|
---|
65 | bool isTypedef; // false => TYPEGENname, true => TYPEDEFname
|
---|
66 | DeclarationNode * params;
|
---|
67 | ExpressionNode * actuals;
|
---|
68 | DeclarationNode * assertions;
|
---|
69 | };
|
---|
70 |
|
---|
71 | Kind kind;
|
---|
72 | TypeData * base;
|
---|
73 | DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
|
---|
74 | DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
|
---|
75 | DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
|
---|
76 | DeclarationNode::Length length = DeclarationNode::NoLength;
|
---|
77 | DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
|
---|
78 |
|
---|
79 | typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers;
|
---|
80 | TypeQualifiers typeQualifiers;
|
---|
81 | DeclarationNode * forall;
|
---|
82 |
|
---|
83 | // Basic_t basic;
|
---|
84 | Aggregate_t aggregate;
|
---|
85 | AggInst_t aggInst;
|
---|
86 | Array_t array;
|
---|
87 | Enumeration_t enumeration;
|
---|
88 | // Variable_t variable;
|
---|
89 | Function_t function;
|
---|
90 | Symbolic_t symbolic;
|
---|
91 | DeclarationNode * tuple;
|
---|
92 | ExpressionNode * typeexpr;
|
---|
93 |
|
---|
94 | TypeData( Kind k = Unknown );
|
---|
95 | ~TypeData();
|
---|
96 | void print( std::ostream &, int indent = 0 ) const;
|
---|
97 | TypeData * clone() const;
|
---|
98 | };
|
---|
99 |
|
---|
100 | Type * typebuild( const TypeData * );
|
---|
101 | TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
|
---|
102 | Type::Qualifiers buildQualifiers( const TypeData * td );
|
---|
103 | Type * buildBasicType( const TypeData * );
|
---|
104 | PointerType * buildPointer( const TypeData * );
|
---|
105 | ArrayType * buildArray( const TypeData * );
|
---|
106 | AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > );
|
---|
107 | ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes );
|
---|
108 | ReferenceToType * buildAggInst( const TypeData * );
|
---|
109 | TypeDecl * buildVariable( const TypeData * );
|
---|
110 | EnumDecl * buildEnum( const TypeData *, std::list< Attribute * > );
|
---|
111 | TypeInstType * buildSymbolicInst( const TypeData * );
|
---|
112 | TupleType * buildTuple( const TypeData * );
|
---|
113 | TypeofType * buildTypeof( const TypeData * );
|
---|
114 | Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
|
---|
115 | FunctionType * buildFunction( const TypeData * );
|
---|
116 | void buildKRFunction( const TypeData::Function_t & function );
|
---|
117 |
|
---|
118 | #endif // TYPEDATA_H
|
---|
119 |
|
---|
120 | // Local Variables: //
|
---|
121 | // tab-width: 4 //
|
---|
122 | // mode: c++ //
|
---|
123 | // compile-command: "make install" //
|
---|
124 | // End: //
|
---|