/
cppDeclaration.h
232 lines (210 loc) · 6.8 KB
/
cppDeclaration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file cppDeclaration.h
* @author drose
* @date 1999-10-19
*/
#ifndef CPPDECLARATION_H
#define CPPDECLARATION_H
#include "dtoolbase.h"
#include "cppVisibility.h"
#include "cppFile.h"
#include <map>
#include <set>
class CPPCommentBlock;
class CPPInstance;
class CPPTemplateParameterList;
class CPPTypedefType;
class CPPTypeDeclaration;
class CPPExpression;
class CPPType;
class CPPNamespace;
class CPPUsing;
class CPPSimpleType;
class CPPPointerType;
class CPPReferenceType;
class CPPArrayType;
class CPPConstType;
class CPPFunctionType;
class CPPFunctionGroup;
class CPPExtensionType;
class CPPStructType;
class CPPEnumType;
class CPPTypeProxy;
class CPPMakeProperty;
class CPPMakeSeq;
class CPPClosureType;
class CPPClassTemplateParameter;
class CPPTBDType;
class CPPScope;
class CPPTemplateScope;
class CPPPreprocessor;
/**
*
*/
class CPPDeclaration {
public:
enum SubType {
// Subtypes of CPPDeclaration
ST_instance,
ST_type_declaration,
ST_expression,
ST_type,
ST_namespace,
ST_using,
ST_make_property,
ST_make_seq,
// Subtypes of CPPType
ST_simple,
ST_pointer,
ST_reference,
ST_array,
ST_const,
ST_function,
ST_function_group,
ST_extension,
ST_struct,
ST_enum,
ST_class_template_parameter,
ST_tbd,
ST_type_proxy,
ST_typedef,
ST_closure,
};
CPPDeclaration(const CPPFile &file);
CPPDeclaration(const CPPDeclaration ©);
virtual ~CPPDeclaration() {};
CPPDeclaration &operator = (const CPPDeclaration ©);
bool operator == (const CPPDeclaration &other) const;
bool operator != (const CPPDeclaration &other) const;
bool operator < (const CPPDeclaration &other) const;
bool is_template() const;
CPPTemplateScope *get_template_scope() const;
virtual bool is_fully_specified() const;
virtual CPPDeclaration *
instantiate(const CPPTemplateParameterList *actual_params,
CPPScope *current_scope, CPPScope *global_scope,
CPPPreprocessor *error_sink = nullptr) const;
typedef std::map<CPPDeclaration *, CPPDeclaration *> SubstDecl;
virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
CPPScope *current_scope,
CPPScope *global_scope);
typedef std::set<CPPDeclaration *> Instantiations;
Instantiations _instantiations;
virtual void output(std::ostream &out, int indent_level, CPPScope *scope,
bool complete) const=0;
virtual SubType get_subtype() const=0;
virtual CPPInstance *as_instance();
virtual CPPClassTemplateParameter *as_class_template_parameter();
virtual CPPTypedefType *as_typedef_type();
virtual CPPTypeDeclaration *as_type_declaration();
virtual CPPExpression *as_expression();
virtual CPPType *as_type();
virtual CPPNamespace *as_namespace();
virtual CPPUsing *as_using();
virtual CPPSimpleType *as_simple_type();
virtual CPPPointerType *as_pointer_type();
virtual CPPReferenceType *as_reference_type();
virtual CPPArrayType *as_array_type();
virtual CPPConstType *as_const_type();
virtual CPPFunctionType *as_function_type();
virtual CPPFunctionGroup *as_function_group();
virtual CPPExtensionType *as_extension_type();
virtual CPPStructType *as_struct_type();
virtual CPPEnumType *as_enum_type();
virtual CPPTBDType *as_tbd_type();
virtual CPPTypeProxy *as_type_proxy();
virtual CPPMakeProperty *as_make_property();
virtual CPPMakeSeq *as_make_seq();
virtual CPPClosureType *as_closure_type();
inline const CPPInstance *as_instance() const {
return ((CPPDeclaration *)this)->as_instance();
}
inline const CPPClassTemplateParameter *as_class_template_parameter() const {
return ((CPPDeclaration *)this)->as_class_template_parameter();
}
inline const CPPTypedefType *as_typedef_type() const {
return ((CPPDeclaration *)this)->as_typedef_type();
}
inline const CPPTypeDeclaration *as_type_declaration() const {
return ((CPPDeclaration *)this)->as_type_declaration();
}
inline const CPPExpression *as_expression() const {
return ((CPPDeclaration *)this)->as_expression();
}
inline const CPPType *as_type() const {
return ((CPPDeclaration *)this)->as_type();
}
inline const CPPNamespace *as_namespace() const {
return ((CPPDeclaration *)this)->as_namespace();
}
inline const CPPUsing *as_using() const {
return ((CPPDeclaration *)this)->as_using();
}
inline const CPPSimpleType *as_simple_type() const {
return ((CPPDeclaration *)this)->as_simple_type();
}
inline const CPPPointerType *as_pointer_type() const {
return ((CPPDeclaration *)this)->as_pointer_type();
}
inline const CPPReferenceType *as_reference_type() const {
return ((CPPDeclaration *)this)->as_reference_type();
}
inline const CPPArrayType *as_array_type() const {
return ((CPPDeclaration *)this)->as_array_type();
}
inline const CPPConstType *as_const_type() const {
return ((CPPDeclaration *)this)->as_const_type();
}
inline const CPPFunctionType *as_function_type() const {
return ((CPPDeclaration *)this)->as_function_type();
}
inline const CPPFunctionGroup *as_function_group() const {
return ((CPPDeclaration *)this)->as_function_group();
}
inline const CPPExtensionType *as_extension_type() const {
return ((CPPDeclaration *)this)->as_extension_type();
}
inline const CPPStructType *as_struct_type() const {
return ((CPPDeclaration *)this)->as_struct_type();
}
inline const CPPEnumType *as_enum_type() const {
return ((CPPDeclaration *)this)->as_enum_type();
}
inline const CPPTBDType *as_tbd_type() const {
return ((CPPDeclaration *)this)->as_tbd_type();
}
inline const CPPTypeProxy *as_type_proxy() const {
return ((CPPDeclaration *)this)->as_type_proxy();
}
inline const CPPMakeProperty *as_make_property() const {
return ((CPPDeclaration *)this)->as_make_property();
}
inline const CPPMakeSeq *as_make_seq() const {
return ((CPPDeclaration *)this)->as_make_seq();
}
inline const CPPClosureType *as_closure_type() const {
return ((CPPDeclaration *)this)->as_closure_type();
}
CPPVisibility _vis;
CPPTemplateScope *_template_scope;
CPPFile _file;
CPPCommentBlock *_leading_comment;
protected:
virtual bool is_equal(const CPPDeclaration *other) const;
virtual bool is_less(const CPPDeclaration *other) const;
};
inline std::ostream &
operator << (std::ostream &out, const CPPDeclaration &decl) {
decl.output(out, 0, nullptr, false);
return out;
}
std::ostream &
operator << (std::ostream &out, const CPPDeclaration::SubstDecl &decl);
#endif