~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/cppparser/ast.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of KDevelop
2
 
    Copyright (C) 2002,2003 Roberto Raggi <roberto@kdevelop.org>
3
 
 
4
 
    This library is free software; you can redistribute it and/or
5
 
    modify it under the terms of the GNU Library General Public
6
 
    License as published by the Free Software Foundation; either
7
 
    version 2 of the License, or (at your option) any later version.
8
 
 
9
 
    This library is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
    Library General Public License for more details.
13
 
 
14
 
    You should have received a copy of the GNU Library General Public License
15
 
    along with this library; see the file COPYING.LIB.  If not, write to
16
 
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
    Boston, MA 02111-1307, USA.
18
 
*/
19
 
 
20
 
#include "ast.h"
21
 
#include <qstringlist.h>
22
 
#include <kdebug.h>
23
 
 
24
 
QString nodeTypeToString( int type )
25
 
{
26
 
    switch( type )
27
 
    {
28
 
    case NodeType_Generic:
29
 
        return "Generic";
30
 
    case NodeType_TemplateArgumentList:
31
 
        return "TemplateArgumentList";
32
 
    case NodeType_ClassOrNamespaceName:
33
 
        return "ClassOrNamespaceName";
34
 
    case NodeType_Name:
35
 
        return "Name";
36
 
    case NodeType_Declaration:
37
 
        return "Declaration";
38
 
    case NodeType_TypeSpecifier:
39
 
        return "TypeSpecifier";
40
 
    case NodeType_BaseSpecifier:
41
 
        return "BaseSpecifier";
42
 
    case NodeType_BaseClause:
43
 
        return "BaseClause";
44
 
    case NodeType_ClassSpecifier:
45
 
        return "ClassSpecifier";
46
 
    case NodeType_Enumerator:
47
 
        return "Enumerator";
48
 
    case NodeType_EnumSpecifier:
49
 
        return "EnumSpecifier";
50
 
    case NodeType_ElaboratedTypeSpecifier:
51
 
        return "ElaboratedTypeSpecifier";
52
 
    case NodeType_LinkageBody:
53
 
        return "LinkageBody";
54
 
    case NodeType_LinkageSpecification:
55
 
        return "LinkageSpecification";
56
 
    case NodeType_Namespace:
57
 
        return "Namespace";
58
 
    case NodeType_NamespaceAlias:
59
 
        return "NamespaceAlias";
60
 
    case NodeType_Using:
61
 
        return "Using";
62
 
    case NodeType_UsingDirective:
63
 
        return "UsingDirective";
64
 
    case NodeType_InitDeclaratorList:
65
 
        return "InitDeclaratorList";
66
 
    case NodeType_Typedef:
67
 
        return "Typedef";
68
 
    case NodeType_Declarator:
69
 
        return "Declarator";
70
 
    case NodeType_InitDeclarator:
71
 
        return "InitDeclarator";
72
 
    case NodeType_TemplateDeclaration:
73
 
        return "TemplateDeclaration";
74
 
    case NodeType_SimpleDeclaration:
75
 
        return "SimpleDeclaration";
76
 
    case NodeType_Statement:
77
 
        return "Statement";
78
 
    case NodeType_IfStatement:
79
 
        return "IfStatement";
80
 
    case NodeType_WhileStatement:
81
 
        return "WhileStatement";
82
 
    case NodeType_DoStatement:
83
 
        return "DoStatement";
84
 
    case NodeType_ForStatement:
85
 
        return "ForStatement";
86
 
    case NodeType_ForEachStatement: // qt4 [erbsland]
87
 
        return "ForEachStatement";
88
 
    case NodeType_SwitchStatement:
89
 
        return "SwitchStatement";
90
 
    case NodeType_CatchStatement:
91
 
        return "CatchStatement";
92
 
    case NodeType_CatchStatementList:
93
 
        return "CatchStatementList";
94
 
    case NodeType_TryBlockStatement:
95
 
        return "TryBlockStatement";
96
 
    case NodeType_DeclarationStatement:
97
 
        return "DeclarationStatement";
98
 
    case NodeType_StatementList:
99
 
        return "StatementList";
100
 
    case NodeType_TranslationUnit:
101
 
        return "TranslationUnit";
102
 
    case NodeType_FunctionDefinition:
103
 
        return "FunctionDefinition";
104
 
    case NodeType_ExpressionStatement:
105
 
        return "ExpressionStatement";
106
 
    case NodeType_ParameterDeclaration:
107
 
        return "ParameterDeclaration";
108
 
    case NodeType_ParameterDeclarationList:
109
 
        return "ParameterDeclarationList";
110
 
    case NodeType_ParameterDeclarationClause:
111
 
        return "ParameterDeclarationClause";
112
 
    case NodeType_Group:
113
 
        return "Group";
114
 
    case NodeType_AccessDeclaration:
115
 
        return "AccessDeclaration";
116
 
    case NodeType_TypeParameter:
117
 
        return "TypeParameter";
118
 
    case NodeType_TemplateParameter:
119
 
        return "TemplateParameter";
120
 
    case NodeType_TemplateParameterList:
121
 
        return "TemplateParameterList";
122
 
    case NodeType_Condition:
123
 
        return "Condition";
124
 
    case NodeType_Custom:
125
 
        return "Custom";
126
 
    }
127
 
 
128
 
    return QString::null;
129
 
}
130
 
 
131
 
 
132
 
// ------------------------------------------------------------------------
133
 
AST::AST()
134
 
    : m_nodeType( NodeType_Generic ), m_parent( 0 ),
135
 
      m_startLine( 0 ), m_startColumn( 0 ),
136
 
      m_endLine( 0 ), m_endColumn( 0 )
137
 
{
138
 
#ifndef CPPPARSER_NO_CHILDREN
139
 
    m_children.setAutoDelete( false );
140
 
#endif
141
 
}
142
 
 
143
 
AST::~AST()
144
 
{
145
 
#ifndef CPPPARSER_NO_CHILDREN
146
 
    if( m_parent )
147
 
        m_parent->removeChild( this );
148
 
#endif
149
 
}
150
 
 
151
 
