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

« back to all changes in this revision

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

  • 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
#include "ast.h"
 
30
 
 
31
#include <qstringlist.h>
 
32
 
 
33
int AST::N = 0;
 
34
 
 
35
// ------------------------------------------------------------------------
 
36
AST::AST(int startToken, int count)
 
37
    : m_scope(0),
 
38
      m_startToken(startToken),
 
39
      m_endToken(startToken + count),
 
40
      m_parent(0),
 
41
      m_children(0)
 
42
{
 
43
    ++N;
 
44
}
 
45
 
 
46
void AST::setParent(AST *parent)
 
47
{
 
48
    if (m_parent)
 
49
        m_parent->removeChild(this);
 
50
 
 
51
    m_parent = parent;
 
52
 
 
53
    if (m_parent)
 
54
        m_parent->appendChild(this);
 
55
}
 
56
 
 
57
void AST::appendChild(AST *child)
 
58
{
 
59
    m_children = snoc(m_children, child, _pool);
 
60
}
 
61
 
 
62
void AST::removeChild(AST *child)
 
63
{
 
64
    fprintf(stderr, "AST::removeChild child: %p not implemented yet\n", child);
 
65
}
 
66
 
 
67
// ------------------------------------------------------------------------
 
68
NameAST::NameAST()
 
69
    : m_global(false), m_unqualifiedName(0), m_classOrNamespaceNameList(0)
 
70
{
 
71
}
 
72
 
 
73
void NameAST::setGlobal(bool b)
 
74
{
 
75
    m_global = b;
 
76
}
 
77
 
 
78
void NameAST::setUnqualifiedName(ClassOrNamespaceNameAST *unqualifiedName)
 
79
{
 
80
    m_unqualifiedName = unqualifiedName;
 
81
    if (m_unqualifiedName) m_unqualifiedName->setParent(this);
 
82
}
 
83
 
 
84
void NameAST::addClassOrNamespaceName(ClassOrNamespaceNameAST *classOrNamespaceName)
 
85
{
 
86
    if(!classOrNamespaceName)
 
87
        return;
 
88
 
 
89
    classOrNamespaceName->setParent(this);
 
90
    m_classOrNamespaceNameList = snoc(m_classOrNamespaceNameList, classOrNamespaceName, _pool);
 
91
}
 
92
 
 
93
// ------------------------------------------------------------------------
 
94
DeclarationAST::DeclarationAST()
 
95
{
 
96
}
 
97
 
 
98
// ------------------------------------------------------------------------
 
99
LinkageBodyAST::LinkageBodyAST()
 
100
    : m_declarationList(0)
 
101
{
 
102
}
 
103
 
 
104
void LinkageBodyAST::addDeclaration(DeclarationAST *ast)
 
105
{
 
106
    if(!ast)
 
107
        return;
 
108
 
 
109
    ast->setParent(this);
 
110
    m_declarationList = snoc(m_declarationList, ast, _pool);
 
111
}
 
112
 
 
113
// ------------------------------------------------------------------------
 
114
LinkageSpecificationAST::LinkageSpecificationAST()
 
115
    : m_externType(0),
 
116
      m_linkageBody(0),
 
117
      m_declaration(0)
 
118
{
 
119
}
 
120
 
 
121
void LinkageSpecificationAST::setExternType(AST *externType)
 
122
{
 
123
    m_externType = externType;
 
124
    if (m_externType) m_externType->setParent(this);
 
125
}
 
126
 
 
127
void LinkageSpecificationAST::setLinkageBody(LinkageBodyAST *linkageBody)
 
128
{
 
129
    m_linkageBody = linkageBody;
 
130
    if (m_linkageBody) m_linkageBody->setParent(this);
 
131
}
 
132
 
 
133
void LinkageSpecificationAST::setDeclaration(DeclarationAST *decl)
 
134
{
 
135
    m_declaration = decl;
 
136
    if (m_declaration) m_declaration->setParent(this);
 
137
}
 
138
 
 
139
// ------------------------------------------------------------------------
 
140
TranslationUnitAST::TranslationUnitAST()
 
141
    : m_declarationList(0)
 
142
{
 
143
    //kdDebug(9007) << "++ TranslationUnitAST::TranslationUnitAST()" << endl;
 
144
}
 
145
 
 
146
void TranslationUnitAST::addDeclaration(DeclarationAST *ast)
 
147
{
 
148
    if(!ast)
 
149
        return;
 
150
 
 
151
    ast->setParent(this);
 
152
    m_declarationList = snoc(m_declarationList, ast, _pool);
 
153
}
 
154
 
 
155
// ------------------------------------------------------------------------
 
156
NamespaceAST::NamespaceAST()
 
157
    : m_namespaceName(0),
 
158
      m_linkageBody(0)
 
159
{
 
160
}
 
161
 
 
162
void NamespaceAST::setNamespaceName(AST *namespaceName)
 
163
{
 
164
    m_namespaceName = namespaceName;
 
165
    if (m_namespaceName) m_namespaceName->setParent(this);
 
166
}
 
167
 
 
168
void NamespaceAST::setLinkageBody(LinkageBodyAST *linkageBody)
 
169
{
 
170
    m_linkageBody = linkageBody;
 
171
    if (m_linkageBody) m_linkageBody->setParent(this);
 
172
}
 
173
 
 
174
 
 
175
// ------------------------------------------------------------------------
 
176
NamespaceAliasAST::NamespaceAliasAST()
 
177
    : m_namespaceName(0),
 
