~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/porting/src/ast.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

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