void AST::setStartPosition( int line, int col )
152
 
{
153
 
   m_startLine = line;
154
 
   m_startColumn = col;
155
 
}
156
 
 
157
 
void AST::getStartPosition( int* line, int* col ) const
158
 
{
159
 
    if( line )
160
 
        *line = m_startLine;
161
 
 
162
 
    if( col )
163
 
        * col = m_startColumn;
164
 
}
165
 
 
166
 
void AST::setEndPosition( int line, int col )
167
 
{
168
 
   m_endLine = line;
169
 
   m_endColumn = col;
170
 
}
171
 
 
172
 
void AST::getEndPosition( int* line, int* col ) const
173
 
{
174
 
    if( line )
175
 
        *line = m_endLine;
176
 
 
177
 
    if( col )
178
 
        * col = m_endColumn;
179
 
}
180
 
 
181
 
void AST::setParent( AST* parent )
182
 
{
183
 
#ifndef CPPPARSER_NO_CHILDREN
184
 
    if( m_parent )
185
 
        m_parent->removeChild( this );
186
 
#endif
187
 
 
188
 
    m_parent = parent;
189
 
 
190
 
#ifndef CPPPARSER_NO_CHILDREN
191
 
    if( m_parent )
192
 
        m_parent->appendChild( this );
193
 
#endif
194
 
}
195
 
 
196
 
#ifndef CPPPARSER_NO_CHILDREN
197
 
void AST::appendChild( AST* child )
198
 
{
199
 
    m_children.append( child );
200
 
}
201
 
 
202
 
void AST::removeChild( AST* child )
203
 
{
204
 
    m_children.remove( child );
205
 
}
206
 
#endif
207
 
 
208
 
// ------------------------------------------------------------------------
209
 
NameAST::NameAST()
210
 
    : m_global( false )
211
 
{
212
 
    m_classOrNamespaceNameList.setAutoDelete( true );
213
 
}
214
 
 
215
 
void NameAST::setGlobal( bool b )
216
 
{
217
 
    m_global = b;
218
 
}
219
 
 
220
 
void NameAST::setUnqualifiedName( ClassOrNamespaceNameAST::Node& unqualifiedName )
221
 
{
222
 
    m_unqualifiedName = unqualifiedName;
223
 
    if( m_unqualifiedName.get() ) m_unqualifiedName->setParent( this );
224
 
}
225
 
 
226
 
void NameAST::addClassOrNamespaceName( ClassOrNamespaceNameAST::Node& classOrNamespaceName )
227
 
{
228
 
    if( !classOrNamespaceName.get() )
229
 
        return;
230
 
 
231
 
    classOrNamespaceName->setParent( this );
232
 
    m_classOrNamespaceNameList.append( classOrNamespaceName.release() );
233
 
}
234
 
 
235
 
QString NameAST::text() const
236
 
{
237
 
    if( !m_unqualifiedName.get() )
238
 
        return QString::null;
239
 
 
240
 
    QString str;
241
 
 
242
 
    if( m_global )
243
 
        str += "::";
244
 
 
245
 
    QStringList l;
246
 
    QPtrListIterator<ClassOrNamespaceNameAST> it( m_classOrNamespaceNameList );
247
 
    while( it.current() ){
248
 
        str += it.current()->text() + "::";
249
 
        ++it;
250
 
    }
251
 
 
252
 
    if( m_unqualifiedName.get() )
253
 
        str += m_unqualifiedName->text();
254
 
 
255
 
    return str;
256
 
}
257
 
 
258
 
// ------------------------------------------------------------------------
259
 
DeclarationAST::DeclarationAST()
260
 
{
261
 
}
262
 
 
263
 
// ------------------------------------------------------------------------
264
 
LinkageBodyAST::LinkageBodyAST()
265
 
{
266
 
    m_declarationList.setAutoDelete( true );
267
 
}
268
 
 
269
 
void LinkageBodyAST::addDeclaration( DeclarationAST::Node& ast )
270
 
{
271
 
    if( !ast.get() )
272
 
        return;
273
 
 
274
 
    ast->setParent( this );
275
 
    m_declarationList.append( ast.release() );
276
 
}
277
 
 
278
 
// ------------------------------------------------------------------------
279
 
LinkageSpecificationAST::LinkageSpecificationAST()
280
 
{
281
 
}
282
 
 
283
 
void LinkageSpecificationAST::setExternType( AST::Node& externType )
284
 
{
285
 
    m_externType = externType;
286
 
    if( m_externType.get() ) m_externType->setParent( this );
287
 
}
288
 
 
289
 
void LinkageSpecificationAST::setLinkageBody( LinkageBodyAST::Node& linkageBody )
290
 
{
291
 
    m_linkageBody = linkageBody;
292
 
    if( m_linkageBody.get() ) m_linkageBody->setParent( this );
293
 
}
294
 
 
295
 
void LinkageSpecificationAST::setDeclaration( DeclarationAST::Node& decl )
296
 
{
297
 
    m_declaration = decl;
298
 
    if( m_declaration.get() ) m_declaration->setParent( this );
299
 
}
300
 
 
301
 
// ------------------------------------------------------------------------
302
 
TranslationUnitAST::TranslationUnitAST()
303
 
{
304
 
    ////kdDebug(9007) << "++ TranslationUnitAST::TranslationUnitAST()" << endl;
305
 
    m_declarationList.setAutoDelete( true );
306
 
}
307
 
 
308
 
void TranslationUnitAST::addDeclaration( DeclarationAST::Node& ast )
309
 
{
310
 
    if( !ast.get() )
311
 
        return;
312
 
 
313
 
    ast->setParent( this );
314
 
    m_declarationList.append( ast.release() );
315
 
}
316
 
 
317
 
// ------------------------------------------------------------------------
318
 
NamespaceAST::NamespaceAST()
319
 
{
320
 
}
321
 
 
322
 
void NamespaceAST::setNamespaceName( AST::Node& namespaceName )
323
 