178
      m_aliasName(0)
 
179
{
 
180
}
 
181
 
 
182
void NamespaceAliasAST::setNamespaceName(AST *namespaceName)
 
183
{
 
184
    m_namespaceName = namespaceName;
 
185
    if (m_namespaceName) m_namespaceName->setParent(this);
 
186
}
 
187
 
 
188
void NamespaceAliasAST::setAliasName(NameAST *name)
 
189
{
 
190
    m_aliasName = name;
 
191
    if (m_aliasName) m_aliasName->setParent(this);
 
192
}
 
193
 
 
194
// ------------------------------------------------------------------------
 
195
UsingAST::UsingAST()
 
196
    : m_typeName(0),
 
197
      m_name(0)
 
198
{
 
199
}
 
200
 
 
201
void UsingAST::setTypeName(AST *typeName)
 
202
{
 
203
    m_typeName = typeName;
 
204
    if (m_typeName) m_typeName->setParent(this);
 
205
}
 
206
 
 
207
void UsingAST::setName(NameAST *name)
 
208
{
 
209
    m_name = name;
 
210
    if (m_name) m_name->setParent(this);
 
211
}
 
212
 
 
213
// ------------------------------------------------------------------------
 
214
UsingDirectiveAST::UsingDirectiveAST()
 
215
    : m_name(0)
 
216
{
 
217
}
 
218
 
 
219
void UsingDirectiveAST::setName(NameAST *name)
 
220
{
 
221
    m_name = name;
 
222
    if (m_name) m_name->setParent(this);
 
223
}
 
224
 
 
225
TypedefAST::TypedefAST()
 
226
    : m_typeSpec(0),
 
227
      m_initDeclaratorList(0)
 
228
{
 
229
}
 
230
 
 
231
void TypeSpecifierAST::setName(NameAST *name)
 
232
{
 
233
    m_name = name;
 
234
    if (m_name) m_name->setParent(this);
 
235
}
 
236
 
 
237
void TypedefAST::setTypeSpec(TypeSpecifierAST *typeSpec)
 
238
{
 
239
    m_typeSpec = typeSpec;
 
240
    if (m_typeSpec) m_typeSpec->setParent(this);
 
241
}
 
242
 
 
243
void TypedefAST::setInitDeclaratorList(InitDeclaratorListAST *initDeclaratorList)
 
244
{
 
245
    m_initDeclaratorList = initDeclaratorList;
 
246
    if (m_initDeclaratorList) m_initDeclaratorList->setParent(this);
 
247
}
 
248
 
 
249
// ------------------------------------------------------------------------
 
250
TemplateArgumentListAST::TemplateArgumentListAST()
 
251
    : m_argumentList(0)
 
252
{
 
253
}
 
254
 
 
255
void TemplateArgumentListAST::addArgument(AST *arg)
 
256
{
 
257
    if(!arg)
 
258
        return;
 
259
 
 
260
    arg->setParent(this);
 
261
    m_argumentList = snoc(m_argumentList, arg, _pool);
 
262
}
 
263
 
 
264
// ------------------------------------------------------------------------
 
265
TemplateDeclarationAST::TemplateDeclarationAST()
 
266
    : m_exported(0),
 
267
      m_templateParameterList(0),
 
268
      m_declaration(0)
 
269
{
 
270
}
 
271
 
 
272
void TemplateDeclarationAST::setExported(AST *exported)
 
273
{
 
274
    m_exported = exported;
 
275
    if (m_exported) m_exported->setParent(this);
 
276
}
 
277
 
 
278
void TemplateDeclarationAST::setTemplateParameterList(TemplateParameterListAST *templateParameterList)
 
279
{
 
280
    m_templateParameterList = templateParameterList;
 
281
    if (m_templateParameterList) m_templateParameterList->setParent(this);
 
282
}
 
283
 
 
284
void TemplateDeclarationAST::setDeclaration(DeclarationAST *declaration)
 
285
{
 
286
    m_declaration = declaration;
 
287
    if (m_declaration) m_declaration->setParent(this);
 
288
}
 
289
 
 
290
// ------------------------------------------------------------------------
 
291
ClassOrNamespaceNameAST::ClassOrNamespaceNameAST()
 
292
    : m_name(0), m_templateArgumentList(0)
 
293
{
 
294
}
 
295
 
 
296
void ClassOrNamespaceNameAST::setName(AST *name)
 
297
{
 
298
    m_name = name;
 
299
    if (m_name) m_name->setParent(this);
 
300
}
 
301
 
 
302
void ClassOrNamespaceNameAST::setTemplateArgumentList(TemplateArgumentListAST *templateArgumentList)
 
303
{
 
304
    m_templateArgumentList = templateArgumentList;
 
305
    if (m_templateArgumentList) m_templateArgumentList->setParent(this);
 
306
}
 
307
 
 
308
// ------------------------------------------------------------------------
 
309
TypeSpecifierAST::TypeSpecifierAST()
 
310
    : m_name(0), m_cvQualify(0), m_cv2Qualify(0)
 
311
 
 
312
{
 
313
}
 
314
 
 
315
void TypeSpecifierAST::setCvQualify(AST *cvQualify)
 
316
{
 
317
    m_cvQualify = cvQualify;
 
318
    if (m_cvQualify) m_cvQualify->setParent(this);
 
319
}
 
320
 
 
321
void TypeSpecifierAST::setCv2Qualify(AST *cv2Qualify)
 
