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