{
324
 
    m_namespaceName = namespaceName;
325
 
    if( m_namespaceName.get() ) m_namespaceName->setParent( this );
326
 
}
327
 
 
328
 
void NamespaceAST::setLinkageBody( LinkageBodyAST::Node& linkageBody )
329
 
{
330
 
    m_linkageBody = linkageBody;
331
 
    if( m_linkageBody.get() ) m_linkageBody->setParent( this );
332
 
}
333
 
 
334
 
 
335
 
// ------------------------------------------------------------------------
336
 
NamespaceAliasAST::NamespaceAliasAST()
337
 
{
338
 
}
339
 
 
340
 
void NamespaceAliasAST::setNamespaceName( AST::Node& namespaceName )
341
 
{
342
 
    m_namespaceName = namespaceName;
343
 
    if( m_namespaceName.get() ) m_namespaceName->setParent( this );
344
 
}
345
 
 
346
 
void NamespaceAliasAST::setAliasName( NameAST::Node& name )
347
 
{
348
 
    m_aliasName = name;
349
 
    if( m_aliasName.get() ) m_aliasName->setParent( this );
350
 
}
351
 
 
352
 
// ------------------------------------------------------------------------
353
 
UsingAST::UsingAST()
354
 
{
355
 
}
356
 
 
357
 
void UsingAST::setTypeName( AST::Node& typeName )
358
 
{
359
 
    m_typeName = typeName;
360
 
    if( m_typeName.get() ) m_typeName->setParent( this );
361
 
}
362
 
 
363
 
void UsingAST::setName( NameAST::Node& name )
364
 
{
365
 
    m_name = name;
366
 
    if( m_name.get() ) m_name->setParent( this );
367
 
}
368
 
 
369
 
// ------------------------------------------------------------------------
370
 
UsingDirectiveAST::UsingDirectiveAST()
371
 
{
372
 
}
373
 
 
374
 
void UsingDirectiveAST::setName( NameAST::Node& name )
375
 
{
376
 
    m_name = name;
377
 
    if( m_name.get() ) m_name->setParent( this );
378
 
}
379
 
 
380
 
TypedefAST::TypedefAST()
381
 
{
382
 
}
383
 
 
384
 
void TypeSpecifierAST::setName( NameAST::Node& name )
385
 
{
386
 
    m_name = name;
387
 
    if( m_name.get() ) m_name->setParent( this );
388
 
}
389
 
 
390
 
void TypedefAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
391
 
{
392
 
    m_typeSpec = typeSpec;
393
 
    if( m_typeSpec.get() ) m_typeSpec->setParent( this );
394
 
}
395
 
 
396
 
void TypedefAST::setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList )
397
 
{
398
 
    m_initDeclaratorList = initDeclaratorList;
399
 
    if( m_initDeclaratorList.get() ) m_initDeclaratorList->setParent( this );
400
 
}
401
 
 
402
 
// ------------------------------------------------------------------------
403
 
TemplateArgumentListAST::TemplateArgumentListAST()
404
 
{
405
 
    m_argumentList.setAutoDelete( true );
406
 
}
407
 
 
408
 
void TemplateArgumentListAST::addArgument( AST::Node& arg )
409
 
{
410
 
    if( !arg.get() )
411
 
        return;
412
 
 
413
 
    arg->setParent( this );
414
 
    m_argumentList.append( arg.release() );
415
 
}
416
 
 
417
 
QString TemplateArgumentListAST::text() const
418
 
{
419
 
    QStringList l;
420
 
 
421
 
    QPtrListIterator<AST> it( m_argumentList );
422
 
    while( it.current() ){
423
 
        l.append( it.current()->text() );
424
 
        ++it;
425
 
    }
426
 
 
427
 
    return l.join( ", " );
428
 
}
429
 
 
430
 
// ------------------------------------------------------------------------
431
 
TemplateDeclarationAST::TemplateDeclarationAST()
432
 
{
433
 
}
434
 
 
435
 
void TemplateDeclarationAST::setExported( AST::Node& exported )
436
 
{
437
 
    m_exported = exported;
438
 
    if( m_exported.get() ) m_exported->setParent( this );
439
 
}
440
 
 
441
 
void TemplateDeclarationAST::setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList )
442
 
{
443
 
    m_templateParameterList = templateParameterList;
444
 
    if( m_templateParameterList.get() ) m_templateParameterList->setParent( this );
445
 
}
446
 
 
447
 
void TemplateDeclarationAST::setDeclaration( DeclarationAST::Node& declaration )
448
 
{
449
 
    m_declaration = declaration;
450
 
    if( m_declaration.get() ) m_declaration->setParent( this );
451
 
}
452
 
 
453
 
// ------------------------------------------------------------------------
454
 
ClassOrNamespaceNameAST::ClassOrNamespaceNameAST()
455
 
{
456
 
}
457
 
 
458
 
void ClassOrNamespaceNameAST::setName( AST::Node& name )
459
 
{
460
 
    m_name = name;
461
 
    if( m_name.get() ) m_name->setParent( this );
462
 
}
463
 
 
464
 
void ClassOrNamespaceNameAST::setTemplateArgumentList( TemplateArgumentListAST::Node& templateArgumentList )
465
 
{
466
 
    m_templateArgumentList = templateArgumentList;
467
 
    if( m_templateArgumentList.get() ) m_templateArgumentList->setParent( this );
468
 
}
469
 
 
470
 
QString ClassOrNamespaceNameAST::text() const
471
 
{
472
 
    if( !m_name.get() )
473
 
        return QString::null;
474
 
 
475
 
    QString str = m_name->text();
476
 
    if( m_templateArgumentList.get() )
477
 
        str += QString::fromLatin1("< ") + m_templateArgumentList->text() + QString::fromLatin1(" >");
478
 
 
479
 
    return str;
480
 
}
481
 
 
482
 
// ------------------------------------------------------------------------
483
 
TypeSpecifierAST::TypeSpecifierAST()
484
 
