util/src/script/parser/qscriptast.cpp
changeset 7 f7bc934e204c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtScript module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
       
    10 ** GNU Lesser General Public License Usage
       
    11 ** This file may be used under the terms of the GNU Lesser
       
    12 ** General Public License version 2.1 as published by the Free Software
       
    13 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    14 ** packaging of this file.  Please review the following information to
       
    15 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    16 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    17 **
       
    18 ** If you have questions regarding the use of this file, please contact
       
    19 ** Nokia at qt-info@nokia.com.
       
    20 ** $QT_END_LICENSE$
       
    21 **
       
    22 ****************************************************************************/
       
    23 
       
    24 #include "qscriptast_p.h"
       
    25 
       
    26 #include "qscriptastvisitor_p.h"
       
    27 
       
    28 QT_BEGIN_NAMESPACE
       
    29 
       
    30 namespace QScript { namespace AST {
       
    31 
       
    32 ExpressionNode *Node::expressionCast()
       
    33 {
       
    34     return 0;
       
    35 }
       
    36 
       
    37 BinaryExpression *Node::binaryExpressionCast()
       
    38 {
       
    39     return 0;
       
    40 }
       
    41 
       
    42 Statement *Node::statementCast()
       
    43 {
       
    44     return 0;
       
    45 }
       
    46 
       
    47 ExpressionNode *ExpressionNode::expressionCast()
       
    48 {
       
    49     return this;
       
    50 }
       
    51 
       
    52 BinaryExpression *BinaryExpression::binaryExpressionCast()
       
    53 {
       
    54     return this;
       
    55 }
       
    56 
       
    57 Statement *Statement::statementCast()
       
    58 {
       
    59     return this;
       
    60 }
       
    61 
       
    62 void ThisExpression::accept0(Visitor *visitor)
       
    63 {
       
    64     if (visitor->visit(this)) {
       
    65     }
       
    66 
       
    67     visitor->endVisit(this);
       
    68 }
       
    69 
       
    70 void IdentifierExpression::accept0(Visitor *visitor)
       
    71 {
       
    72     if (visitor->visit(this)) {
       
    73     }
       
    74 
       
    75     visitor->endVisit(this);
       
    76 }
       
    77 
       
    78 void NullExpression::accept0(Visitor *visitor)
       
    79 {
       
    80     if (visitor->visit(this)) {
       
    81     }
       
    82 
       
    83     visitor->endVisit(this);
       
    84 }
       
    85 
       
    86 void TrueLiteral::accept0(Visitor *visitor)
       
    87 {
       
    88     if (visitor->visit(this)) {
       
    89     }
       
    90 
       
    91     visitor->endVisit(this);
       
    92 }
       
    93 
       
    94 void FalseLiteral::accept0(Visitor *visitor)
       
    95 {
       
    96     if (visitor->visit(this)) {
       
    97     }
       
    98 
       
    99     visitor->endVisit(this);
       
   100 }
       
   101 
       
   102 void StringLiteral::accept0(Visitor *visitor)
       
   103 {
       
   104     if (visitor->visit(this)) {
       
   105     }
       
   106 
       
   107     visitor->endVisit(this);
       
   108 }
       
   109 
       
   110 void NumericLiteral::accept0(Visitor *visitor)
       
   111 {
       
   112     if (visitor->visit(this)) {
       
   113     }
       
   114 
       
   115     visitor->endVisit(this);
       
   116 }
       
   117 
       
   118 void RegExpLiteral::accept0(Visitor *visitor)
       
   119 {
       
   120     if (visitor->visit(this)) {
       
   121     }
       
   122 
       
   123     visitor->endVisit(this);
       
   124 }
       
   125 
       
   126 void ArrayLiteral::accept0(Visitor *visitor)
       
   127 {
       
   128     if (visitor->visit(this)) {
       
   129         acceptChild(elements, visitor);
       
   130         acceptChild(elision, visitor);
       
   131     }
       
   132 
       
   133     visitor->endVisit(this);
       
   134 }
       
   135 
       
   136 void ObjectLiteral::accept0(Visitor *visitor)
       
   137 {
       
   138     if (visitor->visit(this)) {
       
   139         acceptChild(properties, visitor);
       
   140     }
       
   141 
       
   142     visitor->endVisit(this);
       
   143 }
       
   144 
       
   145 void ElementList::accept0(Visitor *visitor)
       
   146 {
       
   147     if (visitor->visit(this)) {
       
   148         ElementList *it = this;
       
   149         do {
       
   150             acceptChild(it->elision, visitor);
       
   151             acceptChild(it->expression, visitor);
       
   152             it = it->next;
       
   153         } while (it);
       
   154     }
       
   155 
       
   156     visitor->endVisit(this);
       
   157 }
       
   158 
       
   159 void Elision::accept0(Visitor *visitor)
       
   160 {
       
   161     if (visitor->visit(this)) {
       
   162         // ###
       
   163     }
       
   164 
       
   165     visitor->endVisit(this);
       
   166 }
       
   167 
       
   168 void PropertyNameAndValueList::accept0(Visitor *visitor)
       
   169 {
       
   170     if (visitor->visit(this)) {
       
   171         PropertyNameAndValueList *it = this;
       
   172         do {
       
   173             acceptChild(it->name, visitor);
       
   174             acceptChild(it->value, visitor);
       
   175             it = it->next;
       
   176         } while (it);
       
   177     }
       
   178 
       
   179     visitor->endVisit(this);
       
   180 }
       
   181 
       
   182 void IdentifierPropertyName::accept0(Visitor *visitor)
       
   183 {
       
   184     if (visitor->visit(this)) {
       
   185     }
       
   186 
       
   187     visitor->endVisit(this);
       
   188 }
       
   189 
       
   190 void StringLiteralPropertyName::accept0(Visitor *visitor)
       
   191 {
       
   192     if (visitor->visit(this)) {
       
   193     }
       
   194 
       
   195     visitor->endVisit(this);
       
   196 }
       
   197 
       
   198 void NumericLiteralPropertyName::accept0(Visitor *visitor)
       
   199 {
       
   200     if (visitor->visit(this)) {
       
   201     }
       
   202 
       
   203     visitor->endVisit(this);
       
   204 }
       
   205 
       
   206 void ArrayMemberExpression::accept0(Visitor *visitor)
       
   207 {
       
   208     if (visitor->visit(this)) {
       
   209         acceptChild(base, visitor);
       
   210         acceptChild(expression, visitor);
       
   211     }
       
   212 
       
   213     visitor->endVisit(this);
       
   214 }
       
   215 
       
   216 void FieldMemberExpression::accept0(Visitor *visitor)
       
   217 {
       
   218     if (visitor->visit(this)) {
       
   219         acceptChild(base, visitor);
       
   220     }
       
   221 
       
   222     visitor->endVisit(this);
       
   223 }
       
   224 
       
   225 void NewMemberExpression::accept0(Visitor *visitor)
       
   226 {
       
   227     if (visitor->visit(this)) {
       
   228         acceptChild(base, visitor);
       
   229         acceptChild(arguments, visitor);
       
   230     }
       
   231 
       
   232     visitor->endVisit(this);
       
   233 }
       
   234 
       
   235 void NewExpression::accept0(Visitor *visitor)
       
   236 {
       
   237     if (visitor->visit(this)) {
       
   238         acceptChild(expression, visitor);
       
   239     }
       
   240 
       
   241     visitor->endVisit(this);
       
   242 }
       
   243 
       
   244 void CallExpression::accept0(Visitor *visitor)
       
   245 {
       
   246     if (visitor->visit(this)) {
       
   247         acceptChild(base, visitor);
       
   248         acceptChild(arguments, visitor);
       
   249     }
       
   250 
       
   251     visitor->endVisit(this);
       
   252 }
       
   253 
       
   254 void ArgumentList::accept0(Visitor *visitor)
       
   255 {
       
   256     if (visitor->visit(this)) {
       
   257         ArgumentList *it = this;
       
   258         do {
       
   259             acceptChild(it->expression, visitor);
       
   260             it = it->next;
       
   261         } while (it);
       
   262     }
       
   263 
       
   264     visitor->endVisit(this);
       
   265 }
       
   266 
       
   267 void PostIncrementExpression::accept0(Visitor *visitor)
       
   268 {
       
   269     if (visitor->visit(this)) {
       
   270         acceptChild(base, visitor);
       
   271     }
       
   272 
       
   273     visitor->endVisit(this);
       
   274 }
       
   275 
       
   276 void PostDecrementExpression::accept0(Visitor *visitor)
       
   277 {
       
   278     if (visitor->visit(this)) {
       
   279         acceptChild(base, visitor);
       
   280     }
       
   281 
       
   282     visitor->endVisit(this);
       
   283 }
       
   284 
       
   285 void DeleteExpression::accept0(Visitor *visitor)
       
   286 {
       
   287     if (visitor->visit(this)) {
       
   288         acceptChild(expression, visitor);
       
   289     }
       
   290 
       
   291     visitor->endVisit(this);
       
   292 }
       
   293 
       
   294 void VoidExpression::accept0(Visitor *visitor)
       
   295 {
       
   296     if (visitor->visit(this)) {
       
   297         acceptChild(expression, visitor);
       
   298     }
       
   299 
       
   300     visitor->endVisit(this);
       
   301 }
       
   302 
       
   303 void TypeOfExpression::accept0(Visitor *visitor)
       
   304 {
       
   305     if (visitor->visit(this)) {
       
   306         acceptChild(expression, visitor);
       
   307     }
       
   308 
       
   309     visitor->endVisit(this);
       
   310 }
       
   311 
       
   312 void PreIncrementExpression::accept0(Visitor *visitor)
       
   313 {
       
   314     if (visitor->visit(this)) {
       
   315         acceptChild(expression, visitor);
       
   316     }
       
   317 
       
   318     visitor->endVisit(this);
       
   319 }
       
   320 
       
   321 void PreDecrementExpression::accept0(Visitor *visitor)
       
   322 {
       
   323     if (visitor->visit(this)) {
       
   324         acceptChild(expression, visitor);
       
   325     }
       
   326 
       
   327     visitor->endVisit(this);
       
   328 }
       
   329 
       
   330 void UnaryPlusExpression::accept0(Visitor *visitor)
       
   331 {
       
   332     if (visitor->visit(this)) {
       
   333         acceptChild(expression, visitor);
       
   334     }
       
   335 
       
   336     visitor->endVisit(this);
       
   337 }
       
   338 
       
   339 void UnaryMinusExpression::accept0(Visitor *visitor)
       
   340 {
       
   341     if (visitor->visit(this)) {
       
   342         acceptChild(expression, visitor);
       
   343     }
       
   344 
       
   345     visitor->endVisit(this);
       
   346 }
       
   347 
       
   348 void TildeExpression::accept0(Visitor *visitor)
       
   349 {
       
   350     if (visitor->visit(this)) {
       
   351         acceptChild(expression, visitor);
       
   352     }
       
   353 
       
   354     visitor->endVisit(this);
       
   355 }
       
   356 
       
   357 void NotExpression::accept0(Visitor *visitor)
       
   358 {
       
   359     if (visitor->visit(this)) {
       
   360         acceptChild(expression, visitor);
       
   361     }
       
   362 
       
   363     visitor->endVisit(this);
       
   364 }
       
   365 
       
   366 void BinaryExpression::accept0(Visitor *visitor)
       
   367 {
       
   368     if (visitor->visit(this)) {
       
   369         acceptChild(left, visitor);
       
   370         acceptChild(right, visitor);
       
   371     }
       
   372 
       
   373     visitor->endVisit(this);
       
   374 }
       
   375 
       
   376 void ConditionalExpression::accept0(Visitor *visitor)
       
   377 {
       
   378     if (visitor->visit(this)) {
       
   379         acceptChild(expression, visitor);
       
   380         acceptChild(ok, visitor);
       
   381         acceptChild(ko, visitor);
       
   382     }
       
   383 
       
   384     visitor->endVisit(this);
       
   385 }
       
   386 
       
   387 void Expression::accept0(Visitor *visitor)
       
   388 {
       
   389     if (visitor->visit(this)) {
       
   390         acceptChild(left, visitor);
       
   391         acceptChild(right, visitor);
       
   392     }
       
   393 
       
   394     visitor->endVisit(this);
       
   395 }
       
   396 
       
   397 void Block::accept0(Visitor *visitor)
       
   398 {
       
   399     if (visitor->visit(this)) {
       
   400         acceptChild(statements, visitor);
       
   401     }
       
   402 
       
   403     visitor->endVisit(this);
       
   404 }
       
   405 
       
   406 void StatementList::accept0(Visitor *visitor)
       
   407 {
       
   408     if (visitor->visit(this)) {
       
   409         StatementList *it = this;
       
   410         do {
       
   411             acceptChild(it->statement, visitor);
       
   412             it = it->next;
       
   413         } while (it);
       
   414     }
       
   415 
       
   416     visitor->endVisit(this);
       
   417 }
       
   418 
       
   419 void VariableStatement::accept0(Visitor *visitor)
       
   420 {
       
   421     if (visitor->visit(this)) {
       
   422         acceptChild(declarations, visitor);
       
   423     }
       
   424 
       
   425     visitor->endVisit(this);
       
   426 }
       
   427 
       
   428 void VariableDeclarationList::accept0(Visitor *visitor)
       
   429 {
       
   430     if (visitor->visit(this)) {
       
   431         VariableDeclarationList *it = this;
       
   432         do {
       
   433             acceptChild(it->declaration, visitor);
       
   434             it = it->next;
       
   435         } while (it);
       
   436     }
       
   437 
       
   438     visitor->endVisit(this);
       
   439 }
       
   440 
       
   441 void VariableDeclaration::accept0(Visitor *visitor)
       
   442 {
       
   443     if (visitor->visit(this)) {
       
   444         acceptChild(expression, visitor);
       
   445     }
       
   446 
       
   447     visitor->endVisit(this);
       
   448 }
       
   449 
       
   450 void EmptyStatement::accept0(Visitor *visitor)
       
   451 {
       
   452     if (visitor->visit(this)) {
       
   453     }
       
   454 
       
   455     visitor->endVisit(this);
       
   456 }
       
   457 
       
   458 void ExpressionStatement::accept0(Visitor *visitor)
       
   459 {
       
   460     if (visitor->visit(this)) {
       
   461         acceptChild(expression, visitor);
       
   462     }
       
   463 
       
   464     visitor->endVisit(this);
       
   465 }
       
   466 
       
   467 void IfStatement::accept0(Visitor *visitor)
       
   468 {
       
   469     if (visitor->visit(this)) {
       
   470         acceptChild(expression, visitor);
       
   471         acceptChild(ok, visitor);
       
   472         acceptChild(ko, visitor);
       
   473     }
       
   474 
       
   475     visitor->endVisit(this);
       
   476 }
       
   477 
       
   478 void DoWhileStatement::accept0(Visitor *visitor)
       
   479 {
       
   480     if (visitor->visit(this)) {
       
   481         acceptChild(statement, visitor);
       
   482         acceptChild(expression, visitor);
       
   483     }
       
   484 
       
   485     visitor->endVisit(this);
       
   486 }
       
   487 
       
   488 void WhileStatement::accept0(Visitor *visitor)
       
   489 {
       
   490     if (visitor->visit(this)) {
       
   491         acceptChild(expression, visitor);
       
   492         acceptChild(statement, visitor);
       
   493     }
       
   494 
       
   495     visitor->endVisit(this);
       
   496 }
       
   497 
       
   498 void ForStatement::accept0(Visitor *visitor)
       
   499 {
       
   500     if (visitor->visit(this)) {
       
   501         acceptChild(initialiser, visitor);
       
   502         acceptChild(condition, visitor);
       
   503         acceptChild(expression, visitor);
       
   504         acceptChild(statement, visitor);
       
   505     }
       
   506 
       
   507     visitor->endVisit(this);
       
   508 }
       
   509 
       
   510 void LocalForStatement::accept0(Visitor *visitor)
       
   511 {
       
   512     if (visitor->visit(this)) {
       
   513         acceptChild(declarations, visitor);
       
   514         acceptChild(condition, visitor);
       
   515         acceptChild(expression, visitor);
       
   516         acceptChild(statement, visitor);
       
   517     }
       
   518 
       
   519     visitor->endVisit(this);
       
   520 }
       
   521 
       
   522 void ForEachStatement::accept0(Visitor *visitor)
       
   523 {
       
   524     if (visitor->visit(this)) {
       
   525         acceptChild(initialiser, visitor);
       
   526         acceptChild(expression, visitor);
       
   527         acceptChild(statement, visitor);
       
   528     }
       
   529 
       
   530     visitor->endVisit(this);
       
   531 }
       
   532 
       
   533 void LocalForEachStatement::accept0(Visitor *visitor)
       
   534 {
       
   535     if (visitor->visit(this)) {
       
   536         acceptChild(declaration, visitor);
       
   537         acceptChild(expression, visitor);
       
   538         acceptChild(statement, visitor);
       
   539     }
       
   540 
       
   541     visitor->endVisit(this);
       
   542 }
       
   543 
       
   544 void ContinueStatement::accept0(Visitor *visitor)
       
   545 {
       
   546     if (visitor->visit(this)) {
       
   547     }
       
   548 
       
   549     visitor->endVisit(this);
       
   550 }
       
   551 
       
   552 void BreakStatement::accept0(Visitor *visitor)
       
   553 {
       
   554     if (visitor->visit(this)) {
       
   555     }
       
   556 
       
   557     visitor->endVisit(this);
       
   558 }
       
   559 
       
   560 void ReturnStatement::accept0(Visitor *visitor)
       
   561 {
       
   562     if (visitor->visit(this)) {
       
   563         acceptChild(expression, visitor);
       
   564     }
       
   565 
       
   566     visitor->endVisit(this);
       
   567 }
       
   568 
       
   569 void WithStatement::accept0(Visitor *visitor)
       
   570 {
       
   571     if (visitor->visit(this)) {
       
   572         acceptChild(expression, visitor);
       
   573         acceptChild(statement, visitor);
       
   574     }
       
   575 
       
   576     visitor->endVisit(this);
       
   577 }
       
   578 
       
   579 void SwitchStatement::accept0(Visitor *visitor)
       
   580 {
       
   581     if (visitor->visit(this)) {
       
   582         acceptChild(expression, visitor);
       
   583         acceptChild(block, visitor);
       
   584     }
       
   585 
       
   586     visitor->endVisit(this);
       
   587 }
       
   588 
       
   589 void CaseBlock::accept0(Visitor *visitor)
       
   590 {
       
   591     if (visitor->visit(this)) {
       
   592         acceptChild(clauses, visitor);
       
   593         acceptChild(defaultClause, visitor);
       
   594         acceptChild(moreClauses, visitor);
       
   595     }
       
   596 
       
   597     visitor->endVisit(this);
       
   598 }
       
   599 
       
   600 void CaseClauses::accept0(Visitor *visitor)
       
   601 {
       
   602     if (visitor->visit(this)) {
       
   603         CaseClauses *it = this;
       
   604         do {
       
   605             acceptChild(it->clause, visitor);
       
   606             it = it->next;
       
   607         } while (it);
       
   608     }
       
   609 
       
   610     visitor->endVisit(this);
       
   611 }
       
   612 
       
   613 void CaseClause::accept0(Visitor *visitor)
       
   614 {
       
   615     if (visitor->visit(this)) {
       
   616         acceptChild(expression, visitor);
       
   617         acceptChild(statements, visitor);
       
   618     }
       
   619 
       
   620     visitor->endVisit(this);
       
   621 }
       
   622 
       
   623 void DefaultClause::accept0(Visitor *visitor)
       
   624 {
       
   625     if (visitor->visit(this)) {
       
   626         acceptChild(statements, visitor);
       
   627     }
       
   628 
       
   629     visitor->endVisit(this);
       
   630 }
       
   631 
       
   632 void LabelledStatement::accept0(Visitor *visitor)
       
   633 {
       
   634     if (visitor->visit(this)) {
       
   635         acceptChild(statement, visitor);
       
   636     }
       
   637 
       
   638     visitor->endVisit(this);
       
   639 }
       
   640 
       
   641 void ThrowStatement::accept0(Visitor *visitor)
       
   642 {
       
   643     if (visitor->visit(this)) {
       
   644         acceptChild(expression, visitor);
       
   645     }
       
   646 
       
   647     visitor->endVisit(this);
       
   648 }
       
   649 
       
   650 void TryStatement::accept0(Visitor *visitor)
       
   651 {
       
   652     if (visitor->visit(this)) {
       
   653         acceptChild(statement, visitor);
       
   654         acceptChild(catchExpression, visitor);
       
   655         acceptChild(finallyExpression, visitor);
       
   656     }
       
   657 
       
   658     visitor->endVisit(this);
       
   659 }
       
   660 
       
   661 void Catch::accept0(Visitor *visitor)
       
   662 {
       
   663     if (visitor->visit(this)) {
       
   664         acceptChild(statement, visitor);
       
   665     }
       
   666 
       
   667     visitor->endVisit(this);
       
   668 }
       
   669 
       
   670 void Finally::accept0(Visitor *visitor)
       
   671 {
       
   672     if (visitor->visit(this)) {
       
   673         acceptChild(statement, visitor);
       
   674     }
       
   675 
       
   676     visitor->endVisit(this);
       
   677 }
       
   678 
       
   679 void FunctionDeclaration::accept0(Visitor *visitor)
       
   680 {
       
   681     if (visitor->visit(this)) {
       
   682         acceptChild(formals, visitor);
       
   683         acceptChild(body, visitor);
       
   684     }
       
   685 
       
   686     visitor->endVisit(this);
       
   687 }
       
   688 
       
   689 void FunctionExpression::accept0(Visitor *visitor)
       
   690 {
       
   691     if (visitor->visit(this)) {
       
   692         acceptChild(formals, visitor);
       
   693         acceptChild(body, visitor);
       
   694     }
       
   695 
       
   696     visitor->endVisit(this);
       
   697 }
       
   698 
       
   699 void FormalParameterList::accept0(Visitor *visitor)
       
   700 {
       
   701     if (visitor->visit(this)) {
       
   702         // ###
       
   703     }
       
   704 
       
   705     visitor->endVisit(this);
       
   706 }
       
   707 
       
   708 void FunctionBody::accept0(Visitor *visitor)
       
   709 {
       
   710     if (visitor->visit(this)) {
       
   711         acceptChild(elements, visitor);
       
   712     }
       
   713 
       
   714     visitor->endVisit(this);
       
   715 }
       
   716 
       
   717 void Program::accept0(Visitor *visitor)
       
   718 {
       
   719     if (visitor->visit(this)) {
       
   720         acceptChild(elements, visitor);
       
   721     }
       
   722 
       
   723     visitor->endVisit(this);
       
   724 }
       
   725 
       
   726 void SourceElements::accept0(Visitor *visitor)
       
   727 {
       
   728     if (visitor->visit(this)) {
       
   729         SourceElements *it = this;
       
   730         do {
       
   731             acceptChild(it->element, visitor);
       
   732             it = it->next;
       
   733         } while (it);
       
   734     }
       
   735 
       
   736     visitor->endVisit(this);
       
   737 }
       
   738 
       
   739 void FunctionSourceElement::accept0(Visitor *visitor)
       
   740 {
       
   741     if (visitor->visit(this)) {
       
   742         acceptChild(declaration, visitor);
       
   743     }
       
   744 
       
   745     visitor->endVisit(this);
       
   746 }
       
   747 
       
   748 void StatementSourceElement::accept0(Visitor *visitor)
       
   749 {
       
   750     if (visitor->visit(this)) {
       
   751         acceptChild(statement, visitor);
       
   752     }
       
   753 
       
   754     visitor->endVisit(this);
       
   755 }
       
   756 
       
   757 void DebuggerStatement::accept0(Visitor *visitor)
       
   758 {
       
   759     if (visitor->visit(this)) {
       
   760     }
       
   761 
       
   762     visitor->endVisit(this);
       
   763 }
       
   764 
       
   765 } } // namespace QScript::AST
       
   766 
       
   767 QT_END_NAMESPACE