322
{
 
323
    m_cv2Qualify = cv2Qualify;
 
324
    if (m_cv2Qualify) m_cv2Qualify->setParent(this);
 
325
}
 
326
 
 
327
// ------------------------------------------------------------------------
 
328
ClassSpecifierAST::ClassSpecifierAST()
 
329
    : m_winDeclSpec(0),
 
330
      m_classKey(0),
 
331
      m_baseClause(0),
 
332
      m_declarationList(0)
 
333
{
 
334
}
 
335
 
 
336
void ClassSpecifierAST::setClassKey(AST *classKey)
 
337
{
 
338
    m_classKey = classKey;
 
339
    if (m_classKey) m_classKey->setParent(this);
 
340
}
 
341
 
 
342
void ClassSpecifierAST::addDeclaration(DeclarationAST *declaration)
 
343
{
 
344
    if(!declaration)
 
345
        return;
 
346
 
 
347
    declaration->setParent(this);
 
348
    m_declarationList = snoc(m_declarationList, declaration, _pool);
 
349
}
 
350
 
 
351
void ClassSpecifierAST::setBaseClause(BaseClauseAST *baseClause)
 
352
{
 
353
    m_baseClause = baseClause;
 
354
    if (m_baseClause) m_baseClause->setParent(this);
 
355
}
 
356
 
 
357
// ------------------------------------------------------------------------
 
358
EnumSpecifierAST::EnumSpecifierAST()
 
359
    : m_enumeratorList(0)
 
360
{
 
361
}
 
362
 
 
363
void EnumSpecifierAST::addEnumerator(EnumeratorAST *enumerator)
 
364
{
 
365
    if(!enumerator)
 
366
        return;
 
367
 
 
368
    enumerator->setParent(this);
 
369
    m_enumeratorList = snoc(m_enumeratorList, enumerator, _pool);
 
370
}
 
371
 
 
372
 
 
373
// ------------------------------------------------------------------------
 
374
ElaboratedTypeSpecifierAST::ElaboratedTypeSpecifierAST()
 
375
    : m_kind(0)
 
376
{
 
377
}
 
378
 
 
379
void ElaboratedTypeSpecifierAST::setKind(AST *kind)
 
380
{
 
381
    m_kind = kind;
 
382
    if (m_kind) m_kind->setParent(this);
 
383
}
 
384
 
 
385
// ------------------------------------------------------------------------
 
386
EnumeratorAST::EnumeratorAST()
 
387
    : m_id(0),
 
388
      m_expression(0)
 
389
{
 
390
}
 
391
 
 
392
void EnumeratorAST::setId(AST *id)
 
393
{
 
394
    m_id = id;
 
395
    if (m_id) m_id->setParent(this);
 
396
}
 
397
 
 
398
void EnumeratorAST::setExpression(AbstractExpressionAST *expression)
 
399
{
 
400
    m_expression = expression;
 
401
    if (m_expression) m_expression->setParent(this);
 
402
}
 
403
 
 
404
// ------------------------------------------------------------------------
 
405
BaseClauseAST::BaseClauseAST()
 
406
    : m_baseSpecifierList(0)
 
407
{
 
408
}
 
409
 
 
410
void BaseClauseAST::addBaseSpecifier(BaseSpecifierAST *baseSpecifier)
 
411
{
 
412
    if(!baseSpecifier)
 
413
        return;
 
414
 
 
415
    baseSpecifier->setParent(this);
 
416
    m_baseSpecifierList = snoc(m_baseSpecifierList, baseSpecifier, _pool);
 
417
}
 
418
 
 
419
// ------------------------------------------------------------------------
 
420
BaseSpecifierAST::BaseSpecifierAST()
 
421
    : m_isVirtual(0), m_access(0), m_name(0)
 
422
 
 
423
{
 
424
}
 
425
 
 
426
void BaseSpecifierAST::setIsVirtual(AST *isVirtual)
 
427
{
 
428
    m_isVirtual = isVirtual;
 
429
    if (m_isVirtual) m_isVirtual->setParent(this);
 
430
}
 
431
 
 
432
void BaseSpecifierAST::setAccess(AST *access)
 
433
{
 
434
    m_access = access;
 
435
    if (m_access) m_access->setParent(this);
 
436
}
 
437
 
 
438
void BaseSpecifierAST::setName(NameAST *name)
 
439
{
 
440
    m_name = name;
 
441
    if (m_name) m_name->setParent(this);
 
442
}
 
443
 
 
444
// ------------------------------------------------------------------------
 
445
SimpleDeclarationAST::SimpleDeclarationAST()
 
446
    : m_functionSpecifier(0),
 
447
      m_storageSpecifier(0),
 
448
      m_typeSpec(0),
 
449
      m_initDeclaratorList(0),
 
450
      m_winDeclSpec(0)
 
451
{
 
452
}
 
453
 
 
454
void SimpleDeclarationAST::setFunctionSpecifier(AST *functionSpecifier)
 
455
{
 
456
    m_functionSpecifier = functionSpecifier;
 
457
    if (m_functionSpecifier) m_functionSpecifier->setParent(this);
 
458
}
 
459
 
 
460
void SimpleDeclarationAST::setStorageSpecifier(AST *storageSpecifier)
 
461
{
 
462
    m_storageSpecifier = storageSpecifier;
 
463
    if (m_storageSpecifier) m_storageSpecifier->setParent(this);
 
464
}
 
465
 
 
466
void SimpleDeclarationAST::setTypeSpec(TypeSpecifierAST *typeSpec)
 