{
485
 
}
486
 
 
487
 
void TypeSpecifierAST::setCvQualify( GroupAST::Node& cvQualify )
488
 
{
489
 
    m_cvQualify = cvQualify;
490
 
    if( m_cvQualify.get() ) m_cvQualify->setParent( this );
491
 
}
492
 
 
493
 
void TypeSpecifierAST::setCv2Qualify( GroupAST::Node& cv2Qualify )
494
 
{
495
 
    m_cv2Qualify = cv2Qualify;
496
 
    if( m_cv2Qualify.get() ) m_cv2Qualify->setParent( this );
497
 
}
498
 
 
499
 
QString TypeSpecifierAST::text() const
500
 
{
501
 
    QString str;
502
 
 
503
 
    if( m_cvQualify.get() )
504
 
        str += m_cvQualify->text() + " ";
505
 
 
506
 
    if( m_name.get() )
507
 
        str += m_name->text();
508
 
 
509
 
    if( m_cv2Qualify.get() )
510
 
        str += QString(" ") + m_cv2Qualify->text();
511
 
 
512
 
    return str;
513
 
}
514
 
 
515
 
// ------------------------------------------------------------------------
516
 
ClassSpecifierAST::ClassSpecifierAST()
517
 
{
518
 
    m_declarationList.setAutoDelete( true );
519
 
}
520
 
 
521
 
void ClassSpecifierAST::setClassKey( AST::Node& classKey )
522
 
{
523
 
    m_classKey = classKey;
524
 
    if( m_classKey.get() ) m_classKey->setParent( this );
525
 
}
526
 
 
527
 
void ClassSpecifierAST::addDeclaration( DeclarationAST::Node& declaration )
528
 
{
529
 
    if( !declaration.get() )
530
 
        return;
531
 
 
532
 
    declaration->setParent( this );
533
 
    m_declarationList.append( declaration.release() );
534
 
}
535
 
 
536
 
void ClassSpecifierAST::setBaseClause( BaseClauseAST::Node& baseClause )
537
 
{
538
 
    m_baseClause = baseClause;
539
 
    if( m_baseClause.get() ) m_baseClause->setParent( this );
540
 
}
541
 
 
542
 
// ------------------------------------------------------------------------
543
 
EnumSpecifierAST::EnumSpecifierAST()
544
 
{
545
 
    m_enumeratorList.setAutoDelete( true );
546
 
}
547
 
 
548
 
void EnumSpecifierAST::addEnumerator( EnumeratorAST::Node& enumerator )
549
 
{
550
 
    if( !enumerator.get() )
551
 
        return;
552
 
 
553
 
    enumerator->setParent( this );
554
 
    m_enumeratorList.append( enumerator.release() );
555
 
}
556
 
 
557
 
 
558
 
// ------------------------------------------------------------------------
559
 
ElaboratedTypeSpecifierAST::ElaboratedTypeSpecifierAST()
560
 
{
561
 
}
562
 
 
563
 
void ElaboratedTypeSpecifierAST::setKind( AST::Node& kind )
564
 
{
565
 
    m_kind = kind;
566
 
    if( m_kind.get() ) m_kind->setParent( this );
567
 
}
568
 
 
569
 
QString ElaboratedTypeSpecifierAST::text() const
570
 
{
571
 
    if( m_kind.get() )
572
 
        return m_kind->text() + " " + TypeSpecifierAST::text();
573
 
 
574
 
    return TypeSpecifierAST::text();
575
 
}
576
 
 
577
 
// ------------------------------------------------------------------------
578
 
StatementAST::StatementAST()
579
 
{
580
 
}
581
 
 
582
 
// ------------------------------------------------------------------------
583
 
EnumeratorAST::EnumeratorAST()
584
 
{
585
 
}
586
 
 
587
 
void EnumeratorAST::setId( AST::Node& id )
588
 
{
589
 
    m_id = id;
590
 
    if( m_id.get() ) m_id->setParent( this );
591
 
}
592
 
 
593
 
void EnumeratorAST::setExpr( AST::Node& expr )
594
 
{
595
 
    m_expr = expr;
596
 
    if( m_expr.get() ) m_expr->setParent( this );
597
 
}
598
 
 
599
 
// ------------------------------------------------------------------------
600
 
BaseClauseAST::BaseClauseAST()
601
 
{
602
 
    m_baseSpecifierList.setAutoDelete( true );
603
 
}
604
 
 
605
 
void BaseClauseAST::addBaseSpecifier( BaseSpecifierAST::Node& baseSpecifier )
606
 
{
607
 
    if( !baseSpecifier.get() )
608
 
        return;
609
 
 
610
 
    baseSpecifier->setParent( this );
611
 
    m_baseSpecifierList.append( baseSpecifier.release() );
612
 
}
613
 
 
614
 
// ------------------------------------------------------------------------
615
 
BaseSpecifierAST::BaseSpecifierAST()
616
 
{
617
 
}
618
 
 
619
 
void BaseSpecifierAST::setIsVirtual( AST::Node& isVirtual )
620
 
{
621
 
    m_isVirtual = isVirtual;
622
 
    if( m_isVirtual.get() ) m_isVirtual->setParent( this );
623
 
}
624
 
 
625
 
void BaseSpecifierAST::setAccess( AST::Node& access )
626
 
{
627
 
    m_access = access;
628
 
    if( m_access.get() ) m_access->setParent( this );
629
 
}
630
 
 
631
 
void BaseSpecifierAST::setName( NameAST::Node& name )
632
 
{
633
 
    m_name = name;
634
 
    if( m_name.get() ) m_name->setParent( this );
635
 
}
636
 
 
637
 
// ------------------------------------------------------------------------
638
 
SimpleDeclarationAST::SimpleDeclarationAST()
639
 
{
640
 
}
641
 
 
642
 
void SimpleDeclarationAST::setFunctionSpecifier( GroupAST::Node& functionSpecifier )
643
 
{
644
 
    m_functionSpecifier = functionSpecifier;
645
 
    if( m_functionSpecifier.get() ) m_functionSpecifier->setParent( this );
646
 
}
647
 
 
648
 
