1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2001-2004 Roberto Raggi
|
---|
4 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
5 | ** All rights reserved.
|
---|
6 | ** Contact: Nokia Corporation ([email protected])
|
---|
7 | **
|
---|
8 | ** This file is part of the qt3to4 porting application of the Qt Toolkit.
|
---|
9 | **
|
---|
10 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
11 | ** Commercial Usage
|
---|
12 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
13 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
14 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
15 | ** a written agreement between you and Nokia.
|
---|
16 | **
|
---|
17 | ** GNU Lesser General Public License Usage
|
---|
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
19 | ** General Public License version 2.1 as published by the Free Software
|
---|
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
21 | ** packaging of this file. Please review the following information to
|
---|
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
24 | **
|
---|
25 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
26 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
28 | **
|
---|
29 | ** GNU General Public License Usage
|
---|
30 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
31 | ** General Public License version 3.0 as published by the Free Software
|
---|
32 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
33 | ** packaging of this file. Please review the following information to
|
---|
34 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
35 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
36 | **
|
---|
37 | ** If you have questions regarding the use of this file, please contact
|
---|
38 | ** Nokia at [email protected].
|
---|
39 | ** $QT_END_LICENSE$
|
---|
40 | **
|
---|
41 | ****************************************************************************/
|
---|
42 |
|
---|
43 | #ifndef AST_H
|
---|
44 | #define AST_H
|
---|
45 |
|
---|
46 | #include "smallobject.h"
|
---|
47 | #include "list.h"
|
---|
48 |
|
---|
49 | QT_BEGIN_NAMESPACE
|
---|
50 |
|
---|
51 | class AST;
|
---|
52 | class NameAST;
|
---|
53 | class TypeIdAST;
|
---|
54 | class TypeSpecifierAST;
|
---|
55 | class DeclaratorAST;
|
---|
56 |
|
---|
57 | class Symbol;
|
---|
58 | class Scope;
|
---|
59 |
|
---|
60 | enum NodeType
|
---|
61 | {
|
---|
62 | NodeType_Generic = 0,
|
---|
63 |
|
---|
64 | NodeType_TemplateArgumentList = 1000,
|
---|
65 | NodeType_ClassOrNamespaceName,
|
---|
66 | NodeType_Name,
|
---|
67 | NodeType_Declaration,
|
---|
68 | NodeType_TypeSpecifier,
|
---|
69 | NodeType_BaseSpecifier,
|
---|
70 | NodeType_BaseClause,
|
---|
71 | NodeType_ClassSpecifier,
|
---|
72 | NodeType_Enumerator,
|
---|
73 | NodeType_EnumSpecifier,
|
---|
74 | NodeType_ElaboratedTypeSpecifier,
|
---|
75 | NodeType_LinkageBody,
|
---|
76 | NodeType_LinkageSpecification,
|
---|
77 | NodeType_Namespace,
|
---|
78 | NodeType_NamespaceAlias,
|
---|
79 | NodeType_Using,
|
---|
80 | NodeType_UsingDirective,
|
---|
81 | NodeType_InitDeclaratorList,
|
---|
82 | NodeType_Typedef,
|
---|
83 | NodeType_Declarator,
|
---|
84 | NodeType_InitDeclarator,
|
---|
85 | NodeType_TemplateDeclaration,
|
---|
86 | NodeType_SimpleDeclaration,
|
---|
87 | NodeType_Statement,
|
---|
88 | NodeType_StatementList,
|
---|
89 | NodeType_IfStatement,
|
---|
90 | NodeType_WhileStatement,
|
---|
91 | NodeType_DoStatement,
|
---|
92 | NodeType_ForStatement,
|
---|
93 | NodeType_SwitchStatement,
|
---|
94 | NodeType_DeclarationStatement,
|
---|
95 | NodeType_LabeledStatement,
|
---|
96 | NodeType_ReturnStatement,
|
---|
97 | NodeType_TranslationUnit,
|
---|
98 | NodeType_FunctionDefinition,
|
---|
99 | NodeType_ExpressionStatement,
|
---|
100 | NodeType_ParameterDeclaration,
|
---|
101 | NodeType_ParameterDeclarationList,
|
---|
102 | NodeType_ParameterDeclarationClause,
|
---|
103 | NodeType_AccessDeclaration,
|
---|
104 | NodeType_TypeParameter,
|
---|
105 | NodeType_TemplateParameter,
|
---|
106 | NodeType_TemplateParameterList,
|
---|
107 | NodeType_Condition,
|
---|
108 |
|
---|
109 | NodeType_TypeId,
|
---|
110 |
|
---|
111 | NodeType_Expression = 2000,
|
---|
112 | NodeType_BinaryExpression,
|
---|
113 | NodeType_PrimaryExpression,
|
---|
114 |
|
---|
115 | //
|
---|
116 | // postfix expression
|
---|
117 | //
|
---|
118 | NodeType_PostfixExpression,
|
---|
119 | NodeType_Subscripting,
|
---|
120 | NodeType_FunctionCall,
|
---|
121 | NodeType_ExplicitTypeConversion,
|
---|
122 | NodeType_PseudoConstructorCall,
|
---|
123 | NodeType_ClassMemberAccess,
|
---|
124 | NodeType_IncrDecr,
|
---|
125 | NodeType_CppCastExpression,
|
---|
126 | NodeType_TypeIdentification,
|
---|
127 |
|
---|
128 | NodeType_UnaryExpression,
|
---|
129 | NodeType_NewExpression,
|
---|
130 | NodeType_NewTypeId,
|
---|
131 | NodeType_NewDeclarator,
|
---|
132 | NodeType_NewInitializer,
|
---|
133 | NodeType_DeleteExpression,
|
---|
134 | NodeType_CastExpression,
|
---|
135 | NodeType_ConditionalExpression,
|
---|
136 | NodeType_ThrowExpression,
|
---|
137 |
|
---|
138 | NodeType_Custom = 3000
|
---|
139 | };
|
---|
140 |
|
---|
141 |
|
---|
142 | template <typename T>
|
---|
143 | inline int length(List<T> *e)
|
---|
144 | {
|
---|
145 | return e ? e->size() : 0;
|
---|
146 | }
|
---|
147 |
|
---|
148 | class AST
|
---|
149 | {
|
---|
150 | public:
|
---|
151 | enum { Type=NodeType_Generic };
|
---|
152 |
|
---|
153 | pool *_pool;
|
---|
154 |
|
---|
155 | static int N;
|
---|
156 |
|
---|
157 | public:
|
---|
158 | AST(int startToken=0, int count=1);
|
---|
159 | virtual ~AST() { --N; }
|
---|
160 |
|
---|
161 | inline int startToken() const
|
---|
162 | { return m_startToken; }
|
---|
163 |
|
---|
164 | inline int endToken() const
|
---|
165 | { return m_endToken; }
|
---|
166 |
|
---|
167 | inline void setPosition(int startToken, int endToken)
|
---|
168 | {
|
---|
169 | m_startToken = startToken;
|
---|
170 | m_endToken = endToken;
|
---|
171 | }
|
---|
172 |
|
---|
173 | inline int nodeType() const
|
---|
174 | { return m_nodeType; }
|
---|
175 |
|
---|
176 | inline void setNodeType(int nodeType)
|
---|
177 | { m_nodeType = nodeType; }
|
---|
178 |
|
---|
179 | inline AST *parent() const
|
---|
180 | { return m_parent; }
|
---|
181 |
|
---|
182 | void setParent(AST *parent);
|
---|
183 |
|
---|
184 | inline List<AST *> *children() const
|
---|
185 | { return m_children; }
|
---|
186 |
|
---|
187 | void appendChild(AST *child);
|
---|
188 | void removeChild(AST *child);
|
---|
189 |
|
---|
190 | // ### move
|
---|
191 | inline Scope *scope() const
|
---|
192 | {
|
---|
193 | if (m_scope)
|
---|
194 | return m_scope;
|
---|
195 |
|
---|
196 | return m_parent ? m_parent->scope() : 0;
|
---|
197 | }
|
---|
198 |
|
---|
199 | inline void setScope(Scope *scope)
|
---|
200 | { m_scope = scope; }
|
---|
201 |
|
---|
202 | private:
|
---|
203 | Scope *m_scope;
|
---|
204 | int m_nodeType;
|
---|
205 | int m_startToken;
|
---|
206 | int m_endToken;
|
---|
207 | AST *m_parent;
|
---|
208 | List<AST *> *m_children;
|
---|
209 |
|
---|
210 | private:
|
---|
211 | AST(const AST &source);
|
---|
212 | void operator = (const AST &source);
|
---|
213 | };
|
---|
214 |
|
---|
215 | class AbstractExpressionAST: public AST
|
---|
216 | {
|
---|
217 | public:
|
---|
218 | enum { Type = NodeType_Expression };
|
---|
219 |
|
---|
220 | AbstractExpressionAST();
|
---|
221 |
|
---|
222 | inline Symbol *symbol() const
|
---|
223 | { return m_symbol; }
|
---|
224 |
|
---|
225 | inline void setSymbol(Symbol *symbol)
|
---|
226 | { m_symbol = symbol; }
|
---|
227 |
|
---|
228 | private:
|
---|
229 | Symbol *m_symbol;
|
---|
230 | };
|
---|
231 |
|
---|
232 | // ### remove me
|
---|
233 | template <int kind, class Base = AbstractExpressionAST>
|
---|
234 | class ExpressionAST: public Base
|
---|
235 | {
|
---|
236 | public:
|
---|
237 | enum { Type = kind };
|
---|
238 |
|
---|
239 | public:
|
---|
240 | inline ExpressionAST() {}
|
---|
241 |
|
---|
242 | private:
|
---|
243 | ExpressionAST(const ExpressionAST &source);
|
---|
244 | void operator = (const ExpressionAST &source);
|
---|
245 | };
|
---|
246 |
|
---|
247 | class BinaryExpressionAST: public AbstractExpressionAST
|
---|
248 | {
|
---|
249 | public:
|
---|
250 | enum { Type = NodeType_BinaryExpression };
|
---|
251 |
|
---|
252 | public:
|
---|
253 | BinaryExpressionAST();
|
---|
254 |
|
---|
255 | inline AST *op() const
|
---|
256 | { return m_op; }
|
---|
257 |
|
---|
258 | inline AbstractExpressionAST *leftExpression() const
|
---|
259 | { return m_left; }
|
---|
260 |
|
---|
261 | inline AbstractExpressionAST *rightExpression() const
|
---|
262 | { return m_right; }
|
---|
263 |
|
---|
264 | void setOp(AST *op);
|
---|
265 | void setLeftExpression(AbstractExpressionAST *left);
|
---|
266 | void setRightExpression(AbstractExpressionAST *right);
|
---|
267 |
|
---|
268 | private:
|
---|
269 | AST *m_op;
|
---|
270 | AbstractExpressionAST *m_left;
|
---|
271 | AbstractExpressionAST *m_right;
|
---|
272 |
|
---|
273 | private:
|
---|
274 | BinaryExpressionAST(const BinaryExpressionAST &source);
|
---|
275 | void operator = (const BinaryExpressionAST &source);
|
---|
276 | };
|
---|
277 |
|
---|
278 | class ConditionalExpressionAST: public AbstractExpressionAST
|
---|
279 | {
|
---|
280 | public:
|
---|
281 | enum { Type = NodeType_ConditionalExpression };
|
---|
282 |
|
---|
283 | public:
|
---|
284 | ConditionalExpressionAST();
|
---|
285 |
|
---|
286 | inline AbstractExpressionAST *condition() const
|
---|
287 | { return m_condition; }
|
---|
288 |
|
---|
289 | inline AbstractExpressionAST *leftExpression() const
|
---|
290 | { return m_left; }
|
---|
291 |
|
---|
292 | inline AbstractExpressionAST *rightExpression() const
|
---|
293 | { return m_right; }
|
---|
294 |
|
---|
295 | void setCondition(AbstractExpressionAST *condition);
|
---|
296 | void setLeftExpression(AbstractExpressionAST *left);
|
---|
297 | void setRightExpression(AbstractExpressionAST *right);
|
---|
298 |
|
---|
299 | private:
|
---|
300 | AbstractExpressionAST *m_condition;
|
---|
301 | AbstractExpressionAST *m_left;
|
---|
302 | AbstractExpressionAST *m_right;
|
---|
303 |
|
---|
304 | private:
|
---|
305 | ConditionalExpressionAST(const ConditionalExpressionAST& source);
|
---|
306 | void operator = (const ConditionalExpressionAST &source);
|
---|
307 | };
|
---|
308 |
|
---|
309 |
|
---|
310 | //
|
---|
311 | // postfix expression
|
---|
312 | //
|
---|
313 |
|
---|
314 | class SubscriptingAST: public AbstractExpressionAST
|
---|
315 | {
|
---|
316 | public:
|
---|
317 | enum { Type = NodeType_Subscripting };
|
---|
318 |
|
---|
319 | public:
|
---|
320 | SubscriptingAST();
|
---|
321 |
|
---|
322 | inline AbstractExpressionAST *expression() const
|
---|
323 | { return m_expression; }
|
---|
324 |
|
---|
325 | inline AbstractExpressionAST *subscript() const
|
---|
326 | { return m_subscript; }
|
---|
327 |
|
---|
328 | void setExpression(AbstractExpressionAST *expression);
|
---|
329 | void setSubscript(AbstractExpressionAST *subscript);
|
---|
330 |
|
---|
331 | private:
|
---|
332 | AbstractExpressionAST *m_expression;
|
---|
333 | AbstractExpressionAST *m_subscript;
|
---|
334 |
|
---|
335 | private:
|
---|
336 | SubscriptingAST(const SubscriptingAST &source);
|
---|
337 | void operator = (const SubscriptingAST &source);
|
---|
338 | };
|
---|
339 |
|
---|
340 | class FunctionCallAST: public AbstractExpressionAST
|
---|
341 | {
|
---|
342 | public:
|
---|
343 | enum { Type = NodeType_FunctionCall };
|
---|
344 |
|
---|
345 | public:
|
---|
346 | FunctionCallAST();
|
---|
347 |
|
---|
348 | inline AbstractExpressionAST *expression() const
|
---|
349 | { return m_expression; }
|
---|
350 |
|
---|
351 | inline AbstractExpressionAST *arguments() const
|
---|
352 | { return m_arguments; }
|
---|
353 |
|
---|
354 | void setExpression(AbstractExpressionAST *expression);
|
---|
355 | void setArguments(AbstractExpressionAST *arguments);
|
---|
356 |
|
---|
357 | private:
|
---|
358 | AbstractExpressionAST *m_expression;
|
---|
359 | AbstractExpressionAST *m_arguments;
|
---|
360 |
|
---|
361 | private:
|
---|
362 | FunctionCallAST(const FunctionCallAST &source);
|
---|
363 | void operator = (const FunctionCallAST &source);
|
---|
364 | };
|
---|
365 |
|
---|
366 | class ExplicitTypeConversionAST: public AbstractExpressionAST
|
---|
367 | {
|
---|
368 | public:
|
---|
369 | enum { Type = NodeType_ExplicitTypeConversion };
|
---|
370 |
|
---|
371 | public:
|
---|
372 | ExplicitTypeConversionAST();
|
---|
373 |
|
---|
374 | private:
|
---|
375 | ExplicitTypeConversionAST(const ExplicitTypeConversionAST &source);
|
---|
376 | void operator = (const ExplicitTypeConversionAST &source);
|
---|
377 | };
|
---|
378 |
|
---|
379 | class PseudoDestructorCallAST: public AbstractExpressionAST
|
---|
380 | {
|
---|
381 | public:
|
---|
382 | enum { Type = NodeType_PseudoConstructorCall };
|
---|
383 |
|
---|
384 | public:
|
---|
385 | PseudoDestructorCallAST();
|
---|
386 |
|
---|
387 | private:
|
---|
388 | PseudoDestructorCallAST(const PseudoDestructorCallAST &source);
|
---|
389 | void operator = (const PseudoDestructorCallAST &source);
|
---|
390 | };
|
---|
391 |
|
---|
392 | class ClassMemberAccessAST: public AbstractExpressionAST
|
---|
393 | {
|
---|
394 | public:
|
---|
395 | enum { Type = NodeType_ClassMemberAccess };
|
---|
396 |
|
---|
397 | public:
|
---|
398 | ClassMemberAccessAST();
|
---|
399 |
|
---|
400 | inline AST *op() const
|
---|
401 | { return m_op; }
|
---|
402 |
|
---|
403 | inline AbstractExpressionAST *expression() const
|
---|
404 | { return m_expression; }
|
---|
405 |
|
---|
406 | inline NameAST *name() const
|
---|
407 | { return m_name; }
|
---|
408 |
|
---|
409 | void setOp(AST *op);
|
---|
410 | void setExpression(AbstractExpressionAST *expression);
|
---|
411 | void setName(NameAST *name);
|
---|
412 |
|
---|
413 | private:
|
---|
414 | AST *m_op;
|
---|
415 | AbstractExpressionAST *m_expression;
|
---|
416 | AST *m_templ;
|
---|
417 | NameAST *m_name;
|
---|
418 |
|
---|
419 | private:
|
---|
420 | ClassMemberAccessAST(const ClassMemberAccessAST &source);
|
---|
421 | void operator = (const ClassMemberAccessAST &source);
|
---|
422 | };
|
---|
423 |
|
---|
424 | class IncrDecrAST: public AbstractExpressionAST
|
---|
425 | {
|
---|
426 | public:
|
---|
427 | enum { Type = NodeType_IncrDecr };
|
---|
428 |
|
---|
429 | public:
|
---|
430 | IncrDecrAST();
|
---|
431 |
|
---|
432 | inline AST *op() const
|
---|
433 | { return m_op; }
|
---|
434 |
|
---|
435 | inline AbstractExpressionAST *expression() const
|
---|
436 | { return m_expression; }
|
---|
437 |
|
---|
438 | void setOp(AST *op);
|
---|
439 | void setExpression(AbstractExpressionAST *expression);
|
---|
440 |
|
---|
441 | private:
|
---|
442 | AST *m_op;
|
---|
443 | AbstractExpressionAST *m_expression;
|
---|
444 |
|
---|
445 | private:
|
---|
446 | IncrDecrAST(const IncrDecrAST &source);
|
---|
447 | void operator = (const IncrDecrAST &source);
|
---|
448 | };
|
---|
449 |
|
---|
450 | class CppCastExpressionAST: public AbstractExpressionAST
|
---|
451 | {
|
---|
452 | public:
|
---|
453 | enum { Type = NodeType_CppCastExpression };
|
---|
454 |
|
---|
455 | public:
|
---|
456 | CppCastExpressionAST();
|
---|
457 |
|
---|
458 | inline AST *castOp() const
|
---|
459 | { return m_castOp; }
|
---|
460 |
|
---|
461 | inline AST *typeId() const
|
---|
462 | { return m_typeId; }
|
---|
463 |
|
---|
464 | inline AbstractExpressionAST *expression() const
|
---|
465 | { return m_expression; }
|
---|
466 |
|
---|
467 | void setCastOp(AST *castOp);
|
---|
468 | void setTypeId(AST *typeId);
|
---|
469 | void setExpression(AbstractExpressionAST *expression);
|
---|
470 |
|
---|
471 | private:
|
---|
472 | AST *m_castOp;
|
---|
473 | AST *m_typeId;
|
---|
474 | AbstractExpressionAST *m_expression;
|
---|
475 |
|
---|
476 | private:
|
---|
477 | CppCastExpressionAST(const CppCastExpressionAST &source);
|
---|
478 | void operator = (const CppCastExpressionAST &source);
|
---|
479 | };
|
---|
480 |
|
---|
481 | class TypeIdentificationAST: public AbstractExpressionAST
|
---|
482 | {
|
---|
483 | public:
|
---|
484 | enum { Type = NodeType_TypeIdentification };
|
---|
485 |
|
---|
486 | public:
|
---|
487 | TypeIdentificationAST();
|
---|
488 |
|
---|
489 | private:
|
---|
490 | TypeIdentificationAST(const TypeIdentificationAST &source);
|
---|
491 | void operator = (const TypeIdentificationAST &source);
|
---|
492 | };
|
---|
493 |
|
---|
494 | class TypeIdAST: public AST
|
---|
495 | {
|
---|
496 | public:
|
---|
497 | enum { Type = NodeType_TypeId };
|
---|
498 |
|
---|
499 | public:
|
---|
500 | TypeIdAST();
|
---|
501 |
|
---|
502 | inline TypeSpecifierAST *typeSpecifier() const
|
---|
503 | { return m_typeSpecifier; }
|
---|
504 |
|
---|
505 | inline DeclaratorAST *declarator() const
|
---|
506 | { return m_declarator; }
|
---|
507 |
|
---|
508 | void setTypeSpecifier(TypeSpecifierAST *typeSpecifier);
|
---|
509 | void setDeclarator(DeclaratorAST *declarator);
|
---|
510 |
|
---|
511 | private:
|
---|
512 | TypeSpecifierAST *m_typeSpecifier;
|
---|
513 | DeclaratorAST *m_declarator;
|
---|
514 |
|
---|
515 | private:
|
---|
516 | TypeIdAST(const TypeIdAST &source);
|
---|
517 | void operator = (const TypeIdAST &source);
|
---|
518 | };
|
---|
519 |
|
---|
520 | class StatementAST: public AST
|
---|
521 | {
|
---|
522 | public:
|
---|
523 | enum { Type = NodeType_Statement };
|
---|
524 | };
|
---|
525 |
|
---|
526 | class TemplateArgumentListAST: public AST
|
---|
527 | {
|
---|
528 | public:
|
---|
529 | enum { Type = NodeType_TemplateArgumentList };
|
---|
530 |
|
---|
531 | public:
|
---|
532 | TemplateArgumentListAST();
|
---|
533 |
|
---|
534 | void addArgument(AST *arg);
|
---|
535 | inline List<AST *> *argumentList() const { return m_argumentList; }
|
---|
536 |
|
---|
537 | private:
|
---|
538 | List<AST *> *m_argumentList;
|
---|
539 |
|
---|
540 | private:
|
---|
541 | TemplateArgumentListAST(const TemplateArgumentListAST &source);
|
---|
542 | void operator = (const TemplateArgumentListAST &source);
|
---|
543 | };
|
---|
544 |
|
---|
545 | class ClassOrNamespaceNameAST: public AST
|
---|
546 | {
|
---|
547 | public:
|
---|
548 | enum { Type = NodeType_ClassOrNamespaceName };
|
---|
549 |
|
---|
550 | public:
|
---|
551 | ClassOrNamespaceNameAST();
|
---|
552 |
|
---|
553 | inline AST *name() const { return m_name; }
|
---|
554 | void setName(AST *name);
|
---|
555 |
|
---|
556 | inline TemplateArgumentListAST *templateArgumentList() const { return m_templateArgumentList; }
|
---|
557 | void setTemplateArgumentList(TemplateArgumentListAST *templateArgumentList);
|
---|
558 |
|
---|
559 | private:
|
---|
560 | AST* m_name;
|
---|
561 | TemplateArgumentListAST* m_templateArgumentList;
|
---|
562 |
|
---|
563 | private:
|
---|
564 | ClassOrNamespaceNameAST(const ClassOrNamespaceNameAST &source);
|
---|
565 | void operator = (const ClassOrNamespaceNameAST &source);
|
---|
566 | };
|
---|
567 |
|
---|
568 | class NameAST: public AST
|
---|
569 | {
|
---|
570 | public:
|
---|
571 | enum { Type = NodeType_Name };
|
---|
572 |
|
---|
573 | public:
|
---|
574 | NameAST();
|
---|
575 |
|
---|
576 | inline bool isGlobal() const { return m_global; }
|
---|
577 | void setGlobal(bool b);
|
---|
578 |
|
---|
579 | void addClassOrNamespaceName(ClassOrNamespaceNameAST *classOrNamespaceName);
|
---|
580 | inline List<ClassOrNamespaceNameAST *> *classOrNamespaceNameList() const { return m_classOrNamespaceNameList; }
|
---|
581 |
|
---|
582 | inline ClassOrNamespaceNameAST *unqualifiedName() const { return m_unqualifiedName; }
|
---|
583 | void setUnqualifiedName(ClassOrNamespaceNameAST *unqualifiedName);
|
---|
584 |
|
---|
585 | private:
|
---|
586 | bool m_global;
|
---|
587 | ClassOrNamespaceNameAST* m_unqualifiedName;
|
---|
588 | List<ClassOrNamespaceNameAST *> *m_classOrNamespaceNameList;
|
---|
589 |
|
---|
590 | private:
|
---|
591 | NameAST(const NameAST &source);
|
---|
592 | void operator = (const NameAST &source);
|
---|
593 | };
|
---|
594 |
|
---|
595 | class TypeParameterAST: public AST
|
---|
596 | {
|
---|
597 | public:
|
---|
598 | enum { Type = NodeType_TypeParameter };
|
---|
599 |
|
---|
600 | public:
|
---|
601 | TypeParameterAST();
|
---|
602 |
|
---|
603 | inline AST *kind() const { return m_kind; }
|
---|
604 | void setKind(AST *kind);
|
---|
605 |
|
---|
606 | inline class TemplateParameterListAST *templateParameterList() const { return m_templateParameterList; }
|
---|
607 | void setTemplateParameterList(class TemplateParameterListAST *templateParameterList);
|
---|
608 |
|
---|
609 | inline NameAST *name() const { return m_name; }
|
---|
610 | void setName(NameAST *name);
|
---|
611 |
|
---|
612 | inline AST *typeId() const { return m_typeId; }
|
---|
613 | void setTypeId(AST *typeId);
|
---|
614 |
|
---|
615 | private:
|
---|
616 | AST* m_kind;
|
---|
617 | class TemplateParameterListAST *m_templateParameterList;
|
---|
618 | NameAST* m_name;
|
---|
619 | AST* m_typeId;
|
---|
620 |
|
---|
621 | private:
|
---|
622 | TypeParameterAST(const TypeParameterAST &source);
|
---|
623 | void operator = (const TypeParameterAST &source);
|
---|
624 | };
|
---|
625 |
|
---|
626 | class DeclarationAST: public AST
|
---|
627 | {
|
---|
628 | public:
|
---|
629 | enum { Type = NodeType_Declaration };
|
---|
630 |
|
---|
631 | public:
|
---|
632 | DeclarationAST();
|
---|
633 |
|
---|
634 | private:
|
---|
635 | DeclarationAST(const DeclarationAST &source);
|
---|
636 | void operator = (const DeclarationAST &source);
|
---|
637 | };
|
---|
638 |
|
---|
639 | class AccessDeclarationAST: public DeclarationAST
|
---|
640 | {
|
---|
641 | public:
|
---|
642 | enum { Type = NodeType_AccessDeclaration };
|
---|
643 |
|
---|
644 | public:
|
---|
645 | AccessDeclarationAST();
|
---|
646 |
|
---|
647 | inline List<AST *> *accessList() const { return m_accessList; }
|
---|
648 | void addAccess(AST *access);
|
---|
649 |
|
---|
650 | private:
|
---|
651 | List<AST *> *m_accessList;
|
---|
652 |
|
---|
653 | private:
|
---|
654 | AccessDeclarationAST(const AccessDeclarationAST &source);
|
---|
655 | void operator = (const AccessDeclarationAST &source);
|
---|
656 | };
|
---|
657 |
|
---|
658 | class TypeSpecifierAST: public AST
|
---|
659 | {
|
---|
660 | public:
|
---|
661 | enum { Type = NodeType_TypeSpecifier };
|
---|
662 |
|
---|
663 | public:
|
---|
664 | TypeSpecifierAST();
|
---|
665 |
|
---|
666 | inline virtual NameAST *name() const { return m_name; }
|
---|
667 | virtual void setName(NameAST *name);
|
---|
668 |
|
---|
669 | inline AST *cvQualify() const { return m_cvQualify; }
|
---|
670 | void setCvQualify(AST *cvQualify);
|
---|
671 |
|
---|
672 | inline AST *cv2Qualify() const { return m_cv2Qualify; }
|
---|
673 | void setCv2Qualify(AST *cv2Qualify);
|
---|
674 |
|
---|
675 | private:
|
---|
676 | NameAST* m_name;
|
---|
677 | AST* m_cvQualify;
|
---|
678 | AST* m_cv2Qualify;
|
---|
679 |
|
---|
680 | private:
|
---|
681 | TypeSpecifierAST(const TypeSpecifierAST &source);
|
---|
682 | void operator = (const TypeSpecifierAST &source);
|
---|
683 | };
|
---|
684 |
|
---|
685 | class BaseSpecifierAST: public AST
|
---|
686 | {
|
---|
687 | public:
|
---|
688 | enum { Type = NodeType_BaseSpecifier };
|
---|
689 |
|
---|
690 | public:
|
---|
691 | BaseSpecifierAST();
|
---|
692 |
|
---|
693 | inline AST *isVirtual() const { return m_isVirtual; }
|
---|
694 | void setIsVirtual(AST *isVirtual);
|
---|
695 |
|
---|
696 | inline AST *access() const { return m_access; }
|
---|
697 | void setAccess(AST *access);
|
---|
698 |
|
---|
699 | inline NameAST *name() const { return m_name; }
|
---|
700 | void setName(NameAST *name);
|
---|
701 |
|
---|
702 | private:
|
---|
703 | AST* m_isVirtual;
|
---|
704 | AST* m_access;
|
---|
705 | NameAST* m_name;
|
---|
706 |
|
---|
707 | private:
|
---|
708 | BaseSpecifierAST(const BaseSpecifierAST &source);
|
---|
709 | void operator = (const BaseSpecifierAST &source);
|
---|
710 | };
|
---|
711 |
|
---|
712 | class BaseClauseAST: public AST
|
---|
713 | {
|
---|
714 | public:
|
---|
715 | enum { Type = NodeType_BaseClause };
|
---|
716 |
|
---|
717 | public:
|
---|
718 | BaseClauseAST();
|
---|
719 |
|
---|
720 | void addBaseSpecifier(BaseSpecifierAST *baseSpecifier);
|
---|
721 | inline List<BaseSpecifierAST *> *baseSpecifierList() const { return m_baseSpecifierList; }
|
---|
722 |
|
---|
723 | private:
|
---|
724 | List<BaseSpecifierAST *> *m_baseSpecifierList;
|
---|
725 |
|
---|
726 | private:
|
---|
727 | BaseClauseAST(const BaseClauseAST &source);
|
---|
728 | void operator = (const BaseClauseAST &source);
|
---|
729 | };
|
---|
730 |
|
---|
731 | class ClassSpecifierAST: public TypeSpecifierAST
|
---|
732 | {
|
---|
733 | public:
|
---|
734 | enum { Type = NodeType_ClassSpecifier };
|
---|
735 |
|
---|
736 | public:
|
---|
737 | ClassSpecifierAST();
|
---|
738 |
|
---|
739 | inline AST *winDeclSpec() const { return m_winDeclSpec; }
|
---|
740 | void setWinDeclSpec(AST *winDeclSpec);
|
---|
741 |
|
---|
742 | inline AST *classKey() const { return m_classKey; }
|
---|
743 | void setClassKey(AST *classKey);
|
---|
744 |
|
---|
745 | inline BaseClauseAST *baseClause() const { return m_baseClause; }
|
---|
746 | void setBaseClause(BaseClauseAST *baseClause);
|
---|
747 |
|
---|
748 | inline List<DeclarationAST *> *declarationList() const { return m_declarationList; }
|
---|
749 | void addDeclaration(DeclarationAST *declaration);
|
---|
750 |
|
---|
751 | private:
|
---|
752 | AST* m_winDeclSpec;
|
---|
753 | AST* m_classKey;
|
---|
754 | BaseClauseAST* m_baseClause;
|
---|
755 | List<DeclarationAST *> *m_declarationList;
|
---|
756 |
|
---|
757 | private:
|
---|
758 | ClassSpecifierAST(const ClassSpecifierAST &source);
|
---|
759 | void operator = (const ClassSpecifierAST &source);
|
---|
760 | };
|
---|
761 |
|
---|
762 | class EnumeratorAST: public AST
|
---|
763 | {
|
---|
764 | public:
|
---|
765 | enum { Type = NodeType_Enumerator };
|
---|
766 |
|
---|
767 | public:
|
---|
768 | EnumeratorAST();
|
---|
769 |
|
---|
770 | inline AST *id() const { return m_id; }
|
---|
771 | void setId(AST *id);
|
---|
772 |
|
---|
773 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
774 | void setExpression(AbstractExpressionAST *expr);
|
---|
775 |
|
---|
776 | private:
|
---|
777 | AST* m_id;
|
---|
778 | AbstractExpressionAST* m_expression;
|
---|
779 |
|
---|
780 | private:
|
---|
781 | EnumeratorAST(const EnumeratorAST &source);
|
---|
782 | void operator = (const EnumeratorAST &source);
|
---|
783 | };
|
---|
784 |
|
---|
785 | class EnumSpecifierAST: public TypeSpecifierAST
|
---|
786 | {
|
---|
787 | public:
|
---|
788 | enum { Type = NodeType_EnumSpecifier };
|
---|
789 |
|
---|
790 | public:
|
---|
791 | EnumSpecifierAST();
|
---|
792 |
|
---|
793 | void addEnumerator(EnumeratorAST *enumerator);
|
---|
794 | inline List<EnumeratorAST *> *enumeratorList() const { return m_enumeratorList; }
|
---|
795 |
|
---|
796 | private:
|
---|
797 | List<EnumeratorAST *> *m_enumeratorList;
|
---|
798 |
|
---|
799 | private:
|
---|
800 | EnumSpecifierAST(const EnumSpecifierAST &source);
|
---|
801 | void operator = (const EnumSpecifierAST &source);
|
---|
802 | };
|
---|
803 |
|
---|
804 | class ElaboratedTypeSpecifierAST: public TypeSpecifierAST
|
---|
805 | {
|
---|
806 | public:
|
---|
807 | enum { Type = NodeType_ElaboratedTypeSpecifier };
|
---|
808 |
|
---|
809 | public:
|
---|
810 | ElaboratedTypeSpecifierAST();
|
---|
811 |
|
---|
812 | inline AST *kind() const { return m_kind; }
|
---|
813 | void setKind(AST *kind);
|
---|
814 |
|
---|
815 | private:
|
---|
816 | AST* m_kind;
|
---|
817 |
|
---|
818 | private:
|
---|
819 | ElaboratedTypeSpecifierAST(const ElaboratedTypeSpecifierAST &source);
|
---|
820 | void operator = (const ElaboratedTypeSpecifierAST &source);
|
---|
821 | };
|
---|
822 |
|
---|
823 |
|
---|
824 | class LinkageBodyAST: public AST
|
---|
825 | {
|
---|
826 | public:
|
---|
827 | enum { Type = NodeType_LinkageBody };
|
---|
828 |
|
---|
829 | public:
|
---|
830 | LinkageBodyAST();
|
---|
831 |
|
---|
832 | void addDeclaration(DeclarationAST *ast);
|
---|
833 | inline List<DeclarationAST *> *declarationList() const { return m_declarationList; }
|
---|
834 |
|
---|
835 | private:
|
---|
836 | List<DeclarationAST *> *m_declarationList;
|
---|
837 |
|
---|
838 | private:
|
---|
839 | LinkageBodyAST(const LinkageBodyAST &source);
|
---|
840 | void operator = (const LinkageBodyAST &source);
|
---|
841 | };
|
---|
842 |
|
---|
843 | class LinkageSpecificationAST: public DeclarationAST
|
---|
844 | {
|
---|
845 | public:
|
---|
846 | enum { Type = NodeType_LinkageSpecification };
|
---|
847 |
|
---|
848 | public:
|
---|
849 | LinkageSpecificationAST();
|
---|
850 |
|
---|
851 | inline AST *externType() const { return m_externType; }
|
---|
852 | void setExternType(AST *externType);
|
---|
853 |
|
---|
854 | inline LinkageBodyAST *linkageBody() const { return m_linkageBody; }
|
---|
855 | void setLinkageBody(LinkageBodyAST *linkageBody);
|
---|
856 |
|
---|
857 | inline DeclarationAST *declaration() const { return m_declaration; }
|
---|
858 | void setDeclaration(DeclarationAST *decl);
|
---|
859 |
|
---|
860 | private:
|
---|
861 | AST* m_externType;
|
---|
862 | LinkageBodyAST* m_linkageBody;
|
---|
863 | DeclarationAST* m_declaration;
|
---|
864 |
|
---|
865 | private:
|
---|
866 | LinkageSpecificationAST(const LinkageSpecificationAST &source);
|
---|
867 | void operator = (const LinkageSpecificationAST &source);
|
---|
868 | };
|
---|
869 |
|
---|
870 | class NamespaceAST: public DeclarationAST
|
---|
871 | {
|
---|
872 | public:
|
---|
873 | enum { Type = NodeType_Namespace };
|
---|
874 |
|
---|
875 | public:
|
---|
876 | NamespaceAST();
|
---|
877 |
|
---|
878 | inline AST *namespaceName() const { return m_namespaceName; }
|
---|
879 | void setNamespaceName(AST *namespaceName);
|
---|
880 |
|
---|
881 | inline LinkageBodyAST *linkageBody() const { return m_linkageBody; }
|
---|
882 | void setLinkageBody(LinkageBodyAST *linkageBody);
|
---|
883 |
|
---|
884 | private:
|
---|
885 | AST* m_namespaceName;
|
---|
886 | LinkageBodyAST* m_linkageBody;
|
---|
887 |
|
---|
888 | private:
|
---|
889 | NamespaceAST(const NamespaceAST &source);
|
---|
890 | void operator = (const NamespaceAST &source);
|
---|
891 | };
|
---|
892 |
|
---|
893 | class NamespaceAliasAST: public DeclarationAST
|
---|
894 | {
|
---|
895 | public:
|
---|
896 | enum { Type = NodeType_NamespaceAlias };
|
---|
897 |
|
---|
898 | public:
|
---|
899 | NamespaceAliasAST();
|
---|
900 |
|
---|
901 | inline AST *namespaceName() const { return m_namespaceName; }
|
---|
902 | void setNamespaceName(AST *name);
|
---|
903 |
|
---|
904 | inline NameAST *aliasName() const { return m_aliasName; }
|
---|
905 | void setAliasName(NameAST *name);
|
---|
906 |
|
---|
907 | private:
|
---|
908 | AST* m_namespaceName;
|
---|
909 | NameAST* m_aliasName;
|
---|
910 |
|
---|
911 | private:
|
---|
912 | NamespaceAliasAST(const NamespaceAliasAST &source);
|
---|
913 | void operator = (const NamespaceAliasAST &source);
|
---|
914 | };
|
---|
915 |
|
---|
916 | class UsingAST: public DeclarationAST
|
---|
917 | {
|
---|
918 | public:
|
---|
919 | enum { Type = NodeType_Using };
|
---|
920 |
|
---|
921 | public:
|
---|
922 | UsingAST();
|
---|
923 |
|
---|
924 | inline AST *typeName() const { return m_typeName; }
|
---|
925 | void setTypeName(AST *typeName);
|
---|
926 |
|
---|
927 | inline NameAST *name() const { return m_name; }
|
---|
928 | void setName(NameAST *name);
|
---|
929 |
|
---|
930 | private:
|
---|
931 | AST* m_typeName;
|
---|
932 | NameAST* m_name;
|
---|
933 |
|
---|
934 | private:
|
---|
935 | UsingAST(const UsingAST &source);
|
---|
936 | void operator = (const UsingAST &source);
|
---|
937 | };
|
---|
938 |
|
---|
939 | class UsingDirectiveAST: public DeclarationAST
|
---|
940 | {
|
---|
941 | public:
|
---|
942 | enum { Type = NodeType_UsingDirective };
|
---|
943 |
|
---|
944 | public:
|
---|
945 | UsingDirectiveAST();
|
---|
946 |
|
---|
947 | inline NameAST *name() const { return m_name; }
|
---|
948 | void setName(NameAST *name);
|
---|
949 |
|
---|
950 | private:
|
---|
951 | NameAST* m_name;
|
---|
952 |
|
---|
953 | private:
|
---|
954 | UsingDirectiveAST(const UsingDirectiveAST &source);
|
---|
955 | void operator = (const UsingDirectiveAST &source);
|
---|
956 | };
|
---|
957 |
|
---|
958 | class DeclaratorAST: public AST
|
---|
959 | {
|
---|
960 | public:
|
---|
961 | enum { Type = NodeType_Declarator };
|
---|
962 |
|
---|
963 | public:
|
---|
964 | DeclaratorAST();
|
---|
965 |
|
---|
966 | inline List<AST *> *ptrOpList() const { return m_ptrOpList; }
|
---|
967 | void addPtrOp(AST *ptrOp);
|
---|
968 |
|
---|
969 | inline DeclaratorAST *subDeclarator() const { return m_subDeclarator; }
|
---|
970 | void setSubDeclarator(DeclaratorAST *subDeclarator);
|
---|
971 |
|
---|
972 | inline NameAST *declaratorId() const { return m_declaratorId; }
|
---|
973 | void setDeclaratorId(NameAST *declaratorId);
|
---|
974 |
|
---|
975 | inline AST *bitfieldInitialization() const { return m_bitfieldInitialization; }
|
---|
976 | void setBitfieldInitialization(AST *bitfieldInitialization);
|
---|
977 |
|
---|
978 | inline List<AST *> *arrayDimensionList() const { return m_arrayDimensionList; }
|
---|
979 | void addArrayDimension(AST *arrayDimension);
|
---|
980 |
|
---|
981 | inline class ParameterDeclarationClauseAST *parameterDeclarationClause() const { return m_parameterDeclarationClause; }
|
---|
982 | void setParameterDeclarationClause(class ParameterDeclarationClauseAST *parameterDeclarationClause);
|
---|
983 |
|
---|
984 | // ### replace 'constant' with cvQualify
|
---|
985 | inline AST *constant() const { return m_constant; }
|
---|
986 | void setConstant(AST *constant);
|
---|
987 |
|
---|
988 | inline AST *exceptionSpecification() const { return m_exceptionSpecification; }
|
---|
989 | void setExceptionSpecification(AST *exceptionSpecification);
|
---|
990 |
|
---|
991 | private:
|
---|
992 | List<AST *> *m_ptrOpList;
|
---|
993 | DeclaratorAST * m_subDeclarator;
|
---|
994 | NameAST* m_declaratorId;
|
---|
995 | AST* m_bitfieldInitialization;
|
---|
996 | List<AST *> *m_arrayDimensionList;
|
---|
997 | class ParameterDeclarationClauseAST * m_parameterDeclarationClause;
|
---|
998 | AST* m_constant;
|
---|
999 | AST* m_exceptionSpecification;
|
---|
1000 |
|
---|
1001 | private:
|
---|
1002 | DeclaratorAST(const DeclaratorAST &source);
|
---|
1003 | void operator = (const DeclaratorAST &source);
|
---|
1004 | };
|
---|
1005 |
|
---|
1006 | class ParameterDeclarationAST: public AST
|
---|
1007 | {
|
---|
1008 | public:
|
---|
1009 | enum { Type = NodeType_ParameterDeclaration };
|
---|
1010 |
|
---|
1011 | public:
|
---|
1012 | ParameterDeclarationAST();
|
---|
1013 |
|
---|
1014 | inline TypeSpecifierAST *typeSpec() const { return m_typeSpec; }
|
---|
1015 | void setTypeSpec(TypeSpecifierAST *typeSpec);
|
---|
1016 |
|
---|
1017 | inline DeclaratorAST *declarator() const { return m_declarator; }
|
---|
1018 | void setDeclarator(DeclaratorAST *declarator);
|
---|
1019 |
|
---|
1020 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
1021 | void setExpression(AbstractExpressionAST *expression);
|
---|
1022 |
|
---|
1023 | private:
|
---|
1024 | TypeSpecifierAST* m_typeSpec;
|
---|
1025 | DeclaratorAST* m_declarator;
|
---|
1026 | AbstractExpressionAST* m_expression;
|
---|
1027 |
|
---|
1028 | private:
|
---|
1029 | ParameterDeclarationAST(const ParameterDeclarationAST &source);
|
---|
1030 | void operator = (const ParameterDeclarationAST &source);
|
---|
1031 | };
|
---|
1032 |
|
---|
1033 | class ParameterDeclarationListAST: public AST
|
---|
1034 | {
|
---|
1035 | public:
|
---|
1036 | enum { Type = NodeType_ParameterDeclarationList };
|
---|
1037 |
|
---|
1038 | public:
|
---|
1039 | ParameterDeclarationListAST();
|
---|
1040 |
|
---|
1041 | inline List<ParameterDeclarationAST *> *parameterList() const { return m_parameterList; }
|
---|
1042 | void addParameter(ParameterDeclarationAST *parameter);
|
---|
1043 |
|
---|
1044 | private:
|
---|
1045 | List<ParameterDeclarationAST *> *m_parameterList;
|
---|
1046 |
|
---|
1047 | private:
|
---|
1048 | ParameterDeclarationListAST(const ParameterDeclarationListAST &source);
|
---|
1049 | void operator = (const ParameterDeclarationListAST &source);
|
---|
1050 | };
|
---|
1051 |
|
---|
1052 | class ParameterDeclarationClauseAST: public AST
|
---|
1053 | {
|
---|
1054 | public:
|
---|
1055 | enum { Type = NodeType_ParameterDeclarationClause };
|
---|
1056 |
|
---|
1057 | public:
|
---|
1058 | ParameterDeclarationClauseAST();
|
---|
1059 |
|
---|
1060 | inline ParameterDeclarationListAST *parameterDeclarationList() const { return m_parameterDeclarationList; }
|
---|
1061 | void setParameterDeclarationList(ParameterDeclarationListAST *parameterDeclarationList);
|
---|
1062 |
|
---|
1063 | inline AST *ellipsis() const { return m_ellipsis; }
|
---|
1064 | void setEllipsis(AST *ellipsis);
|
---|
1065 |
|
---|
1066 | private:
|
---|
1067 | ParameterDeclarationListAST* m_parameterDeclarationList;
|
---|
1068 | AST* m_ellipsis;
|
---|
1069 |
|
---|
1070 | private:
|
---|
1071 | ParameterDeclarationClauseAST(const ParameterDeclarationClauseAST &source);
|
---|
1072 | void operator = (const ParameterDeclarationClauseAST &source);
|
---|
1073 | };
|
---|
1074 |
|
---|
1075 |
|
---|
1076 | class InitDeclaratorAST: public AST
|
---|
1077 | {
|
---|
1078 | public:
|
---|
1079 | enum { Type = NodeType_InitDeclarator };
|
---|
1080 |
|
---|
1081 | public:
|
---|
1082 | InitDeclaratorAST();
|
---|
1083 |
|
---|
1084 | inline DeclaratorAST *declarator() const { return m_declarator; }
|
---|
1085 | void setDeclarator(DeclaratorAST *declarator);
|
---|
1086 |
|
---|
1087 | inline AST *initializer() const { return m_initializer; }
|
---|
1088 | void setInitializer(AST *initializer);
|
---|
1089 |
|
---|
1090 | private:
|
---|
1091 | DeclaratorAST* m_declarator;
|
---|
1092 | AST* m_initializer;
|
---|
1093 |
|
---|
1094 | private:
|
---|
1095 | InitDeclaratorAST(const InitDeclaratorAST &source);
|
---|
1096 | void operator = (const InitDeclaratorAST &source);
|
---|
1097 | };
|
---|
1098 |
|
---|
1099 | class InitDeclaratorListAST: public AST
|
---|
1100 | {
|
---|
1101 | public:
|
---|
1102 | enum { Type = NodeType_InitDeclaratorList };
|
---|
1103 |
|
---|
1104 | public:
|
---|
1105 | InitDeclaratorListAST();
|
---|
1106 |
|
---|
1107 | inline List<InitDeclaratorAST *> *initDeclaratorList() const { return m_initDeclaratorList; }
|
---|
1108 | void addInitDeclarator(InitDeclaratorAST *decl);
|
---|
1109 |
|
---|
1110 | private:
|
---|
1111 | List<InitDeclaratorAST *> *m_initDeclaratorList;
|
---|
1112 |
|
---|
1113 | private:
|
---|
1114 | InitDeclaratorListAST(const InitDeclaratorListAST &source);
|
---|
1115 | void operator = (const InitDeclaratorListAST &source);
|
---|
1116 | };
|
---|
1117 |
|
---|
1118 | class TypedefAST: public DeclarationAST
|
---|
1119 | {
|
---|
1120 | public:
|
---|
1121 | enum { Type = NodeType_Typedef };
|
---|
1122 |
|
---|
1123 | public:
|
---|
1124 | TypedefAST();
|
---|
1125 |
|
---|
1126 | inline TypeSpecifierAST *typeSpec() const { return m_typeSpec; }
|
---|
1127 | void setTypeSpec(TypeSpecifierAST *typeSpec);
|
---|
1128 |
|
---|
1129 | inline InitDeclaratorListAST *initDeclaratorList() const { return m_initDeclaratorList; }
|
---|
1130 | void setInitDeclaratorList(InitDeclaratorListAST *initDeclaratorList);
|
---|
1131 |
|
---|
1132 | private:
|
---|
1133 | TypeSpecifierAST* m_typeSpec;
|
---|
1134 | InitDeclaratorListAST* m_initDeclaratorList;
|
---|
1135 |
|
---|
1136 | private:
|
---|
1137 | void operator = (const TypedefAST &source);
|
---|
1138 | };
|
---|
1139 |
|
---|
1140 | class TemplateParameterAST: public AST
|
---|
1141 | {
|
---|
1142 | public:
|
---|
1143 | enum { Type = NodeType_TemplateParameter };
|
---|
1144 |
|
---|
1145 | public:
|
---|
1146 | TemplateParameterAST();
|
---|
1147 |
|
---|
1148 | inline TypeParameterAST *typeParameter() const { return m_typeParameter; }
|
---|
1149 | void setTypeParameter(TypeParameterAST *typeParameter);
|
---|
1150 |
|
---|
1151 | inline ParameterDeclarationAST *typeValueParameter() const { return m_typeValueParameter; }
|
---|
1152 | void setTypeValueParameter(ParameterDeclarationAST *typeValueParameter);
|
---|
1153 |
|
---|
1154 | private:
|
---|
1155 | TypeParameterAST* m_typeParameter;
|
---|
1156 | ParameterDeclarationAST* m_typeValueParameter;
|
---|
1157 |
|
---|
1158 | private:
|
---|
1159 | TemplateParameterAST(const TemplateParameterAST &source);
|
---|
1160 | void operator = (const TemplateParameterAST &source);
|
---|
1161 | };
|
---|
1162 |
|
---|
1163 | class TemplateParameterListAST: public AST
|
---|
1164 | {
|
---|
1165 | public:
|
---|
1166 | enum { Type = NodeType_TemplateParameterList };
|
---|
1167 |
|
---|
1168 | public:
|
---|
1169 | TemplateParameterListAST();
|
---|
1170 |
|
---|
1171 | inline List<TemplateParameterAST *> *templateParameterList() const { return m_templateParameterList; }
|
---|
1172 | void addTemplateParameter(TemplateParameterAST *templateParameter);
|
---|
1173 |
|
---|
1174 | private:
|
---|
1175 | List<TemplateParameterAST *> *m_templateParameterList;
|
---|
1176 |
|
---|
1177 | private:
|
---|
1178 | TemplateParameterListAST(const TemplateParameterListAST &source);
|
---|
1179 | void operator = (const TemplateParameterListAST &source);
|
---|
1180 | };
|
---|
1181 |
|
---|
1182 | class TemplateDeclarationAST: public DeclarationAST
|
---|
1183 | {
|
---|
1184 | public:
|
---|
1185 | enum { Type = NodeType_TemplateDeclaration };
|
---|
1186 |
|
---|
1187 | public:
|
---|
1188 | TemplateDeclarationAST();
|
---|
1189 |
|
---|
1190 | inline AST *exported() const { return m_exported; }
|
---|
1191 | void setExported(AST *exported);
|
---|
1192 |
|
---|
1193 | inline TemplateParameterListAST *templateParameterList() const { return m_templateParameterList; }
|
---|
1194 | void setTemplateParameterList(TemplateParameterListAST *templateParameterList);
|
---|
1195 |
|
---|
1196 | inline DeclarationAST *declaration() const { return m_declaration; }
|
---|
1197 | void setDeclaration(DeclarationAST *declaration);
|
---|
1198 |
|
---|
1199 | private:
|
---|
1200 | AST* m_exported;
|
---|
1201 | TemplateParameterListAST* m_templateParameterList;
|
---|
1202 | DeclarationAST* m_declaration;
|
---|
1203 |
|
---|
1204 | private:
|
---|
1205 | TemplateDeclarationAST(const TemplateDeclarationAST &source);
|
---|
1206 | void operator = (const TemplateDeclarationAST &source);
|
---|
1207 | };
|
---|
1208 |
|
---|
1209 | class SimpleDeclarationAST: public DeclarationAST
|
---|
1210 | {
|
---|
1211 | public:
|
---|
1212 | enum { Type = NodeType_SimpleDeclaration };
|
---|
1213 |
|
---|
1214 | public:
|
---|
1215 | SimpleDeclarationAST();
|
---|
1216 |
|
---|
1217 | inline AST *functionSpecifier() const { return m_functionSpecifier; }
|
---|
1218 | void setFunctionSpecifier(AST *functionSpecifier);
|
---|
1219 |
|
---|
1220 | inline AST *storageSpecifier() const { return m_storageSpecifier; }
|
---|
1221 | void setStorageSpecifier(AST *storageSpecifier);
|
---|
1222 |
|
---|
1223 | inline TypeSpecifierAST *typeSpec() const { return m_typeSpec; }
|
---|
1224 | void setTypeSpec(TypeSpecifierAST *typeSpec);
|
---|
1225 |
|
---|
1226 | inline InitDeclaratorListAST *initDeclaratorList() const { return m_initDeclaratorList; }
|
---|
1227 | void setInitDeclaratorList(InitDeclaratorListAST *initDeclaratorList);
|
---|
1228 |
|
---|
1229 | inline AST *winDeclSpec() const { return m_winDeclSpec; }
|
---|
1230 | void setWinDeclSpec(AST *winDeclSpec);
|
---|
1231 |
|
---|
1232 | private:
|
---|
1233 | AST* m_functionSpecifier;
|
---|
1234 | AST* m_storageSpecifier;
|
---|
1235 | TypeSpecifierAST* m_typeSpec;
|
---|
1236 | InitDeclaratorListAST* m_initDeclaratorList;
|
---|
1237 | AST* m_winDeclSpec;
|
---|
1238 |
|
---|
1239 | private:
|
---|
1240 | SimpleDeclarationAST(const SimpleDeclarationAST &source);
|
---|
1241 | void operator = (const SimpleDeclarationAST &source);
|
---|
1242 | };
|
---|
1243 |
|
---|
1244 | class ExpressionStatementAST: public StatementAST
|
---|
1245 | {
|
---|
1246 | public:
|
---|
1247 | enum { Type = NodeType_ExpressionStatement };
|
---|
1248 |
|
---|
1249 | public:
|
---|
1250 | ExpressionStatementAST();
|
---|
1251 |
|
---|
1252 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
1253 | void setExpression(AbstractExpressionAST *expression);
|
---|
1254 |
|
---|
1255 | private:
|
---|
1256 | AbstractExpressionAST* m_expression;
|
---|
1257 |
|
---|
1258 | private:
|
---|
1259 | ExpressionStatementAST(const ExpressionStatementAST &source);
|
---|
1260 | void operator = (const ExpressionStatementAST &source);
|
---|
1261 | };
|
---|
1262 |
|
---|
1263 | class ReturnStatementAST: public StatementAST
|
---|
1264 | {
|
---|
1265 | public:
|
---|
1266 | enum { Type = NodeType_ReturnStatement };
|
---|
1267 |
|
---|
1268 | public:
|
---|
1269 | ReturnStatementAST();
|
---|
1270 |
|
---|
1271 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
1272 | void setExpression(AbstractExpressionAST *expression);
|
---|
1273 |
|
---|
1274 | private:
|
---|
1275 | AbstractExpressionAST* m_expression;
|
---|
1276 |
|
---|
1277 | private:
|
---|
1278 | ReturnStatementAST(const ReturnStatementAST &source);
|
---|
1279 | void operator = (const ReturnStatementAST &source);
|
---|
1280 | };
|
---|
1281 |
|
---|
1282 |
|
---|
1283 | class ConditionAST: public AST
|
---|
1284 | {
|
---|
1285 | public:
|
---|
1286 | enum { Type = NodeType_Condition };
|
---|
1287 |
|
---|
1288 | public:
|
---|
1289 | ConditionAST();
|
---|
1290 |
|
---|
1291 | inline TypeSpecifierAST *typeSpec() const { return m_typeSpec; }
|
---|
1292 | void setTypeSpec(TypeSpecifierAST *typeSpec);
|
---|
1293 |
|
---|
1294 | inline DeclaratorAST *declarator() const { return m_declarator; }
|
---|
1295 | void setDeclarator(DeclaratorAST *declarator);
|
---|
1296 |
|
---|
1297 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
1298 | void setExpression(AbstractExpressionAST *expression);
|
---|
1299 |
|
---|
1300 | private:
|
---|
1301 | TypeSpecifierAST* m_typeSpec;
|
---|
1302 | DeclaratorAST* m_declarator;
|
---|
1303 | AbstractExpressionAST* m_expression;
|
---|
1304 |
|
---|
1305 | private:
|
---|
1306 | ConditionAST(const ConditionAST &source);
|
---|
1307 | void operator = (const ConditionAST &source);
|
---|
1308 | };
|
---|
1309 |
|
---|
1310 | class IfStatementAST: public StatementAST
|
---|
1311 | {
|
---|
1312 | public:
|
---|
1313 | enum { Type = NodeType_IfStatement };
|
---|
1314 |
|
---|
1315 | public:
|
---|
1316 | IfStatementAST();
|
---|
1317 |
|
---|
1318 | inline ConditionAST *condition() const { return m_condition; }
|
---|
1319 | void setCondition(ConditionAST *condition);
|
---|
1320 |
|
---|
1321 | inline StatementAST *statement() const { return m_statement; }
|
---|
1322 | void setStatement(StatementAST *statement);
|
---|
1323 |
|
---|
1324 | inline StatementAST *elseStatement() const { return m_elseStatement; }
|
---|
1325 | void setElseStatement(StatementAST *statement);
|
---|
1326 |
|
---|
1327 | private:
|
---|
1328 | ConditionAST* m_condition;
|
---|
1329 | StatementAST* m_statement;
|
---|
1330 | StatementAST* m_elseStatement;
|
---|
1331 |
|
---|
1332 | private:
|
---|
1333 | IfStatementAST(const IfStatementAST &source);
|
---|
1334 | void operator = (const IfStatementAST &source);
|
---|
1335 | };
|
---|
1336 |
|
---|
1337 | class WhileStatementAST: public StatementAST
|
---|
1338 | {
|
---|
1339 | public:
|
---|
1340 | enum { Type = NodeType_WhileStatement };
|
---|
1341 |
|
---|
1342 | public:
|
---|
1343 | WhileStatementAST();
|
---|
1344 |
|
---|
1345 | inline ConditionAST *condition() const { return m_condition; }
|
---|
1346 | void setCondition(ConditionAST *condition);
|
---|
1347 |
|
---|
1348 | inline StatementAST *statement() const { return m_statement; }
|
---|
1349 | void setStatement(StatementAST *statement);
|
---|
1350 |
|
---|
1351 | private:
|
---|
1352 | ConditionAST* m_condition;
|
---|
1353 | StatementAST* m_statement;
|
---|
1354 |
|
---|
1355 | private:
|
---|
1356 | WhileStatementAST(const WhileStatementAST &source);
|
---|
1357 | void operator = (const WhileStatementAST &source);
|
---|
1358 | };
|
---|
1359 |
|
---|
1360 | class DoStatementAST: public StatementAST
|
---|
1361 | {
|
---|
1362 | public:
|
---|
1363 | enum { Type = NodeType_DoStatement };
|
---|
1364 |
|
---|
1365 | public:
|
---|
1366 | DoStatementAST();
|
---|
1367 |
|
---|
1368 | inline ConditionAST *condition() const { return m_condition; }
|
---|
1369 | void setCondition(ConditionAST *condition);
|
---|
1370 |
|
---|
1371 | inline StatementAST *statement() const { return m_statement; }
|
---|
1372 | void setStatement(StatementAST *statement);
|
---|
1373 |
|
---|
1374 | private:
|
---|
1375 | ConditionAST* m_condition;
|
---|
1376 | StatementAST* m_statement;
|
---|
1377 |
|
---|
1378 | private:
|
---|
1379 | DoStatementAST(const DoStatementAST &source);
|
---|
1380 | void operator = (const DoStatementAST &source);
|
---|
1381 | };
|
---|
1382 |
|
---|
1383 | class ForStatementAST: public StatementAST
|
---|
1384 | {
|
---|
1385 | public:
|
---|
1386 | enum { Type = NodeType_ForStatement };
|
---|
1387 |
|
---|
1388 | public:
|
---|
1389 | ForStatementAST();
|
---|
1390 |
|
---|
1391 | inline StatementAST *initStatement() const { return m_initStatement; }
|
---|
1392 | void setInitStatement(StatementAST *statement);
|
---|
1393 |
|
---|
1394 | inline ConditionAST *condition() const { return m_condition; }
|
---|
1395 | void setCondition(ConditionAST *condition);
|
---|
1396 |
|
---|
1397 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
1398 | void setExpression(AbstractExpressionAST *expression);
|
---|
1399 |
|
---|
1400 | inline StatementAST *statement() const { return m_statement; }
|
---|
1401 | void setStatement(StatementAST *statement);
|
---|
1402 |
|
---|
1403 | private:
|
---|
1404 | ConditionAST* m_condition;
|
---|
1405 | StatementAST* m_initStatement;
|
---|
1406 | StatementAST* m_statement;
|
---|
1407 | AbstractExpressionAST* m_expression;
|
---|
1408 |
|
---|
1409 | private:
|
---|
1410 | ForStatementAST(const ForStatementAST &source);
|
---|
1411 | void operator = (const ForStatementAST &source);
|
---|
1412 | };
|
---|
1413 |
|
---|
1414 | class SwitchStatementAST: public StatementAST
|
---|
1415 | {
|
---|
1416 | public:
|
---|
1417 | enum { Type = NodeType_SwitchStatement };
|
---|
1418 |
|
---|
1419 | public:
|
---|
1420 | SwitchStatementAST();
|
---|
1421 |
|
---|
1422 | inline ConditionAST *condition() const { return m_condition; }
|
---|
1423 | void setCondition(ConditionAST *condition);
|
---|
1424 |
|
---|
1425 | inline StatementAST *statement() const { return m_statement; }
|
---|
1426 | void setStatement(StatementAST *statement);
|
---|
1427 |
|
---|
1428 | private:
|
---|
1429 | ConditionAST* m_condition;
|
---|
1430 | StatementAST* m_statement;
|
---|
1431 |
|
---|
1432 | private:
|
---|
1433 | SwitchStatementAST(const SwitchStatementAST &source);
|
---|
1434 | void operator = (const SwitchStatementAST &source);
|
---|
1435 | };
|
---|
1436 |
|
---|
1437 | class StatementListAST: public StatementAST
|
---|
1438 | {
|
---|
1439 | public:
|
---|
1440 | enum { Type = NodeType_StatementList };
|
---|
1441 |
|
---|
1442 | public:
|
---|
1443 | StatementListAST();
|
---|
1444 |
|
---|
1445 | inline List<StatementAST *> *statementList() const { return m_statementList; }
|
---|
1446 | void addStatement(StatementAST *statement);
|
---|
1447 |
|
---|
1448 | private:
|
---|
1449 | List<StatementAST *> *m_statementList;
|
---|
1450 |
|
---|
1451 | private:
|
---|
1452 | StatementListAST(const StatementListAST &source);
|
---|
1453 | void operator = (const StatementListAST &source);
|
---|
1454 | };
|
---|
1455 |
|
---|
1456 | class DeclarationStatementAST: public StatementAST
|
---|
1457 | {
|
---|
1458 | public:
|
---|
1459 | enum { Type = NodeType_DeclarationStatement };
|
---|
1460 |
|
---|
1461 | public:
|
---|
1462 | DeclarationStatementAST();
|
---|
1463 |
|
---|
1464 | inline DeclarationAST *declaration() const { return m_declaration; }
|
---|
1465 | void setDeclaration(DeclarationAST *declaration);
|
---|
1466 |
|
---|
1467 | private:
|
---|
1468 | DeclarationAST* m_declaration;
|
---|
1469 |
|
---|
1470 | private:
|
---|
1471 | DeclarationStatementAST(const DeclarationStatementAST &source);
|
---|
1472 | void operator = (const DeclarationStatementAST &source);
|
---|
1473 | };
|
---|
1474 |
|
---|
1475 | /*
|
---|
1476 | LabeledStatementAST:
|
---|
1477 | case constant-expression : statement
|
---|
1478 | default : statement (expression is 0)
|
---|
1479 | */
|
---|
1480 | class LabeledStatementAST: public StatementAST
|
---|
1481 | {
|
---|
1482 | public:
|
---|
1483 | enum { Type = NodeType_LabeledStatement };
|
---|
1484 | public:
|
---|
1485 | LabeledStatementAST();
|
---|
1486 |
|
---|
1487 | inline StatementAST *statement() const { return m_statement; }
|
---|
1488 | void setStatement(StatementAST *statement);
|
---|
1489 |
|
---|
1490 | inline AbstractExpressionAST *expression() const { return m_expression; }
|
---|
1491 | void setExpression(AbstractExpressionAST *expression);
|
---|
1492 | private:
|
---|
1493 | StatementAST* m_statement;
|
---|
1494 | AbstractExpressionAST *m_expression;
|
---|
1495 |
|
---|
1496 | private:
|
---|
1497 | LabeledStatementAST(const LabeledStatementAST &source);
|
---|
1498 | void operator = (const LabeledStatementAST &source);
|
---|
1499 | };
|
---|
1500 |
|
---|
1501 | class FunctionDefinitionAST: public DeclarationAST
|
---|
1502 | {
|
---|
1503 | public:
|
---|
1504 | enum { Type = NodeType_FunctionDefinition };
|
---|
1505 |
|
---|
1506 | public:
|
---|
1507 | FunctionDefinitionAST();
|
---|
1508 |
|
---|
1509 | inline AST *functionSpecifier() const { return m_functionSpecifier; }
|
---|
1510 | void setFunctionSpecifier(AST *functionSpecifier);
|
---|
1511 |
|
---|
1512 | inline AST *storageSpecifier() const { return m_storageSpecifier; }
|
---|
1513 | void setStorageSpecifier(AST *storageSpecifier);
|
---|
1514 |
|
---|
1515 | inline TypeSpecifierAST *typeSpec() const { return m_typeSpec; }
|
---|
1516 | void setTypeSpec(TypeSpecifierAST *typeSpec);
|
---|
1517 |
|
---|
1518 | inline InitDeclaratorAST *initDeclarator() const { return m_initDeclarator; }
|
---|
1519 | void setInitDeclarator(InitDeclaratorAST *initDeclarator);
|
---|
1520 |
|
---|
1521 | inline StatementListAST *functionBody() const { return m_functionBody; }
|
---|
1522 | void setFunctionBody(StatementListAST *functionBody);
|
---|
1523 |
|
---|
1524 | inline AST *winDeclSpec() const { return m_winDeclSpec; }
|
---|
1525 | void setWinDeclSpec(AST *winDeclSpec);
|
---|
1526 |
|
---|
1527 | private:
|
---|
1528 | AST* m_functionSpecifier;
|
---|
1529 | AST* m_storageSpecifier;
|
---|
1530 | TypeSpecifierAST* m_typeSpec;
|
---|
1531 | InitDeclaratorAST* m_initDeclarator;
|
---|
1532 | StatementListAST* m_functionBody;
|
---|
1533 | AST* m_winDeclSpec;
|
---|
1534 |
|
---|
1535 | private:
|
---|
1536 | FunctionDefinitionAST(const FunctionDefinitionAST &source);
|
---|
1537 | void operator = (const FunctionDefinitionAST &source);
|
---|
1538 | };
|
---|
1539 |
|
---|
1540 | class TranslationUnitAST: public AST
|
---|
1541 | {
|
---|
1542 | public:
|
---|
1543 | enum { Type = NodeType_TranslationUnit };
|
---|
1544 |
|
---|
1545 | public:
|
---|
1546 | TranslationUnitAST();
|
---|
1547 |
|
---|
1548 | void addDeclaration(DeclarationAST *ast);
|
---|
1549 | inline List<DeclarationAST *> *declarationList() const { return m_declarationList; }
|
---|
1550 |
|
---|
1551 | private:
|
---|
1552 | List<DeclarationAST *> *m_declarationList;
|
---|
1553 |
|
---|
1554 | private:
|
---|
1555 | TranslationUnitAST(const TranslationUnitAST &source);
|
---|
1556 | void operator = (const TranslationUnitAST &source);
|
---|
1557 | };
|
---|
1558 |
|
---|
1559 | template <class T> T* CreateNode(pool *p)
|
---|
1560 | {
|
---|
1561 | T* node = new (p->allocate(sizeof(T))) T;
|
---|
1562 | node->setNodeType(T::Type);
|
---|
1563 | node->_pool = p;
|
---|
1564 | return node;
|
---|
1565 | }
|
---|
1566 |
|
---|
1567 | template <int kind> ExpressionAST<kind> *CreateExpression(pool *p)
|
---|
1568 | {
|
---|
1569 | ExpressionAST<kind>* node = new (p->allocate(sizeof(ExpressionAST<kind>))) ExpressionAST<kind>;
|
---|
1570 | node->setNodeType(kind);
|
---|
1571 | node->_pool = p;
|
---|
1572 | return node;
|
---|
1573 | }
|
---|
1574 |
|
---|
1575 | /*
|
---|
1576 | template <typename T>
|
---|
1577 | inline List<T *> *snoc(List<T *> *e, T *d, pool *p)
|
---|
1578 | { if (!e) e = new (p->allocate(sizeof(List<T*>))) List<T *>(p); e->append(d); return e; }
|
---|
1579 | */
|
---|
1580 |
|
---|
1581 | //Workaround for ICE on MSVC, use macro instead of template.
|
---|
1582 | #define SNOC(ListType, ListValueType) \
|
---|
1583 | inline ListType *snoc(ListType *e, ListValueType *d, pool *p) \
|
---|
1584 | { if (!e) e = new (p->allocate(sizeof(ListType))) ListType(p); e->append(d); return e; }
|
---|
1585 |
|
---|
1586 | SNOC(List<AST *>, AST)
|
---|
1587 | SNOC(List<ClassOrNamespaceNameAST *>, ClassOrNamespaceNameAST)
|
---|
1588 | SNOC(List<BaseSpecifierAST *>, BaseSpecifierAST)
|
---|
1589 | SNOC(List<DeclarationAST *>, DeclarationAST)
|
---|
1590 | SNOC(List<EnumeratorAST *>, EnumeratorAST)
|
---|
1591 | SNOC(List<ParameterDeclarationAST *>, ParameterDeclarationAST)
|
---|
1592 | SNOC(List<InitDeclaratorAST *>, InitDeclaratorAST)
|
---|
1593 | SNOC(List<TemplateParameterAST *>, TemplateParameterAST)
|
---|
1594 | SNOC(List<StatementAST *>, StatementAST)
|
---|
1595 |
|
---|
1596 | QT_END_NAMESPACE
|
---|
1597 |
|
---|
1598 | #endif // AST_H
|
---|