467
{
 
468
    m_typeSpec = typeSpec;
 
469
    if (m_typeSpec) m_typeSpec->setParent(this);
 
470
}
 
471
 
 
472
void SimpleDeclarationAST::setInitDeclaratorList(InitDeclaratorListAST *initDeclaratorList)
 
473
{
 
474
    m_initDeclaratorList = initDeclaratorList;
 
475
    if (m_initDeclaratorList) m_initDeclaratorList->setParent(this);
 
476
}
 
477
 
 
478
void SimpleDeclarationAST::setWinDeclSpec(AST *winDeclSpec)
 
479
{
 
480
    m_winDeclSpec = winDeclSpec;
 
481
    if (m_winDeclSpec) m_winDeclSpec->setParent(this);
 
482
}
 
483
 
 
484
// ------------------------------------------------------------------------
 
485
InitDeclaratorListAST::InitDeclaratorListAST()
 
486
    : m_initDeclaratorList(0)
 
487
{
 
488
}
 
489
 
 
490
void InitDeclaratorListAST::addInitDeclarator(InitDeclaratorAST *decl)
 
491
{
 
492
    if(!decl)
 
493
        return;
 
494
 
 
495
    decl->setParent(this);
 
496
    m_initDeclaratorList = snoc(m_initDeclaratorList, decl, _pool);
 
497
}
 
498
 
 
499
// ------------------------------------------------------------------------
 
500
DeclaratorAST::DeclaratorAST()
 
501
    : m_ptrOpList(0),
 
502
      m_subDeclarator(0),
 
503
      m_declaratorId(0),
 
504
      m_bitfieldInitialization(0),
 
505
      m_arrayDimensionList(0),
 
506
      m_parameterDeclarationClause(0),
 
507
      m_constant(0),
 
508
      m_exceptionSpecification(0)
 
509
{
 
510
}
 
511
 
 
512
void DeclaratorAST::setSubDeclarator(DeclaratorAST *subDeclarator)
 
513
{
 
514
    m_subDeclarator = subDeclarator;
 
515
    if (m_subDeclarator) m_subDeclarator->setParent(this);
 
516
}
 
517
 
 
518
void DeclaratorAST::setDeclaratorId(NameAST *declaratorId)
 
519
{
 
520
    m_declaratorId = declaratorId;
 
521
    if (m_declaratorId) m_declaratorId->setParent(this);
 
522
}
 
523
 
 
524
void DeclaratorAST::setBitfieldInitialization(AST *bitfieldInitialization)
 
525
{
 
526
    m_bitfieldInitialization = bitfieldInitialization;
 
527
    if (m_bitfieldInitialization) m_bitfieldInitialization->setParent(this);
 
528
}
 
529
 
 
530
void DeclaratorAST::addArrayDimension(AST *arrayDimension)
 
531
{
 
532
    if(!arrayDimension)
 
533
        return;
 
534
 
 
535
    arrayDimension->setParent(this);
 
536
    m_arrayDimensionList = snoc(m_arrayDimensionList, arrayDimension, _pool);
 
537
}
 
538
 
 
539
void DeclaratorAST::setParameterDeclarationClause(ParameterDeclarationClauseAST *parameterDeclarationClause)
 
540
{
 
541
    m_parameterDeclarationClause = parameterDeclarationClause;
 
542
    if (m_parameterDeclarationClause) m_parameterDeclarationClause->setParent(this);
 
543
}
 
544
 
 
545
void DeclaratorAST::setConstant(AST *constant)
 
546
{
 
547
    m_constant = constant;
 
548
    if (m_constant) m_constant->setParent(this);
 
549
}
 
550
 
 
551
void DeclaratorAST::setExceptionSpecification(AST *exceptionSpecification)
 
552
{
 
553
    m_exceptionSpecification = exceptionSpecification;
 
554
    if (m_exceptionSpecification) m_exceptionSpecification->setParent(this);
 
555
}
 
556
 
 
557
void DeclaratorAST::addPtrOp(AST *ptrOp)
 
558
{
 
559
    if(!ptrOp)
 
560
        return;
 
561
 
 
562
    ptrOp->setParent(this);
 
563
    m_ptrOpList = snoc(m_ptrOpList, ptrOp, _pool);
 
564
}
 
565
 
 
566
// --------------------------------------------------------------------------
 
567
InitDeclaratorAST::InitDeclaratorAST()
 
568
    : m_declarator(0),
 
569
      m_initializer(0)
 
570
{
 
571
}
 
572
 
 
573
void InitDeclaratorAST::setDeclarator(DeclaratorAST *declarator)
 
574
{
 
575
    m_declarator = declarator;
 
576
    if (m_declarator) m_declarator->setParent(this);
 
577
}
 
578
 
 
579
void InitDeclaratorAST::setInitializer(AST *initializer)
 
580
{
 
581
    m_initializer = initializer;
 
582
    if (m_initializer) m_initializer->setParent(this);
 
583
}
 
584
 
 
585
// --------------------------------------------------------------------------
 
586
FunctionDefinitionAST::FunctionDefinitionAST()
 
587
    : m_functionSpecifier(0),
 
588
      m_storageSpecifier(0),
 
589
      m_typeSpec(0),
 
590
      m_initDeclarator(0),
 
591
      m_functionBody(0),
 
592
      m_winDeclSpec(0)
 
593
{
 
594
}
 
595
 
 
596
void FunctionDefinitionAST::setFunctionSpecifier(AST *functionSpecifier)
 