void SimpleDeclarationAST::setStorageSpecifier( GroupAST::Node& storageSpecifier )
649
 
{
650
 
    m_storageSpecifier = storageSpecifier;
651
 
    if( m_storageSpecifier.get() ) m_storageSpecifier->setParent( this );
652
 
}
653
 
 
654
 
void SimpleDeclarationAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
655
 
{
656
 
    m_typeSpec = typeSpec;
657
 
    if( m_typeSpec.get() ) m_typeSpec->setParent( this );
658
 
}
659
 
 
660
 
void SimpleDeclarationAST::setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList )
661
 
{
662
 
    m_initDeclaratorList = initDeclaratorList;
663
 
    if( m_initDeclaratorList.get() ) m_initDeclaratorList->setParent( this );
664
 
}
665
 
 
666
 
void SimpleDeclarationAST::setWinDeclSpec( GroupAST::Node& winDeclSpec )
667
 
{
668
 
    m_winDeclSpec = winDeclSpec;
669
 
    if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this );
670
 
}
671
 
 
672
 
 
673
 
// ------------------------------------------------------------------------
674
 
InitDeclaratorListAST::InitDeclaratorListAST()
675
 
{
676
 
    m_initDeclaratorList.setAutoDelete( true );
677
 
}
678
 
 
679
 
void InitDeclaratorListAST::addInitDeclarator( InitDeclaratorAST::Node& decl )
680
 
{
681
 
    if( !decl.get() )
682
 
        return;
683
 
 
684
 
    decl->setParent( this );
685
 
    m_initDeclaratorList.append( decl.release() );
686
 
}
687
 
 
688
 
// ------------------------------------------------------------------------
689
 
DeclaratorAST::DeclaratorAST()
690
 
{
691
 
    m_ptrOpList.setAutoDelete( true );
692
 
    m_arrayDimensionList.setAutoDelete( true );
693
 
}
694
 
 
695
 
void DeclaratorAST::setSubDeclarator( DeclaratorAST::Node& subDeclarator )
696
 
{
697
 
    m_subDeclarator = subDeclarator;
698
 
    if( m_subDeclarator.get() ) m_subDeclarator->setParent( this );
699
 
}
700
 
 
701
 
void DeclaratorAST::setDeclaratorId( NameAST::Node& declaratorId )
702
 
{
703
 
    m_declaratorId = declaratorId;
704
 
    if( m_declaratorId.get() ) m_declaratorId->setParent( this );
705
 
}
706
 
 
707
 
void DeclaratorAST::setBitfieldInitialization( AST::Node& bitfieldInitialization )
708
 
{
709
 
    m_bitfieldInitialization = bitfieldInitialization;
710
 
    if( m_bitfieldInitialization.get() ) m_bitfieldInitialization->setParent( this );
711
 
}
712
 
 
713
 
void DeclaratorAST::addArrayDimension( AST::Node& arrayDimension )
714
 
{
715
 
    if( !arrayDimension.get() )
716
 
        return;
717
 
 
718
 
    arrayDimension->setParent( this );
719
 
    m_arrayDimensionList.append( arrayDimension.release() );
720
 
}
721
 
 
722
 
void DeclaratorAST::setParameterDeclarationClause( ParameterDeclarationClauseAST::Node& parameterDeclarationClause )
723
 
{
724
 
    m_parameterDeclarationClause = parameterDeclarationClause;
725
 
    if( m_parameterDeclarationClause.get() ) m_parameterDeclarationClause->setParent( this );
726
 
}
727
 
 
728
 
void DeclaratorAST::setConstant( AST::Node& constant )
729
 
{
730
 
    m_constant = constant;
731
 
    if( m_constant.get() ) m_constant->setParent( this );
732
 
}
733
 
 
734
 
void DeclaratorAST::setExceptionSpecification( GroupAST::Node& exceptionSpecification )
735
 
{
736
 
    m_exceptionSpecification = exceptionSpecification;
737
 
    if( m_exceptionSpecification.get() ) m_exceptionSpecification->setParent( this );
738
 
}
739
 
 
740
 
void DeclaratorAST::addPtrOp( AST::Node& ptrOp )
741
 
{
742
 
    if( !ptrOp.get() )
743
 
        return;
744
 
 
745
 
    ptrOp->setParent( this );
746
 
    m_ptrOpList.append( ptrOp.release() );
747
 
}
748
 
 
749
 
// --------------------------------------------------------------------------
750
 
InitDeclaratorAST::InitDeclaratorAST()
751
 
{
752
 
}
753
 
 
754
 
void InitDeclaratorAST::setDeclarator( DeclaratorAST::Node& declarator )
755
 
{
756
 
    m_declarator = declarator;
757
 
    if( m_declarator.get() ) m_declarator->setParent( this );
758
 
}
759
 
 
760
 
void InitDeclaratorAST::setInitializer( AST::Node& initializer )
761
 
{
762
 
    m_initializer = initializer;
763
 
    if( m_initializer.get() ) m_initializer->setParent( this );
764
 
}
765
 
 
766
 
// --------------------------------------------------------------------------
767
 
FunctionDefinitionAST::FunctionDefinitionAST()
768
 
{
769
 
}
770
 
 
771
 
void FunctionDefinitionAST::setFunctionSpecifier( GroupAST::Node& functionSpecifier )
772
 
{
773
 
    m_functionSpecifier = functionSpecifier;
774
 
    if( m_functionSpecifier.get() ) m_functionSpecifier->setParent( this );
775
 
}
776
 
 
777
 
void FunctionDefinitionAST::setStorageSpecifier( GroupAST::Node& storageSpecifier )
778
 
{
779
 
    m_storageSpecifier = storageSpecifier;
780
 
    if( m_storageSpecifier.get() ) m_storageSpecifier->setParent( this );
781
 
}
782
 
 
783
 
void FunctionDefinitionAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
784
 
