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