597
{
 
598
    m_functionSpecifier = functionSpecifier;
 
599
    if (m_functionSpecifier) m_functionSpecifier->setParent(this);
 
600
}
 
601
 
 
602
void FunctionDefinitionAST::setStorageSpecifier(AST *storageSpecifier)
 
603
{
 
604
    m_storageSpecifier = storageSpecifier;
 
605
    if (m_storageSpecifier) m_storageSpecifier->setParent(this);
 
606
}
 
607
 
 
608
void FunctionDefinitionAST::setTypeSpec(TypeSpecifierAST *typeSpec)
 
609
{
 
610
    m_typeSpec = typeSpec;
 
611
    if (m_typeSpec) m_typeSpec->setParent(this);
 
612
}
 
613
 
 
614
void FunctionDefinitionAST::setInitDeclarator(InitDeclaratorAST *initDeclarator)
 
615
{
 
616
    m_initDeclarator = initDeclarator;
 
617
    if (m_initDeclarator) m_initDeclarator->setParent(this);
 
618
}
 
619
 
 
620
void FunctionDefinitionAST::setFunctionBody(StatementListAST *functionBody)
 
621
{
 
622
    m_functionBody = functionBody;
 
623
    if (m_functionBody) m_functionBody->setParent(this);
 
624
}
 
625
 
 
626
void FunctionDefinitionAST::setWinDeclSpec(AST *winDeclSpec)
 
627
{
 
628
    m_winDeclSpec = winDeclSpec;
 
629
    if (m_winDeclSpec) m_winDeclSpec->setParent(this);
 
630
}
 
631
 
 
632
// --------------------------------------------------------------------------
 
633
StatementListAST::StatementListAST()
 
634
    : m_statementList(0)
 
635
{
 
636
}
 
637
 
 
638
void StatementListAST::addStatement(StatementAST *statement)
 
639
{
 
640
    if(!statement)
 
641
        return;
 
642
 
 
643
    statement->setParent(this);
 
644
    m_statementList = snoc(m_statementList, statement, _pool);
 
645
}
 
646
 
 
647
// --------------------------------------------------------------------------
 
648
IfStatementAST::IfStatementAST()
 
649
    : m_condition(0),
 
650
      m_statement(0),
 
651
      m_elseStatement(0)
 
652
{
 
653
}
 
654
 
 
655
void IfStatementAST::setCondition(ConditionAST *condition)
 
656
{
 
657
    m_condition = condition;
 
658
    if (m_condition) m_condition->setParent(this);
 
659
}
 
660
 
 
661
void IfStatementAST::setStatement(StatementAST *statement)
 
662
{
 
663
    m_statement = statement;
 
664
    if (m_statement) m_statement->setParent(this);
 
665
}
 
666
 
 
667
void IfStatementAST::setElseStatement(StatementAST *elseStatement)
 
668
{
 
669
    m_elseStatement = elseStatement;
 
670
    if (m_elseStatement) m_elseStatement->setParent(this);
 
671
}
 
672
 
 
673
// --------------------------------------------------------------------------
 
674
WhileStatementAST::WhileStatementAST()
 
675
    : m_condition(0),
 
676
      m_statement(0)
 
677
{
 
678
}
 
679
 
 
680
void WhileStatementAST::setCondition(ConditionAST *condition)
 
681
{
 
682
    m_condition = condition;
 
683
    if (m_condition) m_condition->setParent(this);
 
684
}
 
685
 
 
686
void WhileStatementAST::setStatement(StatementAST *statement)
 
687
{
 
688
    m_statement = statement;
 
689
    if (m_statement) m_statement->setParent(this);
 
690
}
 
691
 
 
692
// --------------------------------------------------------------------------
 
693
DoStatementAST::DoStatementAST()
 
694
    : m_condition(0),
 
695
      m_statement(0)
 
696
{
 
697
}
 
698
 
 
699
void DoStatementAST::setCondition(ConditionAST *condition)
 
700
{
 
701
    m_condition = condition;
 
702
    if (m_condition) m_condition->setParent(this);
 
703
}
 
704
 
 
705
void DoStatementAST::setStatement(StatementAST *statement)
 
706
{
 
707
    m_statement = statement;
 
708
    if (m_statement) m_statement->setParent(this);
 
709
}
 
710
 
 
711
// --------------------------------------------------------------------------
 
712
ForStatementAST::ForStatementAST()
 
713
    : m_condition(0),
 
714
      m_initStatement(0),
 
715
      m_statement(0),
 
716
      m_expression(0)
 
717
{
 
718
}
 
719
 
 
720
void ForStatementAST::setCondition(ConditionAST *condition)
 
721
{
 
722
    m_condition = condition;
 
723
    if (m_condition) m_condition->setParent(this);
 
724
}
 
725
 
 
726
void ForStatementAST::setExpression(AbstractExpressionAST *expression)
 
727
{
 
728
    m_expression = expression;
 
729
    if (m_expression) m_expression->setParent(this);
 
730
}
 
731
 
 
732
void ForStatementAST::setStatement(StatementAST *statement)
 
733
{
 
734
    m_statement = statement;
 
735
    if (m_statement) m_statement->setParent(this);
 
736
}
 
737
 
 
738
void ForStatementAST::setInitStatement(StatementAST *initStatement)
 
739
{
 
740
    m_initStatement = initStatement;
 
741
    if (m_initStatement) m_initStatement->setParent(this);
 
742
}
 
