KDevelop API Documentation

lib/cppparser/ast.cpp

Go to the documentation of this file.
00001 /* This file is part of KDevelop 00002 Copyright (C) 2002,2003 Roberto Raggi <roberto@kdevelop.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #include "ast.h" 00021 #include <qstringlist.h> 00022 #include <kdebug.h> 00023 00024 QString nodeTypeToString( int type ) 00025 { 00026 switch( type ) 00027 { 00028 case NodeType_Generic: 00029 return "Generic"; 00030 case NodeType_TemplateArgumentList: 00031 return "TemplateArgumentList"; 00032 case NodeType_ClassOrNamespaceName: 00033 return "ClassOrNamespaceName"; 00034 case NodeType_Name: 00035 return "Name"; 00036 case NodeType_Declaration: 00037 return "Declaration"; 00038 case NodeType_TypeSpecifier: 00039 return "TypeSpecifier"; 00040 case NodeType_BaseSpecifier: 00041 return "BaseSpecifier"; 00042 case NodeType_BaseClause: 00043 return "BaseClause"; 00044 case NodeType_ClassSpecifier: 00045 return "ClassSpecifier"; 00046 case NodeType_Enumerator: 00047 return "Enumerator"; 00048 case NodeType_EnumSpecifier: 00049 return "EnumSpecifier"; 00050 case NodeType_ElaboratedTypeSpecifier: 00051 return "ElaboratedTypeSpecifier"; 00052 case NodeType_LinkageBody: 00053 return "LinkageBody"; 00054 case NodeType_LinkageSpecification: 00055 return "LinkageSpecification"; 00056 case NodeType_Namespace: 00057 return "Namespace"; 00058 case NodeType_NamespaceAlias: 00059 return "NamespaceAlias"; 00060 case NodeType_Using: 00061 return "Using"; 00062 case NodeType_UsingDirective: 00063 return "UsingDirective"; 00064 case NodeType_InitDeclaratorList: 00065 return "InitDeclaratorList"; 00066 case NodeType_Typedef: 00067 return "Typedef"; 00068 case NodeType_Declarator: 00069 return "Declarator"; 00070 case NodeType_InitDeclarator: 00071 return "InitDeclarator"; 00072 case NodeType_TemplateDeclaration: 00073 return "TemplateDeclaration"; 00074 case NodeType_SimpleDeclaration: 00075 return "SimpleDeclaration"; 00076 case NodeType_Statement: 00077 return "Statement"; 00078 case NodeType_IfStatement: 00079 return "IfStatement"; 00080 case NodeType_WhileStatement: 00081 return "WhileStatement"; 00082 case NodeType_DoStatement: 00083 return "DoStatement"; 00084 case NodeType_ForStatement: 00085 return "ForStatement"; 00086 case NodeType_SwitchStatement: 00087 return "SwitchStatement"; 00088 case NodeType_DeclarationStatement: 00089 return "DeclarationStatement"; 00090 case NodeType_StatementList: 00091 return "StatementList"; 00092 case NodeType_TranslationUnit: 00093 return "TranslationUnit"; 00094 case NodeType_FunctionDefinition: 00095 return "FunctionDefinition"; 00096 case NodeType_ExpressionStatement: 00097 return "ExpressionStatement"; 00098 case NodeType_ParameterDeclaration: 00099 return "ParameterDeclaration"; 00100 case NodeType_ParameterDeclarationList: 00101 return "ParameterDeclarationList"; 00102 case NodeType_ParameterDeclarationClause: 00103 return "ParameterDeclarationClause"; 00104 case NodeType_Group: 00105 return "Group"; 00106 case NodeType_AccessDeclaration: 00107 return "AccessDeclaration"; 00108 case NodeType_TypeParameter: 00109 return "TypeParameter"; 00110 case NodeType_TemplateParameter: 00111 return "TemplateParameter"; 00112 case NodeType_TemplateParameterList: 00113 return "TemplateParameterList"; 00114 case NodeType_Condition: 00115 return "Condition"; 00116 case NodeType_Custom: 00117 return "Custom"; 00118 } 00119 00120 return QString::null; 00121 } 00122 00123 00124 // ------------------------------------------------------------------------ 00125 AST::AST() 00126 : m_nodeType( NodeType_Generic ), m_parent( 0 ), 00127 m_startLine( 0 ), m_startColumn( 0 ), 00128 m_endLine( 0 ), m_endColumn( 0 ) 00129 { 00130 #ifndef CPPPARSER_NO_CHILDREN 00131 m_children.setAutoDelete( false ); 00132 #endif 00133 } 00134 00135 AST::~AST() 00136 { 00137 #ifndef CPPPARSER_NO_CHILDREN 00138 if( m_parent ) 00139 m_parent->removeChild( this ); 00140 #endif 00141 } 00142 00143 void AST::setStartPosition( int line, int col ) 00144 { 00145 m_startLine = line; 00146 m_startColumn = col; 00147 } 00148 00149 void AST::getStartPosition( int* line, int* col ) const 00150 { 00151 if( line ) 00152 *line = m_startLine; 00153 00154 if( col ) 00155 * col = m_startColumn; 00156 } 00157 00158 void AST::setEndPosition( int line, int col ) 00159 { 00160 m_endLine = line; 00161 m_endColumn = col; 00162 } 00163 00164 void AST::getEndPosition( int* line, int* col ) const 00165 { 00166 if( line ) 00167 *line = m_endLine; 00168 00169 if( col ) 00170 * col = m_endColumn; 00171 } 00172 00173 void AST::setParent( AST* parent ) 00174 { 00175 #ifndef CPPPARSER_NO_CHILDREN 00176 if( m_parent ) 00177 m_parent->removeChild( this ); 00178 #endif 00179 00180 m_parent = parent; 00181 00182 #ifndef CPPPARSER_NO_CHILDREN 00183 if( m_parent ) 00184 m_parent->appendChild( this ); 00185 #endif 00186 } 00187 00188 #ifndef CPPPARSER_NO_CHILDREN 00189 void AST::appendChild( AST* child ) 00190 { 00191 m_children.append( child ); 00192 } 00193 00194 void AST::removeChild( AST* child ) 00195 { 00196 m_children.remove( child ); 00197 } 00198 #endif 00199 00200 // ------------------------------------------------------------------------ 00201 NameAST::NameAST() 00202 : m_global( false ) 00203 { 00204 m_classOrNamespaceNameList.setAutoDelete( true ); 00205 } 00206 00207 void NameAST::setGlobal( bool b ) 00208 { 00209 m_global = b; 00210 } 00211 00212 void NameAST::setUnqualifiedName( ClassOrNamespaceNameAST::Node& unqualifiedName ) 00213 { 00214 m_unqualifiedName = unqualifiedName; 00215 if( m_unqualifiedName.get() ) m_unqualifiedName->setParent( this ); 00216 } 00217 00218 void NameAST::addClassOrNamespaceName( ClassOrNamespaceNameAST::Node& classOrNamespaceName ) 00219 { 00220 if( !classOrNamespaceName.get() ) 00221 return; 00222 00223 classOrNamespaceName->setParent( this ); 00224 m_classOrNamespaceNameList.append( classOrNamespaceName.release() ); 00225 } 00226 00227 QString NameAST::text() const 00228 { 00229 if( !m_unqualifiedName.get() ) 00230 return QString::null; 00231 00232 QString str; 00233 00234 if( m_global ) 00235 str += "::"; 00236 00237 QStringList l; 00238 QPtrListIterator<ClassOrNamespaceNameAST> it( m_classOrNamespaceNameList ); 00239 while( it.current() ){ 00240 str += it.current()->text() + "::"; 00241 ++it; 00242 } 00243 00244 if( m_unqualifiedName.get() ) 00245 str += m_unqualifiedName->text(); 00246 00247 return str; 00248 } 00249 00250 // ------------------------------------------------------------------------ 00251 DeclarationAST::DeclarationAST() 00252 { 00253 } 00254 00255 // ------------------------------------------------------------------------ 00256 LinkageBodyAST::LinkageBodyAST() 00257 { 00258 m_declarationList.setAutoDelete( true ); 00259 } 00260 00261 void LinkageBodyAST::addDeclaration( DeclarationAST::Node& ast ) 00262 { 00263 if( !ast.get() ) 00264 return; 00265 00266 ast->setParent( this ); 00267 m_declarationList.append( ast.release() ); 00268 } 00269 00270 // ------------------------------------------------------------------------ 00271 LinkageSpecificationAST::LinkageSpecificationAST() 00272 { 00273 } 00274 00275 void LinkageSpecificationAST::setExternType( AST::Node& externType ) 00276 { 00277 m_externType = externType; 00278 if( m_externType.get() ) m_externType->setParent( this ); 00279 } 00280 00281 void LinkageSpecificationAST::setLinkageBody( LinkageBodyAST::Node& linkageBody ) 00282 { 00283 m_linkageBody = linkageBody; 00284 if( m_linkageBody.get() ) m_linkageBody->setParent( this ); 00285 } 00286 00287 void LinkageSpecificationAST::setDeclaration( DeclarationAST::Node& decl ) 00288 { 00289 m_declaration = decl; 00290 if( m_declaration.get() ) m_declaration->setParent( this ); 00291 } 00292 00293 // ------------------------------------------------------------------------ 00294 TranslationUnitAST::TranslationUnitAST() 00295 { 00296 //kdDebug(9007) << "++ TranslationUnitAST::TranslationUnitAST()" << endl; 00297 m_declarationList.setAutoDelete( true ); 00298 } 00299 00300 void TranslationUnitAST::addDeclaration( DeclarationAST::Node& ast ) 00301 { 00302 if( !ast.get() ) 00303 return; 00304 00305 ast->setParent( this ); 00306 m_declarationList.append( ast.release() ); 00307 } 00308 00309 // ------------------------------------------------------------------------ 00310 NamespaceAST::NamespaceAST() 00311 { 00312 } 00313 00314 void NamespaceAST::setNamespaceName( AST::Node& namespaceName ) 00315 { 00316 m_namespaceName = namespaceName; 00317 if( m_namespaceName.get() ) m_namespaceName->setParent( this ); 00318 } 00319 00320 void NamespaceAST::setLinkageBody( LinkageBodyAST::Node& linkageBody ) 00321 { 00322 m_linkageBody = linkageBody; 00323 if( m_linkageBody.get() ) m_linkageBody->setParent( this ); 00324 } 00325 00326 00327 // ------------------------------------------------------------------------ 00328 NamespaceAliasAST::NamespaceAliasAST() 00329 { 00330 } 00331 00332 void NamespaceAliasAST::setNamespaceName( AST::Node& namespaceName ) 00333 { 00334 m_namespaceName = namespaceName; 00335 if( m_namespaceName.get() ) m_namespaceName->setParent( this ); 00336 } 00337 00338 void NamespaceAliasAST::setAliasName( NameAST::Node& name ) 00339 { 00340 m_aliasName = name; 00341 if( m_aliasName.get() ) m_aliasName->setParent( this ); 00342 } 00343 00344 // ------------------------------------------------------------------------ 00345 UsingAST::UsingAST() 00346 { 00347 } 00348 00349 void UsingAST::setTypeName( AST::Node& typeName ) 00350 { 00351 m_typeName = typeName; 00352 if( m_typeName.get() ) m_typeName->setParent( this ); 00353 } 00354 00355 void UsingAST::setName( NameAST::Node& name ) 00356 { 00357 m_name = name; 00358 if( m_name.get() ) m_name->setParent( this ); 00359 } 00360 00361 // ------------------------------------------------------------------------ 00362 UsingDirectiveAST::UsingDirectiveAST() 00363 { 00364 } 00365 00366 void UsingDirectiveAST::setName( NameAST::Node& name ) 00367 { 00368 m_name = name; 00369 if( m_name.get() ) m_name->setParent( this ); 00370 } 00371 00372 TypedefAST::TypedefAST() 00373 { 00374 } 00375 00376 void TypeSpecifierAST::setName( NameAST::Node& name ) 00377 { 00378 m_name = name; 00379 if( m_name.get() ) m_name->setParent( this ); 00380 } 00381 00382 void TypedefAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec ) 00383 { 00384 m_typeSpec = typeSpec; 00385 if( m_typeSpec.get() ) m_typeSpec->setParent( this ); 00386 } 00387 00388 void TypedefAST::setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList ) 00389 { 00390 m_initDeclaratorList = initDeclaratorList; 00391 if( m_initDeclaratorList.get() ) m_initDeclaratorList->setParent( this ); 00392 } 00393 00394 // ------------------------------------------------------------------------ 00395 TemplateArgumentListAST::TemplateArgumentListAST() 00396 { 00397 m_argumentList.setAutoDelete( true ); 00398 } 00399 00400 void TemplateArgumentListAST::addArgument( AST::Node& arg ) 00401 { 00402 if( !arg.get() ) 00403 return; 00404 00405 arg->setParent( this ); 00406 m_argumentList.append( arg.release() ); 00407 } 00408 00409 QString TemplateArgumentListAST::text() const 00410 { 00411 QStringList l; 00412 00413 QPtrListIterator<AST> it( m_argumentList ); 00414 while( it.current() ){ 00415 l.append( it.current()->text() ); 00416 ++it; 00417 } 00418 00419 return l.join( ", " ); 00420 } 00421 00422 // ------------------------------------------------------------------------ 00423 TemplateDeclarationAST::TemplateDeclarationAST() 00424 { 00425 } 00426 00427 void TemplateDeclarationAST::setExported( AST::Node& exported ) 00428 { 00429 m_exported = exported; 00430 if( m_exported.get() ) m_exported->setParent( this ); 00431 } 00432 00433 void TemplateDeclarationAST::setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList ) 00434 { 00435 m_templateParameterList = templateParameterList; 00436 if( m_templateParameterList.get() ) m_templateParameterList->setParent( this ); 00437 } 00438 00439 void TemplateDeclarationAST::setDeclaration( DeclarationAST::Node& declaration ) 00440 { 00441 m_declaration = declaration; 00442 if( m_declaration.get() ) m_declaration->setParent( this ); 00443 } 00444 00445 // ------------------------------------------------------------------------ 00446 ClassOrNamespaceNameAST::ClassOrNamespaceNameAST() 00447 { 00448 } 00449 00450 void ClassOrNamespaceNameAST::setName( AST::Node& name ) 00451 { 00452 m_name = name; 00453 if( m_name.get() ) m_name->setParent( this ); 00454 } 00455 00456 void ClassOrNamespaceNameAST::setTemplateArgumentList( TemplateArgumentListAST::Node& templateArgumentList ) 00457 { 00458 m_templateArgumentList = templateArgumentList; 00459 if( m_templateArgumentList.get() ) m_templateArgumentList->setParent( this ); 00460 } 00461 00462 QString ClassOrNamespaceNameAST::text() const 00463 { 00464 if( !m_name.get() ) 00465 return QString::null; 00466 00467 QString str = m_name->text(); 00468 if( m_templateArgumentList.get() ) 00469 str += QString::fromLatin1("< ") + m_templateArgumentList->text() + QString::fromLatin1(" >"); 00470 00471 return str; 00472 } 00473 00474 // ------------------------------------------------------------------------ 00475 TypeSpecifierAST::TypeSpecifierAST() 00476 { 00477 } 00478 00479 void TypeSpecifierAST::setCvQualify( GroupAST::Node& cvQualify ) 00480 { 00481 m_cvQualify = cvQualify; 00482 if( m_cvQualify.get() ) m_cvQualify->setParent( this ); 00483 } 00484 00485 void TypeSpecifierAST::setCv2Qualify( GroupAST::Node& cv2Qualify ) 00486 { 00487 m_cv2Qualify = cv2Qualify; 00488 if( m_cv2Qualify.get() ) m_cv2Qualify->setParent( this ); 00489 } 00490 00491 QString TypeSpecifierAST::text() const 00492 { 00493 QString str; 00494 00495 if( m_cvQualify.get() ) 00496 str += m_cvQualify->text() + " "; 00497 00498 if( m_name.get() ) 00499 str += m_name->text(); 00500 00501 if( m_cv2Qualify.get() ) 00502 str += QString(" ") + m_cv2Qualify->text(); 00503 00504 return str; 00505 } 00506 00507 // ------------------------------------------------------------------------ 00508 ClassSpecifierAST::ClassSpecifierAST() 00509 { 00510 m_declarationList.setAutoDelete( true ); 00511 } 00512 00513 void ClassSpecifierAST::setClassKey( AST::Node& classKey ) 00514 { 00515 m_classKey = classKey; 00516 if( m_classKey.get() ) m_classKey->setParent( this ); 00517 } 00518 00519 void ClassSpecifierAST::addDeclaration( DeclarationAST::Node& declaration ) 00520 { 00521 if( !declaration.get() ) 00522 return; 00523 00524 declaration->setParent( this ); 00525 m_declarationList.append( declaration.release() ); 00526 } 00527 00528 void ClassSpecifierAST::setBaseClause( BaseClauseAST::Node& baseClause ) 00529 { 00530 m_baseClause = baseClause; 00531 if( m_baseClause.get() ) m_baseClause->setParent( this ); 00532 } 00533 00534 // ------------------------------------------------------------------------ 00535 EnumSpecifierAST::EnumSpecifierAST() 00536 { 00537 m_enumeratorList.setAutoDelete( true ); 00538 } 00539 00540 void EnumSpecifierAST::addEnumerator( EnumeratorAST::Node& enumerator ) 00541 { 00542 if( !enumerator.get() ) 00543 return; 00544 00545 enumerator->setParent( this ); 00546 m_enumeratorList.append( enumerator.release() ); 00547 } 00548 00549 00550 // ------------------------------------------------------------------------ 00551 ElaboratedTypeSpecifierAST::ElaboratedTypeSpecifierAST() 00552 { 00553 } 00554 00555 void ElaboratedTypeSpecifierAST::setKind( AST::Node& kind ) 00556 { 00557 m_kind = kind; 00558 if( m_kind.get() ) m_kind->setParent( this ); 00559 } 00560 00561 QString ElaboratedTypeSpecifierAST::text() const 00562 { 00563 if( m_kind.get() ) 00564 return m_kind->text() + " " + TypeSpecifierAST::text(); 00565 00566 return TypeSpecifierAST::text(); 00567 } 00568 00569 // ------------------------------------------------------------------------ 00570 StatementAST::StatementAST() 00571 { 00572 } 00573 00574 // ------------------------------------------------------------------------ 00575 EnumeratorAST::EnumeratorAST() 00576 { 00577 } 00578 00579 void EnumeratorAST::setId( AST::Node& id ) 00580 { 00581 m_id = id; 00582 if( m_id.get() ) m_id->setParent( this ); 00583 } 00584 00585 void EnumeratorAST::setExpr( AST::Node& expr ) 00586 { 00587 m_expr = expr; 00588 if( m_expr.get() ) m_expr->setParent( this ); 00589 } 00590 00591 // ------------------------------------------------------------------------ 00592 BaseClauseAST::BaseClauseAST() 00593 { 00594 m_baseSpecifierList.setAutoDelete( true ); 00595 } 00596 00597 void BaseClauseAST::addBaseSpecifier( BaseSpecifierAST::Node& baseSpecifier ) 00598 { 00599 if( !baseSpecifier.get() ) 00600 return; 00601 00602 baseSpecifier->setParent( this ); 00603 m_baseSpecifierList.append( baseSpecifier.release() ); 00604 } 00605 00606 // ------------------------------------------------------------------------ 00607 BaseSpecifierAST::BaseSpecifierAST() 00608 { 00609 } 00610 00611 void BaseSpecifierAST::setIsVirtual( AST::Node& isVirtual ) 00612 { 00613 m_isVirtual = isVirtual; 00614 if( m_isVirtual.get() ) m_isVirtual->setParent( this ); 00615 } 00616 00617 void BaseSpecifierAST::setAccess( AST::Node& access ) 00618 { 00619 m_access = access; 00620 if( m_access.get() ) m_access->setParent( this ); 00621 } 00622 00623 void BaseSpecifierAST::setName( NameAST::Node& name ) 00624 { 00625 m_name = name; 00626 if( m_name.get() ) m_name->setParent( this ); 00627 } 00628 00629 // ------------------------------------------------------------------------ 00630 SimpleDeclarationAST::SimpleDeclarationAST() 00631 { 00632 } 00633 00634 void SimpleDeclarationAST::setFunctionSpecifier( GroupAST::Node& functionSpecifier ) 00635 { 00636 m_functionSpecifier = functionSpecifier; 00637 if( m_functionSpecifier.get() ) m_functionSpecifier->setParent( this ); 00638 } 00639 00640 void SimpleDeclarationAST::setStorageSpecifier( GroupAST::Node& storageSpecifier ) 00641 { 00642 m_storageSpecifier = storageSpecifier; 00643 if( m_storageSpecifier.get() ) m_storageSpecifier->setParent( this ); 00644 } 00645 00646 void SimpleDeclarationAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec ) 00647 { 00648 m_typeSpec = typeSpec; 00649 if( m_typeSpec.get() ) m_typeSpec->setParent( this ); 00650 } 00651 00652 void SimpleDeclarationAST::setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList ) 00653 { 00654 m_initDeclaratorList = initDeclaratorList; 00655 if( m_initDeclaratorList.get() ) m_initDeclaratorList->setParent( this ); 00656 } 00657 00658 void SimpleDeclarationAST::setWinDeclSpec( GroupAST::Node& winDeclSpec ) 00659 { 00660 m_winDeclSpec = winDeclSpec; 00661 if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this ); 00662 } 00663 00664 00665 // ------------------------------------------------------------------------ 00666 InitDeclaratorListAST::InitDeclaratorListAST() 00667 { 00668 m_initDeclaratorList.setAutoDelete( true ); 00669 } 00670 00671 void InitDeclaratorListAST::addInitDeclarator( InitDeclaratorAST::Node& decl ) 00672 { 00673 if( !decl.get() ) 00674 return; 00675 00676 decl->setParent( this ); 00677 m_initDeclaratorList.append( decl.release() ); 00678 } 00679 00680 // ------------------------------------------------------------------------ 00681 DeclaratorAST::DeclaratorAST() 00682 { 00683 m_ptrOpList.setAutoDelete( true ); 00684 m_arrayDimensionList.setAutoDelete( true ); 00685 } 00686 00687 void DeclaratorAST::setSubDeclarator( DeclaratorAST::Node& subDeclarator ) 00688 { 00689 m_subDeclarator = subDeclarator; 00690 if( m_subDeclarator.get() ) m_subDeclarator->setParent( this ); 00691 } 00692 00693 void DeclaratorAST::setDeclaratorId( NameAST::Node& declaratorId ) 00694 { 00695 m_declaratorId = declaratorId; 00696 if( m_declaratorId.get() ) m_declaratorId->setParent( this ); 00697 } 00698 00699 void DeclaratorAST::setBitfieldInitialization( AST::Node& bitfieldInitialization ) 00700 { 00701 m_bitfieldInitialization = bitfieldInitialization; 00702 if( m_bitfieldInitialization.get() ) m_bitfieldInitialization->setParent( this ); 00703 } 00704 00705 void DeclaratorAST::addArrayDimension( AST::Node& arrayDimension ) 00706 { 00707 if( !arrayDimension.get() ) 00708 return; 00709 00710 arrayDimension->setParent( this ); 00711 m_arrayDimensionList.append( arrayDimension.release() ); 00712 } 00713 00714 void DeclaratorAST::setParameterDeclarationClause( ParameterDeclarationClauseAST::Node& parameterDeclarationClause ) 00715 { 00716 m_parameterDeclarationClause = parameterDeclarationClause; 00717 if( m_parameterDeclarationClause.get() ) m_parameterDeclarationClause->setParent( this ); 00718 } 00719 00720 void DeclaratorAST::setConstant( AST::Node& constant ) 00721 { 00722 m_constant = constant; 00723 if( m_constant.get() ) m_constant->setParent( this ); 00724 } 00725 00726 void DeclaratorAST::setExceptionSpecification( GroupAST::Node& exceptionSpecification ) 00727 { 00728 m_exceptionSpecification = exceptionSpecification; 00729 if( m_exceptionSpecification.get() ) m_exceptionSpecification->setParent( this ); 00730 } 00731 00732 void DeclaratorAST::addPtrOp( AST::Node& ptrOp ) 00733 { 00734 if( !ptrOp.get() ) 00735 return; 00736 00737 ptrOp->setParent( this ); 00738 m_ptrOpList.append( ptrOp.release() ); 00739 } 00740 00741 // -------------------------------------------------------------------------- 00742 InitDeclaratorAST::InitDeclaratorAST() 00743 { 00744 } 00745 00746 void InitDeclaratorAST::setDeclarator( DeclaratorAST::Node& declarator ) 00747 { 00748 m_declarator = declarator; 00749 if( m_declarator.get() ) m_declarator->setParent( this ); 00750 } 00751 00752 void InitDeclaratorAST::setInitializer( AST::Node& initializer ) 00753 { 00754 m_initializer = initializer; 00755 if( m_initializer.get() ) m_initializer->setParent( this ); 00756 } 00757 00758 // -------------------------------------------------------------------------- 00759 FunctionDefinitionAST::FunctionDefinitionAST() 00760 { 00761 } 00762 00763 void FunctionDefinitionAST::setFunctionSpecifier( GroupAST::Node& functionSpecifier ) 00764 { 00765 m_functionSpecifier = functionSpecifier; 00766 if( m_functionSpecifier.get() ) m_functionSpecifier->setParent( this ); 00767 } 00768 00769 void FunctionDefinitionAST::setStorageSpecifier( GroupAST::Node& storageSpecifier ) 00770 { 00771 m_storageSpecifier = storageSpecifier; 00772 if( m_storageSpecifier.get() ) m_storageSpecifier->setParent( this ); 00773 } 00774 00775 void FunctionDefinitionAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec ) 00776 { 00777 m_typeSpec = typeSpec; 00778 if( m_typeSpec.get() ) m_typeSpec->setParent( this ); 00779 } 00780 00781 void FunctionDefinitionAST::setInitDeclarator( InitDeclaratorAST::Node& initDeclarator ) 00782 { 00783 m_initDeclarator = initDeclarator; 00784 if( m_initDeclarator.get() ) m_initDeclarator->setParent( this ); 00785 } 00786 00787 void FunctionDefinitionAST::setFunctionBody( StatementListAST::Node& functionBody ) 00788 { 00789 m_functionBody = functionBody; 00790 if( m_functionBody.get() ) m_functionBody->setParent( this ); 00791 } 00792 00793 void FunctionDefinitionAST::setWinDeclSpec( GroupAST::Node& winDeclSpec ) 00794 { 00795 m_winDeclSpec = winDeclSpec; 00796 if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this ); 00797 } 00798 00799 // -------------------------------------------------------------------------- 00800 StatementListAST::StatementListAST() 00801 { 00802 m_statementList.setAutoDelete( true ); 00803 } 00804 00805 void StatementListAST::addStatement( StatementAST::Node& statement ) 00806 { 00807 if( !statement.get() ) 00808 return; 00809 00810 statement->setParent( this ); 00811 m_statementList.append( statement.release() ); 00812 } 00813 00814 // -------------------------------------------------------------------------- 00815 IfStatementAST::IfStatementAST() 00816 { 00817 } 00818 00819 void IfStatementAST::setCondition( ConditionAST::Node& condition ) 00820 { 00821 m_condition = condition; 00822 if( m_condition.get() ) m_condition->setParent( this ); 00823 } 00824 00825 void IfStatementAST::setStatement( StatementAST::Node& statement ) 00826 { 00827 m_statement = statement; 00828 if( m_statement.get() ) m_statement->setParent( this ); 00829 } 00830 00831 void IfStatementAST::setElseStatement( StatementAST::Node& elseStatement ) 00832 { 00833 m_elseStatement = elseStatement; 00834 if( m_elseStatement.get() ) m_elseStatement->setParent( this ); 00835 } 00836 00837 // -------------------------------------------------------------------------- 00838 WhileStatementAST::WhileStatementAST() 00839 { 00840 } 00841 00842 void WhileStatementAST::setCondition( ConditionAST::Node& condition ) 00843 { 00844 m_condition = condition; 00845 if( m_condition.get() ) m_condition->setParent( this ); 00846 } 00847 00848 void WhileStatementAST::setStatement( StatementAST::Node& statement ) 00849 { 00850 m_statement = statement; 00851 if( m_statement.get() ) m_statement->setParent( this ); 00852 } 00853 00854 // -------------------------------------------------------------------------- 00855 DoStatementAST::DoStatementAST() 00856 { 00857 } 00858 00859 void DoStatementAST::setCondition( ConditionAST::Node& condition ) 00860 { 00861 m_condition = condition; 00862 if( m_condition.get() ) m_condition->setParent( this ); 00863 } 00864 00865 void DoStatementAST::setStatement( StatementAST::Node& statement ) 00866 { 00867 m_statement = statement; 00868 if( m_statement.get() ) m_statement->setParent( this ); 00869 } 00870 00871 // -------------------------------------------------------------------------- 00872 ForStatementAST::ForStatementAST() 00873 { 00874 } 00875 00876 void ForStatementAST::setCondition( ConditionAST::Node& condition ) 00877 { 00878 m_condition = condition; 00879 if( m_condition.get() ) m_condition->setParent( this ); 00880 } 00881 00882 void ForStatementAST::setExpression( AST::Node& expression ) 00883 { 00884 m_expression = expression; 00885 if( m_expression.get() ) m_expression->setParent( this ); 00886 } 00887 00888 void ForStatementAST::setStatement( StatementAST::Node& statement ) 00889 { 00890 m_statement = statement; 00891 if( m_statement.get() ) m_statement->setParent( this ); 00892 } 00893 00894 void ForStatementAST::setInitStatement( StatementAST::Node& initStatement ) 00895 { 00896 m_initStatement = initStatement; 00897 if( m_initStatement.get() ) m_initStatement->setParent( this ); 00898 } 00899 00900 // -------------------------------------------------------------------------- 00901 SwitchStatementAST::SwitchStatementAST() 00902 { 00903 } 00904 00905 void SwitchStatementAST::setCondition( ConditionAST::Node& condition ) 00906 { 00907 m_condition = condition; 00908 if( m_condition.get() ) m_condition->setParent( this ); 00909 } 00910 00911 void SwitchStatementAST::setStatement( StatementAST::Node& statement ) 00912 { 00913 m_statement = statement; 00914 if( m_statement.get() ) m_statement->setParent( this ); 00915 } 00916 00917 // -------------------------------------------------------------------------- 00918 DeclarationStatementAST::DeclarationStatementAST() 00919 { 00920 } 00921 00922 void DeclarationStatementAST::setDeclaration( DeclarationAST::Node& declaration ) 00923 { 00924 m_declaration = declaration; 00925 if( m_declaration.get() ) m_declaration->setParent( this ); 00926 } 00927 00928 // -------------------------------------------------------------------------- 00929 ExpressionStatementAST::ExpressionStatementAST() 00930 { 00931 } 00932 00933 void ExpressionStatementAST::setExpression( AST::Node& expression ) 00934 { 00935 m_expression = expression; 00936 if( m_expression.get() ) m_expression->setParent( this ); 00937 } 00938 00939 00940 // -------------------------------------------------------------------------- 00941 ParameterDeclarationAST::ParameterDeclarationAST() 00942 { 00943 } 00944 00945 void ParameterDeclarationAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec ) 00946 { 00947 m_typeSpec = typeSpec; 00948 if( m_typeSpec.get() ) m_typeSpec->setParent( this ); 00949 } 00950 00951 void ParameterDeclarationAST::setDeclarator( DeclaratorAST::Node& declarator ) 00952 { 00953 m_declarator = declarator; 00954 if( m_declarator.get() ) m_declarator->setParent( this ); 00955 } 00956 00957 void ParameterDeclarationAST::setExpression( AST::Node& expression ) 00958 { 00959 m_expression = expression; 00960 if( m_expression.get() ) m_expression->setParent( this ); 00961 } 00962 00963 QString ParameterDeclarationAST::text() const 00964 { 00965 QString str; 00966 if( m_typeSpec.get() ) 00967 str += m_typeSpec->text() + " "; 00968 00969 if( m_declarator.get() ) 00970 str += m_declarator->text(); 00971 00972 if( m_expression.get() ) 00973 str += QString( " = " ) + m_expression->text(); 00974 00975 return str; 00976 } 00977 00978 // -------------------------------------------------------------------------- 00979 ParameterDeclarationListAST::ParameterDeclarationListAST() 00980 { 00981 m_parameterList.setAutoDelete( true ); 00982 } 00983 00984 void ParameterDeclarationListAST::addParameter( ParameterDeclarationAST::Node& parameter ) 00985 { 00986 if( !parameter.get() ) 00987 return; 00988 00989 parameter->setParent( this ); 00990 m_parameterList.append( parameter.release() ); 00991 } 00992 00993 QString ParameterDeclarationListAST::text() const 00994 { 00995 QStringList l; 00996 00997 QPtrListIterator<ParameterDeclarationAST> it( m_parameterList ); 00998 while( it.current() ){ 00999 l.append( it.current()->text() ); 01000 ++it; 01001 } 01002 01003 return l.join( ", " ); 01004 } 01005 01006 01007 // -------------------------------------------------------------------------- 01008 ParameterDeclarationClauseAST::ParameterDeclarationClauseAST() 01009 { 01010 } 01011 01012 void ParameterDeclarationClauseAST::setParameterDeclarationList( ParameterDeclarationListAST::Node& parameterDeclarationList ) 01013 { 01014 m_parameterDeclarationList = parameterDeclarationList; 01015 if( m_parameterDeclarationList.get() ) m_parameterDeclarationList->setParent( this ); 01016 } 01017 01018 void ParameterDeclarationClauseAST::setEllipsis( AST::Node& ellipsis ) 01019 { 01020 m_ellipsis = ellipsis; 01021 if( m_ellipsis.get() ) m_ellipsis->setParent( this ); 01022 } 01023 01024 QString ParameterDeclarationClauseAST::text() const 01025 { 01026 QString str; 01027 01028 if( m_parameterDeclarationList.get() ) 01029 str += m_parameterDeclarationList->text(); 01030 01031 if( m_ellipsis.get() ) 01032 str += " ..."; 01033 01034 return str; 01035 } 01036 01037 01038 // -------------------------------------------------------------------------- 01039 GroupAST::GroupAST() 01040 { 01041 m_nodeList.setAutoDelete( true ); 01042 } 01043 01044 void GroupAST::addNode( AST::Node& node ) 01045 { 01046 if( !node.get() ) 01047 return; 01048 01049 node->setParent( this ); 01050 m_nodeList.append( node.release() ); 01051 } 01052 01053 QString GroupAST::text() const 01054 { 01055 QStringList l; 01056 01057 QPtrListIterator<AST> it( m_nodeList ); 01058 while( it.current() ){ 01059 l.append( it.current()->text() ); 01060 ++it; 01061 } 01062 01063 return l.join( " " ); 01064 } 01065 01066 // -------------------------------------------------------------------------- 01067 AccessDeclarationAST::AccessDeclarationAST() 01068 { 01069 m_accessList.setAutoDelete( true ); 01070 } 01071 01072 void AccessDeclarationAST::addAccess( AST::Node& access ) 01073 { 01074 if( !access.get() ) 01075 return; 01076 01077 access->setParent( this ); 01078 m_accessList.append( access.release() ); 01079 } 01080 01081 QString AccessDeclarationAST::text() const 01082 { 01083 QStringList l; 01084 01085 QPtrListIterator<AST> it( m_accessList ); 01086 while( it.current() ){ 01087 l.append( it.current()->text() ); 01088 ++it; 01089 } 01090 01091 return l.join( " " ); 01092 } 01093 01094 // -------------------------------------------------------------------------- 01095 TypeParameterAST::TypeParameterAST() 01096 { 01097 } 01098 01099 void TypeParameterAST::setKind( AST::Node& kind ) 01100 { 01101 m_kind = kind; 01102 if( m_kind.get() ) m_kind->setParent( this ); 01103 } 01104 01105 void TypeParameterAST::setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList ) 01106 { 01107 m_templateParameterList = templateParameterList; 01108 if( m_templateParameterList.get() ) m_templateParameterList->setParent( this ); 01109 } 01110 01111 void TypeParameterAST::setName( NameAST::Node& name ) 01112 { 01113 m_name = name; 01114 if( m_name.get() ) m_name->setParent( this ); 01115 } 01116 01117 void TypeParameterAST::setTypeId( AST::Node& typeId ) 01118 { 01119 m_typeId = typeId; 01120 if( m_typeId.get() ) m_typeId->setParent( this ); 01121 } 01122 01123 // -------------------------------------------------------------------------- 01124 TemplateParameterAST::TemplateParameterAST() 01125 { 01126 } 01127 01128 void TemplateParameterAST::setTypeParameter( TypeParameterAST::Node& typeParameter ) 01129 { 01130 m_typeParameter = typeParameter; 01131 if( m_typeParameter.get() ) m_typeParameter->setParent( this ); 01132 } 01133 01134 void TemplateParameterAST::setTypeValueParameter( ParameterDeclarationAST::Node& typeValueParameter ) 01135 { 01136 m_typeValueParameter = typeValueParameter; 01137 if( m_typeValueParameter.get() ) m_typeValueParameter->setParent( this ); 01138 } 01139 01140 // -------------------------------------------------------------------------- 01141 TemplateParameterListAST::TemplateParameterListAST() 01142 { 01143 m_templateParameterList.setAutoDelete( true ); 01144 } 01145 01146 void TemplateParameterListAST::addTemplateParameter( TemplateParameterAST::Node& templateParameter ) 01147 { 01148 if( !templateParameter.get() ) 01149 return; 01150 01151 templateParameter->setParent( this ); 01152 m_templateParameterList.append( templateParameter.release() ); 01153 } 01154 01155 // -------------------------------------------------------------------------- 01156 ConditionAST::ConditionAST() 01157 { 01158 } 01159 01160 void ConditionAST::setTypeSpec( TypeSpecifierAST::Node& typeSpec ) 01161 { 01162 m_typeSpec = typeSpec; 01163 if( m_typeSpec.get() ) m_typeSpec->setParent( this ); 01164 } 01165 01166 void ConditionAST::setDeclarator( DeclaratorAST::Node& declarator ) 01167 { 01168 m_declarator = declarator; 01169 if( m_declarator.get() ) m_declarator->setParent( this ); 01170 } 01171 01172 void ConditionAST::setExpression( AST::Node& expression ) 01173 { 01174 m_expression = expression; 01175 if( m_expression.get() ) m_expression->setParent( this ); 01176 } 01177 01178 void ClassSpecifierAST::setWinDeclSpec( GroupAST::Node & winDeclSpec ) 01179 { 01180 m_winDeclSpec = winDeclSpec; 01181 if( m_winDeclSpec.get() ) m_winDeclSpec->setParent( this ); 01182 } 01183
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:07 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003