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