1
/* This file is part of KDevelop
2
Copyright (C) 2002,2003 Roberto Raggi <roberto@kdevelop.org>
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.
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.
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.
21
#include <qstringlist.h>
24
QString nodeTypeToString( int type )
28
case NodeType_Generic:
30
case NodeType_TemplateArgumentList:
31
return "TemplateArgumentList";
32
case NodeType_ClassOrNamespaceName:
33
return "ClassOrNamespaceName";
36
case NodeType_Declaration:
38
case NodeType_TypeSpecifier:
39
return "TypeSpecifier";
40
case NodeType_BaseSpecifier:
41
return "BaseSpecifier";
42
case NodeType_BaseClause:
44
case NodeType_ClassSpecifier:
45
return "ClassSpecifier";
46
case NodeType_Enumerator:
48
case NodeType_EnumSpecifier:
49
return "EnumSpecifier";
50
case NodeType_ElaboratedTypeSpecifier:
51
return "ElaboratedTypeSpecifier";
52
case NodeType_LinkageBody:
54
case NodeType_LinkageSpecification:
55
return "LinkageSpecification";
56
case NodeType_Namespace:
58
case NodeType_NamespaceAlias:
59
return "NamespaceAlias";
62
case NodeType_UsingDirective:
63
return "UsingDirective";
64
case NodeType_InitDeclaratorList:
65
return "InitDeclaratorList";
66
case NodeType_Typedef:
68
case NodeType_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:
78
case NodeType_IfStatement:
80
case NodeType_WhileStatement:
81
return "WhileStatement";
82
case NodeType_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";
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:
124
case NodeType_Custom:
128
return QString::null;
132
// ------------------------------------------------------------------------
134
: m_nodeType( NodeType_Generic ), m_parent( 0 ),
135
m_startLine( 0 ), m_startColumn( 0 ),
136
m_endLine( 0 ), m_endColumn( 0 )
138
#ifndef CPPPARSER_NO_CHILDREN
139
m_children.setAutoDelete( false );
145
#ifndef CPPPARSER_NO_CHILDREN
147
m_parent->removeChild( this );
151
void AST::setStartPosition( int line, int col )
157
void AST::getStartPosition( int* line, int* col ) const
163
* col = m_startColumn;
166
void AST::setEndPosition( int line, int col )
172
void AST::getEndPosition( int* line, int* col ) const
181
void AST::setParent( AST* parent )
183
#ifndef CPPPARSER_NO_CHILDREN
185
m_parent->removeChild( this );
190
#ifndef CPPPARSER_NO_CHILDREN
192
m_parent->appendChild( this );
196
#ifndef CPPPARSER_NO_CHILDREN
197
void AST::appendChild( AST* child )
199
m_children.append( child );
202
void AST::removeChild( AST* child )
204
m_children.remove( child );
208
// ------------------------------------------------------------------------
212
m_classOrNamespaceNameList.setAutoDelete( true );
215
void NameAST::setGlobal( bool b )
220
void NameAST::setUnqualifiedName( ClassOrNamespaceNameAST::Node& unqualifiedName )
222
m_unqualifiedName = unqualifiedName;
223
if( m_unqualifiedName.get() ) m_unqualifiedName->setParent( this );
226
void NameAST::addClassOrNamespaceName( ClassOrNamespaceNameAST::Node& classOrNamespaceName )
228
if( !classOrNamespaceName.get() )
231
classOrNamespaceName->setParent( this );
232
m_classOrNamespaceNameList.append( classOrNamespaceName.release() );
235
QString NameAST::text() const
237
if( !m_unqualifiedName.get() )
238
return QString::null;
246
QPtrListIterator<ClassOrNamespaceNameAST> it( m_classOrNamespaceNameList );
247
while( it.current() ){
248
str += it.current()->text() + "::";
252
if( m_unqualifiedName.get() )
253
str += m_unqualifiedName->text();
258
// ------------------------------------------------------------------------
259
DeclarationAST::DeclarationAST()
263
// ------------------------------------------------------------------------
264
LinkageBodyAST::LinkageBodyAST()
266
m_declarationList.setAutoDelete( true );
269
void LinkageBodyAST::addDeclaration( DeclarationAST::Node& ast )
274
ast->setParent( this );
275
m_declarationList.append( ast.release() );
278
// ------------------------------------------------------------------------
279
LinkageSpecificationAST::LinkageSpecificationAST()
283
void LinkageSpecificationAST::setExternType( AST::Node& externType )
285
m_externType = externType;
286
if( m_externType.get() ) m_externType->setParent( this );
289
void LinkageSpecificationAST::setLinkageBody( LinkageBodyAST::Node& linkageBody )
291
m_linkageBody = linkageBody;
292
if( m_linkageBody.get() ) m_linkageBody->setParent( this );
295
void LinkageSpecificationAST::setDeclaration( DeclarationAST::Node& decl )
297
m_declaration = decl;
298
if( m_declaration.get() ) m_declaration->setParent( this );
301
// ------------------------------------------------------------------------
302
TranslationUnitAST::TranslationUnitAST()
304
////kdDebug(9007) << "++ TranslationUnitAST::TranslationUnitAST()" << endl;
305
m_declarationList.setAutoDelete( true );
308
void TranslationUnitAST::addDeclaration( DeclarationAST::Node& ast )
313
ast->setParent( this );
314
m_declarationList.append( ast.release() );
317
// ------------------------------------------------------------------------
318
NamespaceAST::NamespaceAST()
322
void NamespaceAST::setNamespaceName( AST::Node& namespaceName )
324
m_namespaceName = namespaceName;
325
if( m_namespaceName.get() ) m_namespaceName->setParent( this );
328
void NamespaceAST::setLinkageBody( LinkageBodyAST::Node& linkageBody )
330
m_linkageBody = linkageBody;
331
if( m_linkageBody.get() ) m_linkageBody->setParent( this );
335
// ------------------------------------------------------------------------
336
NamespaceAliasAST::NamespaceAliasAST()
340
void NamespaceAliasAST::setNamespaceName( AST::Node& namespaceName )
342
m_namespaceName = namespaceName;
343
if( m_namespaceName.get() ) m_namespaceName->setParent( this );
346
void NamespaceAliasAST::setAliasName( NameAST::Node& name )
349
if( m_aliasName.get() ) m_aliasName->setParent( this );
352
// ------------------------------------------------------------------------
357
void UsingAST::setTypeName( AST::Node& typeName )
359
m_typeName = typeName;
360
if( m_typeName.get() ) m_typeName->setParent( this );
363
void UsingAST::setName( NameAST::Node& name )
366
if( m_name.get() ) m_name->setParent( this );
369
// ------------------------------------------------------------------------
370
UsingDirectiveAST::UsingDirectiveAST()
374
void UsingDirectiveAST::setName( NameAST::Node& name )
377
if( m_name.get() ) m_name->setParent( this );
380
TypedefAST::TypedefAST()
384
void TypeSpecifierAST::setName( NameAST::Node& name )
387
if( m_name.get() ) m_name->setParent( this );
390
void TypedefAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
392
m_typeSpec = typeSpec;
393
if( m_typeSpec.get() ) m_typeSpec->setParent( this );
396
void TypedefAST::setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList )
398
m_initDeclaratorList = initDeclaratorList;
399
if( m_initDeclaratorList.get() ) m_initDeclaratorList->setParent( this );
402
// ------------------------------------------------------------------------
403
TemplateArgumentListAST::TemplateArgumentListAST()
405
m_argumentList.setAutoDelete( true );
408
void TemplateArgumentListAST::addArgument( AST::Node& arg )
413
arg->setParent( this );
414
m_argumentList.append( arg.release() );
417
QString TemplateArgumentListAST::text() const
421
QPtrListIterator<AST> it( m_argumentList );
422
while( it.current() ){
423
l.append( it.current()->text() );
427
return l.join( ", " );
430
// ------------------------------------------------------------------------
431
TemplateDeclarationAST::TemplateDeclarationAST()
435
void TemplateDeclarationAST::setExported( AST::Node& exported )
437
m_exported = exported;
438
if( m_exported.get() ) m_exported->setParent( this );
441
void TemplateDeclarationAST::setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList )
443
m_templateParameterList = templateParameterList;
444
if( m_templateParameterList.get() ) m_templateParameterList->setParent( this );
447
void TemplateDeclarationAST::setDeclaration( DeclarationAST::Node& declaration )
449
m_declaration = declaration;
450
if( m_declaration.get() ) m_declaration->setParent( this );
453
// ------------------------------------------------------------------------
454
ClassOrNamespaceNameAST::ClassOrNamespaceNameAST()
458
void ClassOrNamespaceNameAST::setName( AST::Node& name )
461
if( m_name.get() ) m_name->setParent( this );
464
void ClassOrNamespaceNameAST::setTemplateArgumentList( TemplateArgumentListAST::Node& templateArgumentList )
466
m_templateArgumentList = templateArgumentList;
467
if( m_templateArgumentList.get() ) m_templateArgumentList->setParent( this );
470
QString ClassOrNamespaceNameAST::text() const
473
return QString::null;
475
QString str = m_name->text();
476
if( m_templateArgumentList.get() )
477
str += QString::fromLatin1("< ") + m_templateArgumentList->text() + QString::fromLatin1(" >");
482
// ------------------------------------------------------------------------
483
TypeSpecifierAST::TypeSpecifierAST()
487
void TypeSpecifierAST::setCvQualify( GroupAST::Node& cvQualify )
489
m_cvQualify = cvQualify;
490
if( m_cvQualify.get() ) m_cvQualify->setParent( this );
493
void TypeSpecifierAST::setCv2Qualify( GroupAST::Node& cv2Qualify )
495
m_cv2Qualify = cv2Qualify;
496
if( m_cv2Qualify.get() ) m_cv2Qualify->setParent( this );
499
QString TypeSpecifierAST::text() const
503
if( m_cvQualify.get() )
504
str += m_cvQualify->text() + " ";
507
str += m_name->text();
509
if( m_cv2Qualify.get() )
510
str += QString(" ") + m_cv2Qualify->text();
515
// ------------------------------------------------------------------------
516
ClassSpecifierAST::ClassSpecifierAST()
518
m_declarationList.setAutoDelete( true );
521
void ClassSpecifierAST::setClassKey( AST::Node& classKey )
523
m_classKey = classKey;
524
if( m_classKey.get() ) m_classKey->setParent( this );
527
void ClassSpecifierAST::addDeclaration( DeclarationAST::Node& declaration )
529
if( !declaration.get() )
532
declaration->setParent( this );
533
m_declarationList.append( declaration.release() );
536
void ClassSpecifierAST::setBaseClause( BaseClauseAST::Node& baseClause )
538
m_baseClause = baseClause;
539
if( m_baseClause.get() ) m_baseClause->setParent( this );
542
// ------------------------------------------------------------------------
543
EnumSpecifierAST::EnumSpecifierAST()
545
m_enumeratorList.setAutoDelete( true );
548
void EnumSpecifierAST::addEnumerator( EnumeratorAST::Node& enumerator )
550
if( !enumerator.get() )
553
enumerator->setParent( this );
554
m_enumeratorList.append( enumerator.release() );
558
// ------------------------------------------------------------------------
559
ElaboratedTypeSpecifierAST::ElaboratedTypeSpecifierAST()
563
void ElaboratedTypeSpecifierAST::setKind( AST::Node& kind )
566
if( m_kind.get() ) m_kind->setParent( this );
569
QString ElaboratedTypeSpecifierAST::text() const
572
return m_kind->text() + " " + TypeSpecifierAST::text();
574
return TypeSpecifierAST::text();
577
// ------------------------------------------------------------------------
578
StatementAST::StatementAST()
582
// ------------------------------------------------------------------------
583
EnumeratorAST::EnumeratorAST()
587
void EnumeratorAST::setId( AST::Node& id )
590
if( m_id.get() ) m_id->setParent( this );
593
void EnumeratorAST::setExpr( AST::Node& expr )
596
if( m_expr.get() ) m_expr->setParent( this );
599
// ------------------------------------------------------------------------
600
BaseClauseAST::BaseClauseAST()
602
m_baseSpecifierList.setAutoDelete( true );
605
void BaseClauseAST::addBaseSpecifier( BaseSpecifierAST::Node& baseSpecifier )
607
if( !baseSpecifier.get() )
610
baseSpecifier->setParent( this );
611
m_baseSpecifierList.append( baseSpecifier.release() );
614
// ------------------------------------------------------------------------
615
BaseSpecifierAST::BaseSpecifierAST()
619
void BaseSpecifierAST::setIsVirtual( AST::Node& isVirtual )
621
m_isVirtual = isVirtual;
622
if( m_isVirtual.get() ) m_isVirtual->setParent( this );
625
void BaseSpecifierAST::setAccess( AST::Node& access )
628
if( m_access.get() ) m_access->setParent( this );
631
void BaseSpecifierAST::setName( NameAST::Node& name )
634
if( m_name.get() ) m_name->setParent( this );
637
// ------------------------------------------------------------------------
638
SimpleDeclarationAST::SimpleDeclarationAST()
642
void SimpleDeclarationAST::setFunctionSpecifier( GroupAST::Node& functionSpecifier )
644
m_functionSpecifier = functionSpecifier;
645
if( m_functionSpecifier.get() ) m_functionSpecifier->setParent( this );
648
void SimpleDeclarationAST::setStorageSpecifier( GroupAST::Node& storageSpecifier )
650
m_storageSpecifier = storageSpecifier;
651
if( m_storageSpecifier.get() ) m_storageSpecifier->setParent( this );
654
void SimpleDeclarationAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
656
m_typeSpec = typeSpec;
657
if( m_typeSpec.get() ) m_typeSpec->setParent( this );
660
void SimpleDeclarationAST::setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList )
662
m_initDeclaratorList = initDeclaratorList;
663
if( m_initDeclaratorList.get() ) m_initDeclaratorList->setParent( this );
666
void SimpleDeclarationAST::setWinDeclSpec( GroupAST::Node& winDeclSpec )
668
m_winDeclSpec = winDeclSpec;
669
if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this );
673
// ------------------------------------------------------------------------
674
InitDeclaratorListAST::InitDeclaratorListAST()
676
m_initDeclaratorList.setAutoDelete( true );
679
void InitDeclaratorListAST::addInitDeclarator( InitDeclaratorAST::Node& decl )
684
decl->setParent( this );
685
m_initDeclaratorList.append( decl.release() );
688
// ------------------------------------------------------------------------
689
DeclaratorAST::DeclaratorAST()
691
m_ptrOpList.setAutoDelete( true );
692
m_arrayDimensionList.setAutoDelete( true );
695
void DeclaratorAST::setSubDeclarator( DeclaratorAST::Node& subDeclarator )
697
m_subDeclarator = subDeclarator;
698
if( m_subDeclarator.get() ) m_subDeclarator->setParent( this );
701
void DeclaratorAST::setDeclaratorId( NameAST::Node& declaratorId )
703
m_declaratorId = declaratorId;
704
if( m_declaratorId.get() ) m_declaratorId->setParent( this );
707
void DeclaratorAST::setBitfieldInitialization( AST::Node& bitfieldInitialization )
709
m_bitfieldInitialization = bitfieldInitialization;
710
if( m_bitfieldInitialization.get() ) m_bitfieldInitialization->setParent( this );
713
void DeclaratorAST::addArrayDimension( AST::Node& arrayDimension )
715
if( !arrayDimension.get() )
718
arrayDimension->setParent( this );
719
m_arrayDimensionList.append( arrayDimension.release() );
722
void DeclaratorAST::setParameterDeclarationClause( ParameterDeclarationClauseAST::Node& parameterDeclarationClause )
724
m_parameterDeclarationClause = parameterDeclarationClause;
725
if( m_parameterDeclarationClause.get() ) m_parameterDeclarationClause->setParent( this );
728
void DeclaratorAST::setConstant( AST::Node& constant )
730
m_constant = constant;
731
if( m_constant.get() ) m_constant->setParent( this );
734
void DeclaratorAST::setExceptionSpecification( GroupAST::Node& exceptionSpecification )
736
m_exceptionSpecification = exceptionSpecification;
737
if( m_exceptionSpecification.get() ) m_exceptionSpecification->setParent( this );
740
void DeclaratorAST::addPtrOp( AST::Node& ptrOp )
745
ptrOp->setParent( this );
746
m_ptrOpList.append( ptrOp.release() );
749
// --------------------------------------------------------------------------
750
InitDeclaratorAST::InitDeclaratorAST()
754
void InitDeclaratorAST::setDeclarator( DeclaratorAST::Node& declarator )
756
m_declarator = declarator;
757
if( m_declarator.get() ) m_declarator->setParent( this );
760
void InitDeclaratorAST::setInitializer( AST::Node& initializer )
762
m_initializer = initializer;
763
if( m_initializer.get() ) m_initializer->setParent( this );
766
// --------------------------------------------------------------------------
767
FunctionDefinitionAST::FunctionDefinitionAST()
771
void FunctionDefinitionAST::setFunctionSpecifier( GroupAST::Node& functionSpecifier )
773
m_functionSpecifier = functionSpecifier;
774
if( m_functionSpecifier.get() ) m_functionSpecifier->setParent( this );
777
void FunctionDefinitionAST::setStorageSpecifier( GroupAST::Node& storageSpecifier )
779
m_storageSpecifier = storageSpecifier;
780
if( m_storageSpecifier.get() ) m_storageSpecifier->setParent( this );
783
void FunctionDefinitionAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
785
m_typeSpec = typeSpec;
786
if( m_typeSpec.get() ) m_typeSpec->setParent( this );
789
void FunctionDefinitionAST::setInitDeclarator( InitDeclaratorAST::Node& initDeclarator )
791
m_initDeclarator = initDeclarator;
792
if( m_initDeclarator.get() ) m_initDeclarator->setParent( this );
795
void FunctionDefinitionAST::setFunctionBody( StatementListAST::Node& functionBody )
797
m_functionBody = functionBody;
798
if( m_functionBody.get() ) m_functionBody->setParent( this );
801
void FunctionDefinitionAST::setWinDeclSpec( GroupAST::Node& winDeclSpec )
803
m_winDeclSpec = winDeclSpec;
804
if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this );
807
// --------------------------------------------------------------------------
808
StatementListAST::StatementListAST()
810
m_statementList.setAutoDelete( true );
813
void StatementListAST::addStatement( StatementAST::Node& statement )
815
if( !statement.get() )
818
statement->setParent( this );
819
m_statementList.append( statement.release() );
822
// --------------------------------------------------------------------------
823
IfStatementAST::IfStatementAST()
827
void IfStatementAST::setCondition( ConditionAST::Node& condition )
829
m_condition = condition;
830
if( m_condition.get() ) m_condition->setParent( this );
833
void IfStatementAST::setStatement( StatementAST::Node& statement )
835
m_statement = statement;
836
if( m_statement.get() ) m_statement->setParent( this );
839
void IfStatementAST::setElseStatement( StatementAST::Node& elseStatement )
841
m_elseStatement = elseStatement;
842
if( m_elseStatement.get() ) m_elseStatement->setParent( this );
845
// --------------------------------------------------------------------------
846
WhileStatementAST::WhileStatementAST()
850
void WhileStatementAST::setCondition( ConditionAST::Node& condition )
852
m_condition = condition;
853
if( m_condition.get() ) m_condition->setParent( this );
856
void WhileStatementAST::setStatement( StatementAST::Node& statement )
858
m_statement = statement;
859
if( m_statement.get() ) m_statement->setParent( this );
862
// --------------------------------------------------------------------------
863
DoStatementAST::DoStatementAST()
867
void DoStatementAST::setCondition( ConditionAST::Node& condition )
869
m_condition = condition;
870
if( m_condition.get() ) m_condition->setParent( this );
873
void DoStatementAST::setStatement( StatementAST::Node& statement )
875
m_statement = statement;
876
if( m_statement.get() ) m_statement->setParent( this );
879
// --------------------------------------------------------------------------
880
ForStatementAST::ForStatementAST()
884
void ForStatementAST::setCondition( ConditionAST::Node& condition )
886
m_condition = condition;
887
if( m_condition.get() ) m_condition->setParent( this );
890
void ForStatementAST::setExpression( AST::Node& expression )
892
m_expression = expression;
893
if( m_expression.get() ) m_expression->setParent( this );
896
void ForStatementAST::setStatement( StatementAST::Node& statement )
898
m_statement = statement;
899
if( m_statement.get() ) m_statement->setParent( this );
902
void ForStatementAST::setInitStatement( StatementAST::Node& initStatement )
904
m_initStatement = initStatement;
905
if( m_initStatement.get() ) m_initStatement->setParent( this );
908
// --------------------------------------------------------------------------
909
ForEachStatementAST::ForEachStatementAST()
913
void ForEachStatementAST::setExpression( AST::Node& expression )
915
m_expression = expression;
916
if( m_expression.get() ) m_expression->setParent( this );
919
void ForEachStatementAST::setStatement( StatementAST::Node& statement )
921
m_statement = statement;
922
if( m_statement.get() ) m_statement->setParent( this );
925
void ForEachStatementAST::setInitStatement( StatementAST::Node& initStatement )
927
m_initStatement = initStatement;
928
if( m_initStatement.get() ) m_initStatement->setParent( this );
931
// --------------------------------------------------------------------------
932
SwitchStatementAST::SwitchStatementAST()
936
void SwitchStatementAST::setCondition( ConditionAST::Node& condition )
938
m_condition = condition;
939
if( m_condition.get() ) m_condition->setParent( this );
942
void SwitchStatementAST::setStatement( StatementAST::Node& statement )
944
m_statement = statement;
945
if( m_statement.get() ) m_statement->setParent( this );
948
// --------------------------------------------------------------------------
949
CatchStatementListAST::CatchStatementListAST()
951
m_statementList.setAutoDelete( true );
954
void CatchStatementListAST::addStatement( CatchStatementAST::Node& statement )
956
if( !statement.get() )
959
statement->setParent( this );
960
m_statementList.append( statement.release() );
963
// --------------------------------------------------------------------------
964
CatchStatementAST::CatchStatementAST()
968
void CatchStatementAST::setCondition( ConditionAST::Node& condition )
970
m_condition = condition;
971
if( m_condition.get() ) m_condition->setParent( this );
974
void CatchStatementAST::setStatement( StatementAST::Node& statement )
976
m_statement = statement;
977
if( m_statement.get() ) m_statement->setParent( this );
980
// --------------------------------------------------------------------------
981
TryBlockStatementAST::TryBlockStatementAST()
985
void TryBlockStatementAST::setStatement( StatementAST::Node& statement )
987
m_statement = statement;
988
if( m_statement.get() ) m_statement->setParent( this );
991
void TryBlockStatementAST::setCatchStatementList( CatchStatementListAST::Node& statementList )
993
m_catchStatementList = statementList;
994
if( m_catchStatementList.get() ) m_catchStatementList->setParent( this );
997
// --------------------------------------------------------------------------
998
DeclarationStatementAST::DeclarationStatementAST()
1002
void DeclarationStatementAST::setDeclaration( DeclarationAST::Node& declaration )
1004
m_declaration = declaration;
1005
if( m_declaration.get() ) m_declaration->setParent( this );
1008
// --------------------------------------------------------------------------
1009
ExpressionStatementAST::ExpressionStatementAST()
1013
void ExpressionStatementAST::setExpression( AST::Node& expression )
1015
m_expression = expression;
1016
if( m_expression.get() ) m_expression->setParent( this );
1020
// --------------------------------------------------------------------------
1021
ParameterDeclarationAST::ParameterDeclarationAST()
1025
void ParameterDeclarationAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
1027
m_typeSpec = typeSpec;
1028
if( m_typeSpec.get() ) m_typeSpec->setParent( this );
1031
void ParameterDeclarationAST::setDeclarator( DeclaratorAST::Node& declarator )
1033
m_declarator = declarator;
1034
if( m_declarator.get() ) m_declarator->setParent( this );
1037
void ParameterDeclarationAST::setExpression( AST::Node& expression )
1039
m_expression = expression;
1040
if( m_expression.get() ) m_expression->setParent( this );
1043
QString ParameterDeclarationAST::text() const
1046
if( m_typeSpec.get() )
1047
str += m_typeSpec->text() + " ";
1049
if( m_declarator.get() )
1050
str += m_declarator->text();
1052
if( m_expression.get() )
1053
str += QString( " = " ) + m_expression->text();
1058
// --------------------------------------------------------------------------
1059
ParameterDeclarationListAST::ParameterDeclarationListAST()
1061
m_parameterList.setAutoDelete( true );
1064
void ParameterDeclarationListAST::addParameter( ParameterDeclarationAST::Node& parameter )
1066
if( !parameter.get() )
1069
parameter->setParent( this );
1070
m_parameterList.append( parameter.release() );
1073
QString ParameterDeclarationListAST::text() const
1077
QPtrListIterator<ParameterDeclarationAST> it( m_parameterList );
1078
while( it.current() ){
1079
l.append( it.current()->text() );
1083
return l.join( ", " );
1087
// --------------------------------------------------------------------------
1088
ParameterDeclarationClauseAST::ParameterDeclarationClauseAST()
1092
void ParameterDeclarationClauseAST::setParameterDeclarationList( ParameterDeclarationListAST::Node& parameterDeclarationList )
1094
m_parameterDeclarationList = parameterDeclarationList;
1095
if( m_parameterDeclarationList.get() ) m_parameterDeclarationList->setParent( this );
1098
void ParameterDeclarationClauseAST::setEllipsis( AST::Node& ellipsis )
1100
m_ellipsis = ellipsis;
1101
if( m_ellipsis.get() ) m_ellipsis->setParent( this );
1104
QString ParameterDeclarationClauseAST::text() const
1108
if( m_parameterDeclarationList.get() )
1109
str += m_parameterDeclarationList->text();
1111
if( m_ellipsis.get() )
1118
// --------------------------------------------------------------------------
1119
GroupAST::GroupAST()
1121
m_nodeList.setAutoDelete( true );
1124
void GroupAST::addNode( AST::Node& node )
1129
node->setParent( this );
1130
m_nodeList.append( node.release() );
1133
QString GroupAST::text() const
1137
QPtrListIterator<AST> it( m_nodeList );
1138
while( it.current() ){
1139
l.append( it.current()->text() );
1143
return l.join( " " );
1146
// --------------------------------------------------------------------------
1147
AccessDeclarationAST::AccessDeclarationAST()
1149
m_accessList.setAutoDelete( true );
1152
void AccessDeclarationAST::addAccess( AST::Node& access )
1157
access->setParent( this );
1158
m_accessList.append( access.release() );
1161
QString AccessDeclarationAST::text() const
1165
QPtrListIterator<AST> it( m_accessList );
1166
while( it.current() ){
1167
l.append( it.current()->text() );
1171
return l.join( " " );
1174
// --------------------------------------------------------------------------
1175
TypeParameterAST::TypeParameterAST()
1179
void TypeParameterAST::setKind( AST::Node& kind )
1182
if( m_kind.get() ) m_kind->setParent( this );
1185
void TypeParameterAST::setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList )
1187
m_templateParameterList = templateParameterList;
1188
if( m_templateParameterList.get() ) m_templateParameterList->setParent( this );
1191
void TypeParameterAST::setName( NameAST::Node& name )
1194
if( m_name.get() ) m_name->setParent( this );
1197
void TypeParameterAST::setTypeId( AST::Node& typeId )
1200
if( m_typeId.get() ) m_typeId->setParent( this );
1203
// --------------------------------------------------------------------------
1204
TemplateParameterAST::TemplateParameterAST()
1208
void TemplateParameterAST::setTypeParameter( TypeParameterAST::Node& typeParameter )
1210
m_typeParameter = typeParameter;
1211
if( m_typeParameter.get() ) m_typeParameter->setParent( this );
1214
void TemplateParameterAST::setTypeValueParameter( ParameterDeclarationAST::Node& typeValueParameter )
1216
m_typeValueParameter = typeValueParameter;
1217
if( m_typeValueParameter.get() ) m_typeValueParameter->setParent( this );
1220
// --------------------------------------------------------------------------
1221
TemplateParameterListAST::TemplateParameterListAST()
1223
m_templateParameterList.setAutoDelete( true );
1226
void TemplateParameterListAST::addTemplateParameter( TemplateParameterAST::Node& templateParameter )
1228
if( !templateParameter.get() )
1231
templateParameter->setParent( this );
1232
m_templateParameterList.append( templateParameter.release() );
1235
// --------------------------------------------------------------------------
1236
ConditionAST::ConditionAST()
1240
void ConditionAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec )
1242
m_typeSpec = typeSpec;
1243
if( m_typeSpec.get() ) m_typeSpec->setParent( this );
1246
void ConditionAST::setDeclarator( DeclaratorAST::Node& declarator )
1248
m_declarator = declarator;
1249
if( m_declarator.get() ) m_declarator->setParent( this );
1252
void ConditionAST::setExpression( AST::Node& expression )
1254
m_expression = expression;
1255
if( m_expression.get() ) m_expression->setParent( this );
1258
void ClassSpecifierAST::setWinDeclSpec( GroupAST::Node & winDeclSpec )
1260
m_winDeclSpec = winDeclSpec;
1261
if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this );