743
 
 
744
// --------------------------------------------------------------------------
 
745
SwitchStatementAST::SwitchStatementAST()
 
746
    : m_condition(0),
 
747
      m_statement(0)
 
748
{
 
749
}
 
750
 
 
751
void SwitchStatementAST::setCondition(ConditionAST *condition)
 
752
{
 
753
    m_condition = condition;
 
754
    if (m_condition) m_condition->setParent(this);
 
755
}
 
756
 
 
757
void SwitchStatementAST::setStatement(StatementAST *statement)
 
758
{
 
759
    m_statement = statement;
 
760
    if (m_statement) m_statement->setParent(this);
 
761
}
 
762
 
 
763
// --------------------------------------------------------------------------
 
764
DeclarationStatementAST::DeclarationStatementAST()
 
765
    : m_declaration(0)
 
766
{
 
767
}
 
768
 
 
769
void DeclarationStatementAST::setDeclaration(DeclarationAST *declaration)
 
770
{
 
771
    m_declaration = declaration;
 
772
    if (m_declaration) m_declaration->setParent(this);
 
773
}
 
774
 
 
775
// --------------------------------------------------------------------------
 
776
ExpressionStatementAST::ExpressionStatementAST()
 
777
    : m_expression(0)
 
778
{
 
779
}
 
780
 
 
781
void ExpressionStatementAST::setExpression(AbstractExpressionAST *expression)
 
782
{
 
783
    m_expression = expression;
 
784
    if (m_expression) m_expression->setParent(this);
 
785
}
 
786
 
 
787
 
 
788
// --------------------------------------------------------------------------
 
789
ParameterDeclarationAST::ParameterDeclarationAST()
 
790
    : m_typeSpec(0),
 
791
      m_declarator(0),
 
792
      m_expression(0)
 
793
{
 
794
}
 
795
 
 
796
void ParameterDeclarationAST::setTypeSpec(TypeSpecifierAST *typeSpec)
 
797
{
 
798
    m_typeSpec = typeSpec;
 
799
    if (m_typeSpec) m_typeSpec->setParent(this);
 
800
}
 
801
 
 
802
void ParameterDeclarationAST::setDeclarator(DeclaratorAST *declarator)
 
803
{
 
804
    m_declarator = declarator;
 
805
    if (m_declarator) m_declarator->setParent(this);
 
806
}
 
807
 
 
808
void ParameterDeclarationAST::setExpression(AbstractExpressionAST *expression)
 
809
{
 
810
    m_expression = expression;
 
811
    if (m_expression) m_expression->setParent(this);
 
812
}
 
813
 
 
814
// --------------------------------------------------------------------------
 
815
ParameterDeclarationListAST::ParameterDeclarationListAST()
 
816
    : m_parameterList(0)
 
817
{
 
818
}
 
819
 
 
820
void ParameterDeclarationListAST::addParameter(ParameterDeclarationAST *parameter)
 
821
{
 
822
    if(!parameter)
 
823
        return;
 
824
 
 
825
    parameter->setParent(this);
 
826
    m_parameterList = snoc(m_parameterList, parameter, _pool);
 
827
}
 
828
 
 
829
// --------------------------------------------------------------------------
 
830
ParameterDeclarationClauseAST::ParameterDeclarationClauseAST()
 
831
    : m_parameterDeclarationList(0),
 
832
      m_ellipsis(0)
 
833
{
 
834
}
 
835
 
 
836
void ParameterDeclarationClauseAST::setParameterDeclarationList(ParameterDeclarationListAST *parameterDeclarationList)
 
837
{
 
838
    m_parameterDeclarationList = parameterDeclarationList;
 
839
    if (m_parameterDeclarationList) m_parameterDeclarationList->setParent(this);
 
840
}
 
841
 
 
842
void ParameterDeclarationClauseAST::setEllipsis(AST *ellipsis)
 
843
{
 
844
    m_ellipsis = ellipsis;
 
845
    if (m_ellipsis) m_ellipsis->setParent(this);
 
846
}
 
847
 
 
848
// --------------------------------------------------------------------------
 
849
AccessDeclarationAST::AccessDeclarationAST()
 
850
    : m_accessList(0)
 
851
{
 
852
}
 
853
 
 
854
void AccessDeclarationAST::addAccess(AST *access)
 
855
{
 
856
    if(!access)
 
857
        return;
 
858
 
 
859
    access->setParent(this);
 
860
    m_accessList = snoc(m_accessList, access, _pool);
 
861
}
 
862
 
 
863
// --------------------------------------------------------------------------
 
864
TypeParameterAST::TypeParameterAST()
 
865
    : m_kind(0), m_templateParameterList(0),
 
866
      m_name(0), m_typeId(0)
 
867
 
 
868
{
 
869
}
 
870
 
 
871
void TypeParameterAST::setKind(AST *kind)
 
872
{
 
873
    m_kind = kind;
 
874
}
 
875
 
 
876
void TypeParameterAST::setTemplateParameterList(TemplateParameterListAST *templateParameterList)
 
877
{
 
878
    m_templateParameterList = templateParameterList;
 
879
    if (m_templateParameterList) m_templateParameterList->setParent(this);
 
880
}
 
881
 
 
882
void TypeParameterAST::setName(NameAST *name)
 
883
{
 
884
    m_name = name;
 
885
    if (m_name) m_name->setParent(this);
 
886
}
 
887
 
 
888
void TypeParameterAST::setTypeId(AST *typeId)
 