{
785
 
    m_typeSpec = typeSpec;
786
 
    if( m_typeSpec.get() ) m_typeSpec->setParent( this );
787
 
}
788
 
 
789
 
void FunctionDefinitionAST::setInitDeclarator( InitDeclaratorAST::Node& initDeclarator )
790
 
{
791
 
    m_initDeclarator = initDeclarator;
792
 
    if( m_initDeclarator.get() ) m_initDeclarator->setParent( this );
793
 
}
794
 
 
795
 
void FunctionDefinitionAST::setFunctionBody( StatementListAST::Node& functionBody )
796
 
{
797
 
    m_functionBody = functionBody;
798
 
    if( m_functionBody.get() ) m_functionBody->setParent( this );
799
 
}
800
 
 
801
 
void FunctionDefinitionAST::setWinDeclSpec( GroupAST::Node& winDeclSpec )
802
 
{
803
 
    m_winDeclSpec = winDeclSpec;
804
 
    if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this );
805
 
}
806
 
 
807
 
// --------------------------------------------------------------------------
808
 
StatementListAST::StatementListAST()
809
 
{
810
 
    m_statementList.setAutoDelete( true );
811
 
}
812
 
 
813
 
void StatementListAST::addStatement( StatementAST::Node& statement )
814
 
{
815
 
    if( !statement.get() )
816
 
        return;
817
 
 
818
 
    statement->setParent( this );
819
 
    m_statementList.append( statement.release() );
820
 
}
821
 
 
822
 
// --------------------------------------------------------------------------
823
 
IfStatementAST::IfStatementAST()
824
 
{
825
 
}
826
 
 
827
 
void IfStatementAST::setCondition( ConditionAST::Node& condition )
828
 
{
829
 
    m_condition = condition;
830
 
    if( m_condition.get() ) m_condition->setParent( this );
831
 
}
832
 
 
833
 
void IfStatementAST::setStatement( StatementAST::Node& statement )
834
 
{
835
 
    m_statement = statement;
836
 
    if( m_statement.get() ) m_statement->setParent( this );
837
 
}
838
 
 
839
 
void IfStatementAST::setElseStatement( StatementAST::Node& elseStatement )
840
 
{
841
 
    m_elseStatement = elseStatement;
842
 
    if( m_elseStatement.get() ) m_elseStatement->setParent( this );
843
 
}
844
 
 
845
 
// --------------------------------------------------------------------------
846
 
WhileStatementAST::WhileStatementAST()
847
 
{
848
 
}
849
 
 
850
 
void WhileStatementAST::setCondition( ConditionAST::Node& condition )
851
 
{
852
 
    m_condition = condition;
853
 
    if( m_condition.get() ) m_condition->setParent( this );
854
 
}
855
 
 
856
 
void WhileStatementAST::setStatement( StatementAST::Node& statement )
857
 
{
858
 
    m_statement = statement;
859
 
    if( m_statement.get() ) m_statement->setParent( this );
860
 
}
861
 
 
862
 
// --------------------------------------------------------------------------
863
 
DoStatementAST::DoStatementAST()
864
 
{
865
 
}
866
 
 
867
 
void DoStatementAST::setCondition( ConditionAST::Node& condition )
868
 
{
869
 
    m_condition = condition;
870
 
    if( m_condition.get() ) m_condition->setParent( this );
871
 
}
872
 
 
873
 
void DoStatementAST::setStatement( StatementAST::Node& statement )
874
 
{
875
 
    m_statement = statement;
876
 
    if( m_statement.get() ) m_statement->setParent( this );
877
 
}
878
 
 
879
 
// --------------------------------------------------------------------------
880
 
ForStatementAST::ForStatementAST()
881
 
{
882
 
}
883
 
 
884
 
void ForStatementAST::setCondition( ConditionAST::Node& condition )
885
 
{
886
 
    m_condition = condition;
887
 
    if( m_condition.get() ) m_condition->setParent( this );
888
 
}
889
 
 
890
 
void ForStatementAST::setExpression( AST::Node& expression )
891
 
{
892
 
    m_expression = expression;
893
 
    if( m_expression.get() ) m_expression->setParent( this );
894
 
}
895
 
 
896
 
void ForStatementAST::setStatement( StatementAST::Node& statement )
897
 
{
898
 
    m_statement = statement;
899
 
    if( m_statement.get() ) m_statement->setParent( this );
900
 
}
901
 
 
902
 
void ForStatementAST::setInitStatement( StatementAST::Node& initStatement )
903
 
{
904
 
    m_initStatement = initStatement;
905
 
    if( m_initStatement.get() ) m_initStatement->setParent( this );
906
 
}
907
 
 
908
 
// --------------------------------------------------------------------------
909
 
ForEachStatementAST::ForEachStatementAST()
910
 
{
911
 
}
912
 
 
913
 
void ForEachStatementAST::setExpression( AST::Node& expression )
914
 
{
915
 
    m_expression = expression;
916
 
    if( m_expression.get() ) m_expression->setParent( this );
917
 
}
918
 
 
919
 
void ForEachStatementAST::setStatement( StatementAST::Node& statement )
920
 
{
921
 
    m_statement = statement;
922
 
    if( m_statement.get() ) m_statement->setParent( this );
923
 
}
924
 
 
925
 
void ForEachStatementAST::setInitStatement( StatementAST::Node& initStatement )
926
 
{
927
 
    m_initStatement = initStatement;
928
 
    if( m_initStatement.get() ) m_initStatement->setParent( this );
929
 
}
930
 
 
931
 
// --------------------------------------------------------------------------
932
 
SwitchStatementAST::SwitchStatementAST()
933
 
{
934
 
}
935
 
 
936
 
void SwitchStatementAST::setCondition( ConditionAST::Node& condition )
937
 
{
938
 
    m_condition = condition;
939
 
    if( m_condition.get() ) m_condition->setParent( this );
940
 
}
941
 
 
942
 
void SwitchStatementAST::setStatement( StatementAST::Node& statement )
943
 
{
944
 
    m_statement = statement;
945
 
    if( m_statement.get() ) m_statement->setParent( this );
946
 
}
947
 
 
948
 