889
{
 
890
    m_typeId = typeId;
 
891
    if (m_typeId) m_typeId->setParent(this);
 
892
}
 
893
 
 
894
// --------------------------------------------------------------------------
 
895
TemplateParameterAST::TemplateParameterAST()
 
896
    : m_typeParameter(0),
 
897
      m_typeValueParameter(0)
 
898
{
 
899
}
 
900
 
 
901
void TemplateParameterAST::setTypeParameter(TypeParameterAST *typeParameter)
 
902
{
 
903
    m_typeParameter = typeParameter;
 
904
    if (m_typeParameter) m_typeParameter->setParent(this);
 
905
}
 
906
 
 
907
void TemplateParameterAST::setTypeValueParameter(ParameterDeclarationAST *typeValueParameter)
 
908
{
 
909
    m_typeValueParameter = typeValueParameter;
 
910
    if (m_typeValueParameter) m_typeValueParameter->setParent(this);
 
911
}
 
912
 
 
913
// --------------------------------------------------------------------------
 
914
TemplateParameterListAST::TemplateParameterListAST()
 
915
    : m_templateParameterList(0)
 
916
{
 
917
}
 
918
 
 
919
void TemplateParameterListAST::addTemplateParameter(TemplateParameterAST *templateParameter)
 
920
{
 
921
    if(!templateParameter)
 
922
        return;
 
923
 
 
924
    templateParameter->setParent(this);
 
925
    m_templateParameterList = snoc(m_templateParameterList, templateParameter, _pool);
 
926
}
 
927
 
 
928
// --------------------------------------------------------------------------
 
929
ConditionAST::ConditionAST()
 
930
    : m_typeSpec(0),
 
931
      m_declarator(0),
 
932
      m_expression(0)
 
933
{
 
934
}
 
935
 
 
936
void ConditionAST::setTypeSpec(TypeSpecifierAST *typeSpec)
 
937
{
 
938
    m_typeSpec = typeSpec;
 
939
    if (m_typeSpec) m_typeSpec->setParent(this);
 
940
}
 
941
 
 
942
void ConditionAST::setDeclarator(DeclaratorAST *declarator)
 
943
{
 
944
    m_declarator = declarator;
 
945
    if (m_declarator) m_declarator->setParent(this);
 
946
}
 
947
 
 
948
void ConditionAST::setExpression(AbstractExpressionAST *expression)
 
949
{
 
950
    m_expression = expression;
 
951
    if (m_expression) m_expression->setParent(this);
 
952
}
 
953
 
 
954
void ClassSpecifierAST::setWinDeclSpec(AST *winDeclSpec)
 
955
{
 
956
    m_winDeclSpec = winDeclSpec;
 
957
    if (m_winDeclSpec) m_winDeclSpec->setParent(this);
 
958
}
 
959
 
 
960
// --------------------------------------------------------------------------
 
961
ReturnStatementAST::ReturnStatementAST()
 
962
    : m_expression(0)
 
963
{
 
964
}
 
965
 
 
966
void ReturnStatementAST::setExpression(AbstractExpressionAST *expression)
 
967
{
 
968
    m_expression = expression;
 
969
    if (m_expression) m_expression->setParent(this);
 
970
}
 
971
 
 
972
// --------------------------------------------------------------------------
 
973
BinaryExpressionAST::BinaryExpressionAST()
 
974
    : m_op(0), m_left(0), m_right(0)
 
975
{
 
976
}
 
977
 
 
978
void BinaryExpressionAST::setOp(AST *op)
 
979
{
 
980
    m_op = op;
 
981
    if (m_op)
 
982
        m_op->setParent(this);
 
983
}
 
984
 
 
985
void BinaryExpressionAST::setLeftExpression(AbstractExpressionAST *left)
 
986
{
 
987
    m_left = left;
 
988
    if (m_left)
 
989
        m_left->setParent(this);
 
990
}
 
991
 
 
992
void BinaryExpressionAST::setRightExpression(AbstractExpressionAST *right)
 
993
{
 
994
    m_right = right;
 
995
    if (m_right)
 
996
        m_right->setParent(this);
 
997
}
 
998
 
 
999
// --------------------------------------------------------------------------
 
1000
ConditionalExpressionAST::ConditionalExpressionAST()
 
1001
    : m_condition(0), m_left(0), m_right(0)
 
1002
{
 
1003
}
 
1004
 
 
1005
void ConditionalExpressionAST::setCondition(AbstractExpressionAST *condition)
 
1006
{
 
1007
    m_condition = condition;
 
1008
    if (m_condition)
 
1009
        m_condition->setParent(this);
 
1010
}
 
1011
 
 
1012
void ConditionalExpressionAST::setLeftExpression(AbstractExpressionAST *left)
 
1013
{
 
1014
    m_left = left;
 
1015
    if (m_left)
 
1016
        m_left->setParent(this);
 
1017
}
 
1018
 
 
1019
void ConditionalExpressionAST::setRightExpression(AbstractExpressionAST *right)
 
1020
{
 
1021
    m_right = right;
 
1022
    if (m_right)
 
1023
        m_right->setParent(this);
 
1024
}
 
1025
 
 
1026
// --------------------------------------------------------------------------
 
1027
CppCastExpressionAST::CppCastExpressionAST()
 
1028
    : m_castOp(0), m_typeId(0), m_expression(0)
 
1029
{
 
1030
}
 
1031
 
 
1032
void CppCastExpressionAST::setCastOp(AST *castOp)
 