// --------------------------------------------------------------------------
949
 
CatchStatementListAST::CatchStatementListAST()
950
 
{
951
 
    m_statementList.setAutoDelete( true );
952
 
}
953
 
 
954
 
void CatchStatementListAST::addStatement( CatchStatementAST::Node& statement )
955
 
{
956
 
    if( !statement.get() )
957
 
        return;
958
 
 
959
 
    statement->setParent( this );
960
 
    m_statementList.append( statement.release() );
961
 
}
962
 
 
963
 
// --------------------------------------------------------------------------
964
 
CatchStatementAST::CatchStatementAST()
965
 
{
966
 
}
967
 
 
968
 
void CatchStatementAST::setCondition( ConditionAST::Node& condition )
969
 
{
970
 
    m_condition = condition;
971
 
    if( m_condition.get() ) m_condition->setParent( this );
972
 
}
973
 
 
974
 
void CatchStatementAST::setStatement( StatementAST::Node& statement )
975
 
{
976
 
    m_statement = statement;
977
 
    if( m_statement.get() ) m_statement->setParent( this );
978
 
}
979
 
 
980
 
// --------------------------------------------------------------------------
981
 
TryBlockStatementAST::TryBlockStatementAST()
982
 
{
983
 
}
984
 
 
985
 
void TryBlockStatementAST::setStatement( StatementAST::Node& statement )
986
 
{
987
 
    m_statement = statement;
988
 
    if( m_statement.get() ) m_statement->setParent( this );
989
 
}
990
 
 
991
 
void TryBlockStatementAST::setCatchStatementList( CatchStatementListAST::Node& statementList )
992
 
{
993
 
    m_catchStatementList = statementList;
994
 
    if( m_catchStatementList.get() ) m_catchStatementList->setParent( this );
995
 
}
996
 
 
997
 
// --------------------------------------------------------------------------
998
 
DeclarationStatementAST::DeclarationStatementAST()
999
 
{
1000
 
}
1001
 
 
1002
 
void DeclarationStatementAST::setDeclaration( DeclarationAST::Node& declaration )
1003
 
{
1004
 
    m_declaration = declaration;
1005
 
    if( m_declaration.get() ) m_declaration->setParent( this );
1006
 
}
1007
 
 
1008
 
// --------------------------------------------------------------------------
1009
 
ExpressionStatementAST::ExpressionStatementAST()
1010
 
{
1011
 
}
1012
 
 
1013
 
void ExpressionStatementAST::setExpression( AST::Node& expression )
1014
 
{
1015
 
    m_expression = expression;
1016
 
    if( m_expression.get() ) m_expression->setParent( this );
1017
 
}
1018
 
 
1019
 
 
1020
 
// --------------------------------------------------------------------------
1021
 
ParameterDeclarationAST::ParameterDeclarationAST()
1022
 
{
1023
 
}
1024
 
 
1025
 
void ParameterDeclarationAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
1026
 
{
1027
 
    m_typeSpec = typeSpec;
1028
 
    if( m_typeSpec.get() ) m_typeSpec->setParent( this );
1029
 
}
1030
 
 
1031
 
void ParameterDeclarationAST::setDeclarator( DeclaratorAST::Node& declarator )
1032
 
{
1033
 
    m_declarator = declarator;
1034
 
    if( m_declarator.get() ) m_declarator->setParent( this );
1035
 
}
1036
 
 
1037
 
void ParameterDeclarationAST::setExpression( AST::Node& expression )
1038
 
{
1039
 
    m_expression = expression;
1040
 
    if( m_expression.get() ) m_expression->setParent( this );
1041
 
}
1042
 
 
1043
 
QString ParameterDeclarationAST::text() const
1044
 
{
1045
 
    QString str;
1046
 
    if( m_typeSpec.get() )
1047
 
        str += m_typeSpec->text() + " ";
1048
 
 
1049
 
    if( m_declarator.get() )
1050
 
        str += m_declarator->text();
1051
 
 
1052
 
    if( m_expression.get() )
1053
 
        str += QString( " = " ) + m_expression->text();
1054
 
 
1055
 
    return str;
1056
 
}
1057
 
 
1058
 
// --------------------------------------------------------------------------
1059
 
ParameterDeclarationListAST::ParameterDeclarationListAST()
1060
 
{
1061
 
    m_parameterList.setAutoDelete( true );
1062
 
}
1063
 
 
1064
 
void ParameterDeclarationListAST::addParameter( ParameterDeclarationAST::Node& parameter )
1065
 
{
1066
 
    if( !parameter.get() )
1067
 
        return;
1068
 
 
1069
 
    parameter->setParent( this );
1070
 
    m_parameterList.append( parameter.release() );
1071
 
}
1072
 
 
1073
 
QString ParameterDeclarationListAST::text() const
1074
 
{
1075
 
    QStringList l;
1076
 
 
1077
 
    QPtrListIterator<ParameterDeclarationAST> it( m_parameterList );
1078
 
    while( it.current() ){
1079
 
        l.append( it.current()->text() );
1080
 
        ++it;
1081
 
    }
1082
 
 
1083
 
    return l.join( ", " );
1084
 
}
1085
 
 
1086
 
 
1087
 
// --------------------------------------------------------------------------
1088
 
ParameterDeclarationClauseAST::ParameterDeclarationClauseAST()
1089
 
{
1090
 
}
1091
 
 
1092
 
void ParameterDeclarationClauseAST::setParameterDeclarationList( ParameterDeclarationListAST::Node& parameterDeclarationList )
1093
 
{
1094
 
    m_parameterDeclarationList = parameterDeclarationList;
1095
 
    if( m_parameterDeclarationList.get() ) m_parameterDeclarationList->setParent( this );
1096
 
}
1097
 
 
1098
 
void ParameterDeclarationClauseAST::setEllipsis( AST::Node& ellipsis )
1099
 
{
1100
 
    m_ellipsis = ellipsis;
1101
 
    if( m_ellipsis.get() ) m_ellipsis->setParent( this );
1102
 
}
1103
 
 
1104
 
QString ParameterDeclarationClauseAST::text() const
1105
 
{
1106
 
    QString str;
1107
 
 
1108
 
    if( m_parameterDeclarationList.get() )
1109
 
        str += m_parameterDeclarationList->text();
1110
 
 
1111
 
    if( m_ellipsis.get() )
1112
 
        str += " ...";
1113
 
 
1114
 
    return str;
1115
 
}
1116
 
 
1117
 
 
1118
 
// --------------------------------------------------------------------------
1119
 
GroupAST::GroupAST()
1120
 
{
1121
 
    m_nodeList.setAutoDelete( true );
1122
 
}
1123
 
 
1124
 
void GroupAST::addNode( AST::Node& node )
1125
 
{
1126
 
    if( !node.get() )
1127
 
        return;
1128
 
 
1129
 
    node->setParent( this );
1130
 
    m_nodeList.append( node.release() );
1131
 
}
1132
 
 
1133
 
QString GroupAST::text() const
1134
 
{
1135
 
    QStringList l;
1136
 
 
1137
 
    QPtrListIterator<AST> it( m_nodeList );
1138
 
    while( it.current() ){
1139
 
        l.append( it.current()->text() );
1140
 
        ++it;
1141
 
    }
1142
 
 
1143
 
    return l.join( " " );
1144
 
}
1145
 
 
1146
 
// --------------------------------------------------------------------------
1147
 
AccessDeclarationAST::AccessDeclarationAST()
1148
 
{
1149
 
    m_accessList.setAutoDelete( true );
1150
 
}
1151
 
 
1152
 
void AccessDeclarationAST::addAccess( AST::Node& access )
1153
 
{
1154
 
    if( !access.get() )
1155
 
        return;
1156
 
 
1157
 
    access->setParent( this );
1158
 
    m_accessList.append( access.release() );
1159
 
}
1160
 
 
1161
 
QString AccessDeclarationAST::text() const
1162
 
{
1163
 
    QStringList l;
1164
 
 
1165
 
    QPtrListIterator<AST> it( m_accessList );
1166
 
    while( it.current() ){
1167
 
        l.append( it.current()->text() );
1168
 
        ++it;
1169
 
    }
1170
 
 
1171
 
    return l.join( " " );
1172
 
}
1173
 
 
1174
 
// --------------------------------------------------------------------------
1175
 
TypeParameterAST::TypeParameterAST()
1176
 
{
1177
 
}
1178
 
 
1179
 
void TypeParameterAST::setKind( AST::Node& kind )
1180
 
{
1181
 
    m_kind = kind;
1182
 
    if( m_kind.get() ) m_kind->setParent( this );
1183
 
}
1184
 
 
1185
 
void TypeParameterAST::setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList )
1186
 
{
1187
 
    m_templateParameterList = templateParameterList;
1188
 
    if( m_templateParameterList.get() ) m_templateParameterList->setParent( this );
1189
 
}
1190
 
 
1191
 
void TypeParameterAST::setName( NameAST::Node& name )
1192
 
{
1193
 
    m_name = name;
1194
 
    if( m_name.get() ) m_name->setParent( this );
1195
 
}
1196
 
 
1197
 
void TypeParameterAST::setTypeId( AST::Node& typeId )
1198
 
{
1199
 
    m_typeId = typeId;
1200
 
    if( m_typeId.get() ) m_typeId->setParent( this );
1201
 
}
1202
 
 
1203
 
// --------------------------------------------------------------------------
1204
 
TemplateParameterAST::TemplateParameterAST()
1205
 
{
1206
 
}
1207
 
 
1208
 
void TemplateParameterAST::setTypeParameter( TypeParameterAST::Node& typeParameter )
1209
 
{
1210
 
    m_typeParameter = typeParameter;
1211
 
    if( m_typeParameter.get() ) m_typeParameter->setParent( this );
1212
 
}
1213
 
 
1214
 
void TemplateParameterAST::setTypeValueParameter( ParameterDeclarationAST::Node& typeValueParameter )
1215
 
{
1216
 
    m_typeValueParameter = typeValueParameter;
1217
 
    if( m_typeValueParameter.get() ) m_typeValueParameter->setParent( this );
1218
 
}
1219
 
 
1220
 
// --------------------------------------------------------------------------
1221
 
TemplateParameterListAST::TemplateParameterListAST()
1222
 
{
1223
 
    m_templateParameterList.setAutoDelete( true );
1224
 
}
1225
 
 
1226
 
void TemplateParameterListAST::addTemplateParameter( TemplateParameterAST::Node& templateParameter )
1227
 
{
1228
 
    if( !templateParameter.get() )
1229
 
        return;
1230
 
 
1231
 
    templateParameter->setParent( this );
1232
 
    m_templateParameterList.append( templateParameter.release() );
1233
 
}
1234
 
 
1235
 
// --------------------------------------------------------------------------
1236
 
ConditionAST::ConditionAST()
1237
 
{
1238
 
}
1239
 
 
1240
 
void ConditionAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
1241
 
{
1242
 
    m_typeSpec = typeSpec;
1243
 
    if( m_typeSpec.get() ) m_typeSpec->setParent( this );
1244
 
}
1245
 
 
1246
 
void ConditionAST::setDeclarator( DeclaratorAST::Node& declarator )
1247
 
{
1248
 
    m_declarator = declarator;
1249
 
    if( m_declarator.get() ) m_declarator->setParent( this );
1250
 
}
1251
 
 
1252
 
void ConditionAST::setExpression( AST::Node& expression )
1253
 
{
1254
 
    m_expression = expression;
1255
 
    if( m_expression.get() ) m_expression->setParent( this );
1256
 
}
1257
 
 
1258
 
void ClassSpecifierAST::setWinDeclSpec( GroupAST::Node & winDeclSpec )
1259
 
{
1260
 
    m_winDeclSpec = winDeclSpec;
1261
 
    if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this );
1262
 
}