1033
{
 
1034
    m_castOp = castOp;
 
1035
    if (m_castOp)
 
1036
        m_castOp->setParent(this);
 
1037
}
 
1038
 
 
1039
void CppCastExpressionAST::setTypeId(AST *typeId)
 
1040
{
 
1041
    m_typeId = typeId;
 
1042
    if (m_typeId)
 
1043
        m_typeId->setParent(this);
 
1044
}
 
1045
 
 
1046
void CppCastExpressionAST::setExpression(AbstractExpressionAST *expression)
 
1047
{
 
1048
    m_expression = expression;
 
1049
    if (m_expression)
 
1050
        m_expression->setParent(this);
 
1051
}
 
1052
 
 
1053
// --------------------------------------------------------------------------
 
1054
SubscriptingAST::SubscriptingAST()
 
1055
    : m_expression(0), m_subscript(0)
 
1056
{
 
1057
}
 
1058
 
 
1059
void SubscriptingAST::setSubscript(AbstractExpressionAST *subscript)
 
1060
{
 
1061
    m_subscript = subscript;
 
1062
    if (m_subscript)
 
1063
        m_subscript->setParent(this);
 
1064
}
 
1065
 
 
1066
void SubscriptingAST::setExpression(AbstractExpressionAST *expression)
 
1067
{
 
1068
    m_expression = expression;
 
1069
    if (m_expression)
 
1070
        m_expression->setParent(this);
 
1071
}
 
1072
 
 
1073
// --------------------------------------------------------------------------
 
1074
FunctionCallAST::FunctionCallAST()
 
1075
    : m_expression(0), m_arguments(0)
 
1076
{
 
1077
}
 
1078
 
 
1079
void FunctionCallAST::setExpression(AbstractExpressionAST *expression)
 
1080
{
 
1081
    m_expression = expression;
 
1082
    if (m_expression)
 
1083
        m_expression->setParent(this);
 
1084
}
 
1085
 
 
1086
void FunctionCallAST::setArguments(AbstractExpressionAST *arguments)
 
1087
{
 
1088
    m_arguments = arguments;
 
1089
    if (m_arguments)
 
1090
        m_arguments->setParent(this);
 
1091
}
 
1092
 
 
1093
// --------------------------------------------------------------------------
 
1094
ExplicitTypeConversionAST::ExplicitTypeConversionAST()
 
1095
{
 
1096
}
 
1097
 
 
1098
// --------------------------------------------------------------------------
 
1099
PseudoDestructorCallAST::PseudoDestructorCallAST()
 
1100
{
 
1101
}
 
1102
 
 
1103
// --------------------------------------------------------------------------
 
1104
ClassMemberAccessAST::ClassMemberAccessAST()
 
1105
    : m_op(0), m_expression(0), m_templ(0), m_name(0)
 
1106
{
 
1107
}
 
1108
 
 
1109
void ClassMemberAccessAST::setOp(AST *op)
 
1110
{
 
1111
    m_op = op;
 
1112
    if (m_op)
 
1113
        m_op->setParent(this);
 
1114
}
 
1115
 
 
1116
void ClassMemberAccessAST::setExpression(AbstractExpressionAST *expression)
 
1117
{
 
1118
    m_expression = expression;
 
1119
    if (m_expression)
 
1120
        m_expression->setParent(this);
 
1121
}
 
1122
 
 
1123
void ClassMemberAccessAST::setName(NameAST *name)
 
1124
{
 
1125
    m_name = name;
 
1126
    if (m_name)
 
1127
        m_name->setParent(this);
 
1128
}
 
1129
 
 
1130
// --------------------------------------------------------------------------
 
1131
IncrDecrAST::IncrDecrAST()
 
1132
    : m_op(0), m_expression(0)
 
1133
{
 
1134
}
 
1135
 
 
1136
void IncrDecrAST::setOp(AST *op)
 
1137
{
 
1138
    m_op = op;
 
1139
    if (m_op)
 
1140
        m_op->setParent(this);
 
1141
}
 
1142
 
 
1143
void IncrDecrAST::setExpression(AbstractExpressionAST *expression)
 
1144
{
 
1145
    m_expression = expression;
 
1146
    if (m_expression)
 
1147
        m_expression->setParent(this);
 
1148
}
 
1149
 
 
1150
// --------------------------------------------------------------------------
 
1151
TypeIdentificationAST::TypeIdentificationAST()
 
1152
{
 
1153
}
 
1154
 
 
1155
// --------------------------------------------------------------------------
 
1156
TypeIdAST::TypeIdAST()
 
1157
    : m_typeSpecifier(0), m_declarator(0)
 
1158
{
 
1159
}
 
1160
 
 
1161
void TypeIdAST::setTypeSpecifier(TypeSpecifierAST *typeSpecifier)
 
1162
{
 
1163
    m_typeSpecifier = typeSpecifier;
 
1164
    if (m_typeSpecifier)
 
1165
        m_typeSpecifier->setParent(this);
 
1166
}
 
1167
 
 
1168
void TypeIdAST::setDeclarator(DeclaratorAST *declarator)
 
1169
{
 
1170
    m_declarator = declarator;
 
1171
    if (m_declarator)
 
1172
        m_declarator->setParent(this);
 
1173
}
 
1174
 
 
1175
// --------------------------------------------------------------------------
 
1176
AbstractExpressionAST::AbstractExpressionAST()
 
1177
{
 
1178
    m_symbol = 0;
 
1179
}
 
1180