5d6ca676a66d86ae64a1a797a3c2273ddb330154
[profile/ivi/qtdeclarative.git] / src / declarative / qml / parser / qdeclarativejsast.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qdeclarativejsast_p.h"
43
44 #include "qdeclarativejsastvisitor_p.h"
45
46 QT_QML_BEGIN_NAMESPACE
47
48 namespace QDeclarativeJS { namespace AST {
49
50 void Node::accept(Visitor *visitor)
51 {
52     if (visitor->preVisit(this)) {
53         accept0(visitor);
54     }
55     visitor->postVisit(this);
56 }
57
58 void Node::accept(Node *node, Visitor *visitor)
59 {
60     if (node)
61         node->accept(visitor);
62 }
63
64 ExpressionNode *Node::expressionCast()
65 {
66     return 0;
67 }
68
69 BinaryExpression *Node::binaryExpressionCast()
70 {
71     return 0;
72 }
73
74 Statement *Node::statementCast()
75 {
76     return 0;
77 }
78
79 UiObjectMember *Node::uiObjectMemberCast()
80 {
81     return 0;
82 }
83
84 ExpressionNode *ExpressionNode::expressionCast()
85 {
86     return this;
87 }
88
89 BinaryExpression *BinaryExpression::binaryExpressionCast()
90 {
91     return this;
92 }
93
94 Statement *Statement::statementCast()
95 {
96     return this;
97 }
98
99 UiObjectMember *UiObjectMember::uiObjectMemberCast()
100 {
101     return this;
102 }
103
104 void NestedExpression::accept0(Visitor *visitor)
105 {
106     if (visitor->visit(this)) {
107         accept(expression, visitor);
108     }
109     visitor->endVisit(this);
110 }
111
112 void ThisExpression::accept0(Visitor *visitor)
113 {
114     if (visitor->visit(this)) {
115     }
116
117     visitor->endVisit(this);
118 }
119
120 void IdentifierExpression::accept0(Visitor *visitor)
121 {
122     if (visitor->visit(this)) {
123     }
124
125     visitor->endVisit(this);
126 }
127
128 void NullExpression::accept0(Visitor *visitor)
129 {
130     if (visitor->visit(this)) {
131     }
132
133     visitor->endVisit(this);
134 }
135
136 void TrueLiteral::accept0(Visitor *visitor)
137 {
138     if (visitor->visit(this)) {
139     }
140
141     visitor->endVisit(this);
142 }
143
144 void FalseLiteral::accept0(Visitor *visitor)
145 {
146     if (visitor->visit(this)) {
147     }
148
149     visitor->endVisit(this);
150 }
151
152 void StringLiteral::accept0(Visitor *visitor)
153 {
154     if (visitor->visit(this)) {
155     }
156
157     visitor->endVisit(this);
158 }
159
160 void NumericLiteral::accept0(Visitor *visitor)
161 {
162     if (visitor->visit(this)) {
163     }
164
165     visitor->endVisit(this);
166 }
167
168 void RegExpLiteral::accept0(Visitor *visitor)
169 {
170     if (visitor->visit(this)) {
171     }
172
173     visitor->endVisit(this);
174 }
175
176 void ArrayLiteral::accept0(Visitor *visitor)
177 {
178     if (visitor->visit(this)) {
179         accept(elements, visitor);
180         accept(elision, visitor);
181     }
182
183     visitor->endVisit(this);
184 }
185
186 void ObjectLiteral::accept0(Visitor *visitor)
187 {
188     if (visitor->visit(this)) {
189         accept(properties, visitor);
190     }
191
192     visitor->endVisit(this);
193 }
194
195 void ElementList::accept0(Visitor *visitor)
196 {
197     if (visitor->visit(this)) {
198         for (ElementList *it = this; it; it = it->next) {
199             accept(it->elision, visitor);
200             accept(it->expression, visitor);
201         }
202     }
203
204     visitor->endVisit(this);
205 }
206
207 void Elision::accept0(Visitor *visitor)
208 {
209     if (visitor->visit(this)) {
210         // ###
211     }
212
213     visitor->endVisit(this);
214 }
215
216 void PropertyNameAndValueList::accept0(Visitor *visitor)
217 {
218     if (visitor->visit(this)) {
219         for (PropertyNameAndValueList *it = this; it; it = it->next) {
220             accept(it->name, visitor);
221             accept(it->value, visitor);
222         }
223     }
224
225     visitor->endVisit(this);
226 }
227
228 void IdentifierPropertyName::accept0(Visitor *visitor)
229 {
230     if (visitor->visit(this)) {
231     }
232
233     visitor->endVisit(this);
234 }
235
236 void StringLiteralPropertyName::accept0(Visitor *visitor)
237 {
238     if (visitor->visit(this)) {
239     }
240
241     visitor->endVisit(this);
242 }
243
244 void NumericLiteralPropertyName::accept0(Visitor *visitor)
245 {
246     if (visitor->visit(this)) {
247     }
248
249     visitor->endVisit(this);
250 }
251
252 void ArrayMemberExpression::accept0(Visitor *visitor)
253 {
254     if (visitor->visit(this)) {
255         accept(base, visitor);
256         accept(expression, visitor);
257     }
258
259     visitor->endVisit(this);
260 }
261
262 void FieldMemberExpression::accept0(Visitor *visitor)
263 {
264     if (visitor->visit(this)) {
265         accept(base, visitor);
266     }
267
268     visitor->endVisit(this);
269 }
270
271 void NewMemberExpression::accept0(Visitor *visitor)
272 {
273     if (visitor->visit(this)) {
274         accept(base, visitor);
275         accept(arguments, visitor);
276     }
277
278     visitor->endVisit(this);
279 }
280
281 void NewExpression::accept0(Visitor *visitor)
282 {
283     if (visitor->visit(this)) {
284         accept(expression, visitor);
285     }
286
287     visitor->endVisit(this);
288 }
289
290 void CallExpression::accept0(Visitor *visitor)
291 {
292     if (visitor->visit(this)) {
293         accept(base, visitor);
294         accept(arguments, visitor);
295     }
296
297     visitor->endVisit(this);
298 }
299
300 void ArgumentList::accept0(Visitor *visitor)
301 {
302     if (visitor->visit(this)) {
303         for (ArgumentList *it = this; it; it = it->next) {
304             accept(it->expression, visitor);
305         }
306     }
307
308     visitor->endVisit(this);
309 }
310
311 void PostIncrementExpression::accept0(Visitor *visitor)
312 {
313     if (visitor->visit(this)) {
314         accept(base, visitor);
315     }
316
317     visitor->endVisit(this);
318 }
319
320 void PostDecrementExpression::accept0(Visitor *visitor)
321 {
322     if (visitor->visit(this)) {
323         accept(base, visitor);
324     }
325
326     visitor->endVisit(this);
327 }
328
329 void DeleteExpression::accept0(Visitor *visitor)
330 {
331     if (visitor->visit(this)) {
332         accept(expression, visitor);
333     }
334
335     visitor->endVisit(this);
336 }
337
338 void VoidExpression::accept0(Visitor *visitor)
339 {
340     if (visitor->visit(this)) {
341         accept(expression, visitor);
342     }
343
344     visitor->endVisit(this);
345 }
346
347 void TypeOfExpression::accept0(Visitor *visitor)
348 {
349     if (visitor->visit(this)) {
350         accept(expression, visitor);
351     }
352
353     visitor->endVisit(this);
354 }
355
356 void PreIncrementExpression::accept0(Visitor *visitor)
357 {
358     if (visitor->visit(this)) {
359         accept(expression, visitor);
360     }
361
362     visitor->endVisit(this);
363 }
364
365 void PreDecrementExpression::accept0(Visitor *visitor)
366 {
367     if (visitor->visit(this)) {
368         accept(expression, visitor);
369     }
370
371     visitor->endVisit(this);
372 }
373
374 void UnaryPlusExpression::accept0(Visitor *visitor)
375 {
376     if (visitor->visit(this)) {
377         accept(expression, visitor);
378     }
379
380     visitor->endVisit(this);
381 }
382
383 void UnaryMinusExpression::accept0(Visitor *visitor)
384 {
385     if (visitor->visit(this)) {
386         accept(expression, visitor);
387     }
388
389     visitor->endVisit(this);
390 }
391
392 void TildeExpression::accept0(Visitor *visitor)
393 {
394     if (visitor->visit(this)) {
395         accept(expression, visitor);
396     }
397
398     visitor->endVisit(this);
399 }
400
401 void NotExpression::accept0(Visitor *visitor)
402 {
403     if (visitor->visit(this)) {
404         accept(expression, visitor);
405     }
406
407     visitor->endVisit(this);
408 }
409
410 void BinaryExpression::accept0(Visitor *visitor)
411 {
412     if (visitor->visit(this)) {
413         accept(left, visitor);
414         accept(right, visitor);
415     }
416
417     visitor->endVisit(this);
418 }
419
420 void ConditionalExpression::accept0(Visitor *visitor)
421 {
422     if (visitor->visit(this)) {
423         accept(expression, visitor);
424         accept(ok, visitor);
425         accept(ko, visitor);
426     }
427
428     visitor->endVisit(this);
429 }
430
431 void Expression::accept0(Visitor *visitor)
432 {
433     if (visitor->visit(this)) {
434         accept(left, visitor);
435         accept(right, visitor);
436     }
437
438     visitor->endVisit(this);
439 }
440
441 void Block::accept0(Visitor *visitor)
442 {
443     if (visitor->visit(this)) {
444         accept(statements, visitor);
445     }
446
447     visitor->endVisit(this);
448 }
449
450 void StatementList::accept0(Visitor *visitor)
451 {
452     if (visitor->visit(this)) {
453         for (StatementList *it = this; it; it = it->next) {
454             accept(it->statement, visitor);
455         }
456     }
457
458     visitor->endVisit(this);
459 }
460
461 void VariableStatement::accept0(Visitor *visitor)
462 {
463     if (visitor->visit(this)) {
464         accept(declarations, visitor);
465     }
466
467     visitor->endVisit(this);
468 }
469
470 void VariableDeclarationList::accept0(Visitor *visitor)
471 {
472     if (visitor->visit(this)) {
473         for (VariableDeclarationList *it = this; it; it = it->next) {
474             accept(it->declaration, visitor);
475         }
476     }
477
478     visitor->endVisit(this);
479 }
480
481 void VariableDeclaration::accept0(Visitor *visitor)
482 {
483     if (visitor->visit(this)) {
484         accept(expression, visitor);
485     }
486
487     visitor->endVisit(this);
488 }
489
490 void EmptyStatement::accept0(Visitor *visitor)
491 {
492     if (visitor->visit(this)) {
493     }
494
495     visitor->endVisit(this);
496 }
497
498 void ExpressionStatement::accept0(Visitor *visitor)
499 {
500     if (visitor->visit(this)) {
501         accept(expression, visitor);
502     }
503
504     visitor->endVisit(this);
505 }
506
507 void IfStatement::accept0(Visitor *visitor)
508 {
509     if (visitor->visit(this)) {
510         accept(expression, visitor);
511         accept(ok, visitor);
512         accept(ko, visitor);
513     }
514
515     visitor->endVisit(this);
516 }
517
518 void DoWhileStatement::accept0(Visitor *visitor)
519 {
520     if (visitor->visit(this)) {
521         accept(statement, visitor);
522         accept(expression, visitor);
523     }
524
525     visitor->endVisit(this);
526 }
527
528 void WhileStatement::accept0(Visitor *visitor)
529 {
530     if (visitor->visit(this)) {
531         accept(expression, visitor);
532         accept(statement, visitor);
533     }
534
535     visitor->endVisit(this);
536 }
537
538 void ForStatement::accept0(Visitor *visitor)
539 {
540     if (visitor->visit(this)) {
541         accept(initialiser, visitor);
542         accept(condition, visitor);
543         accept(expression, visitor);
544         accept(statement, visitor);
545     }
546
547     visitor->endVisit(this);
548 }
549
550 void LocalForStatement::accept0(Visitor *visitor)
551 {
552     if (visitor->visit(this)) {
553         accept(declarations, visitor);
554         accept(condition, visitor);
555         accept(expression, visitor);
556         accept(statement, visitor);
557     }
558
559     visitor->endVisit(this);
560 }
561
562 void ForEachStatement::accept0(Visitor *visitor)
563 {
564     if (visitor->visit(this)) {
565         accept(initialiser, visitor);
566         accept(expression, visitor);
567         accept(statement, visitor);
568     }
569
570     visitor->endVisit(this);
571 }
572
573 void LocalForEachStatement::accept0(Visitor *visitor)
574 {
575     if (visitor->visit(this)) {
576         accept(declaration, visitor);
577         accept(expression, visitor);
578         accept(statement, visitor);
579     }
580
581     visitor->endVisit(this);
582 }
583
584 void ContinueStatement::accept0(Visitor *visitor)
585 {
586     if (visitor->visit(this)) {
587     }
588
589     visitor->endVisit(this);
590 }
591
592 void BreakStatement::accept0(Visitor *visitor)
593 {
594     if (visitor->visit(this)) {
595     }
596
597     visitor->endVisit(this);
598 }
599
600 void ReturnStatement::accept0(Visitor *visitor)
601 {
602     if (visitor->visit(this)) {
603         accept(expression, visitor);
604     }
605
606     visitor->endVisit(this);
607 }
608
609 void WithStatement::accept0(Visitor *visitor)
610 {
611     if (visitor->visit(this)) {
612         accept(expression, visitor);
613         accept(statement, visitor);
614     }
615
616     visitor->endVisit(this);
617 }
618
619 void SwitchStatement::accept0(Visitor *visitor)
620 {
621     if (visitor->visit(this)) {
622         accept(expression, visitor);
623         accept(block, visitor);
624     }
625
626     visitor->endVisit(this);
627 }
628
629 void CaseBlock::accept0(Visitor *visitor)
630 {
631     if (visitor->visit(this)) {
632         accept(clauses, visitor);
633         accept(defaultClause, visitor);
634         accept(moreClauses, visitor);
635     }
636
637     visitor->endVisit(this);
638 }
639
640 void CaseClauses::accept0(Visitor *visitor)
641 {
642     if (visitor->visit(this)) {
643         for (CaseClauses *it = this; it; it = it->next) {
644             accept(it->clause, visitor);
645         }
646     }
647
648     visitor->endVisit(this);
649 }
650
651 void CaseClause::accept0(Visitor *visitor)
652 {
653     if (visitor->visit(this)) {
654         accept(expression, visitor);
655         accept(statements, visitor);
656     }
657
658     visitor->endVisit(this);
659 }
660
661 void DefaultClause::accept0(Visitor *visitor)
662 {
663     if (visitor->visit(this)) {
664         accept(statements, visitor);
665     }
666
667     visitor->endVisit(this);
668 }
669
670 void LabelledStatement::accept0(Visitor *visitor)
671 {
672     if (visitor->visit(this)) {
673         accept(statement, visitor);
674     }
675
676     visitor->endVisit(this);
677 }
678
679 void ThrowStatement::accept0(Visitor *visitor)
680 {
681     if (visitor->visit(this)) {
682         accept(expression, visitor);
683     }
684
685     visitor->endVisit(this);
686 }
687
688 void TryStatement::accept0(Visitor *visitor)
689 {
690     if (visitor->visit(this)) {
691         accept(statement, visitor);
692         accept(catchExpression, visitor);
693         accept(finallyExpression, visitor);
694     }
695
696     visitor->endVisit(this);
697 }
698
699 void Catch::accept0(Visitor *visitor)
700 {
701     if (visitor->visit(this)) {
702         accept(statement, visitor);
703     }
704
705     visitor->endVisit(this);
706 }
707
708 void Finally::accept0(Visitor *visitor)
709 {
710     if (visitor->visit(this)) {
711         accept(statement, visitor);
712     }
713
714     visitor->endVisit(this);
715 }
716
717 void FunctionDeclaration::accept0(Visitor *visitor)
718 {
719     if (visitor->visit(this)) {
720         accept(formals, visitor);
721         accept(body, visitor);
722     }
723
724     visitor->endVisit(this);
725 }
726
727 void FunctionExpression::accept0(Visitor *visitor)
728 {
729     if (visitor->visit(this)) {
730         accept(formals, visitor);
731         accept(body, visitor);
732     }
733
734     visitor->endVisit(this);
735 }
736
737 void FormalParameterList::accept0(Visitor *visitor)
738 {
739     if (visitor->visit(this)) {
740         // ###
741     }
742
743     visitor->endVisit(this);
744 }
745
746 void FunctionBody::accept0(Visitor *visitor)
747 {
748     if (visitor->visit(this)) {
749         accept(elements, visitor);
750     }
751
752     visitor->endVisit(this);
753 }
754
755 void Program::accept0(Visitor *visitor)
756 {
757     if (visitor->visit(this)) {
758         accept(elements, visitor);
759     }
760
761     visitor->endVisit(this);
762 }
763
764 void SourceElements::accept0(Visitor *visitor)
765 {
766     if (visitor->visit(this)) {
767         for (SourceElements *it = this; it; it = it->next) {
768             accept(it->element, visitor);
769         }
770     }
771
772     visitor->endVisit(this);
773 }
774
775 void FunctionSourceElement::accept0(Visitor *visitor)
776 {
777     if (visitor->visit(this)) {
778         accept(declaration, visitor);
779     }
780
781     visitor->endVisit(this);
782 }
783
784 void StatementSourceElement::accept0(Visitor *visitor)
785 {
786     if (visitor->visit(this)) {
787         accept(statement, visitor);
788     }
789
790     visitor->endVisit(this);
791 }
792
793 void DebuggerStatement::accept0(Visitor *visitor)
794 {
795     if (visitor->visit(this)) {
796     }
797
798     visitor->endVisit(this);
799 }
800
801 void UiProgram::accept0(Visitor *visitor)
802 {
803     if (visitor->visit(this)) {
804         accept(imports, visitor);
805         accept(members, visitor);
806     }
807
808     visitor->endVisit(this);
809 }
810
811 void UiPublicMember::accept0(Visitor *visitor)
812 {
813     if (visitor->visit(this)) {
814         accept(statement, visitor);
815         accept(binding, visitor);
816     }
817
818     visitor->endVisit(this);
819 }
820
821 void UiObjectDefinition::accept0(Visitor *visitor)
822 {
823     if (visitor->visit(this)) {
824         accept(qualifiedTypeNameId, visitor);
825         accept(initializer, visitor);
826     }
827
828     visitor->endVisit(this);
829 }
830
831 void UiObjectInitializer::accept0(Visitor *visitor)
832 {
833     if (visitor->visit(this)) {
834         accept(members, visitor);
835     }
836
837     visitor->endVisit(this);
838 }
839
840 void UiObjectBinding::accept0(Visitor *visitor)
841 {
842     if (visitor->visit(this)) {
843         accept(qualifiedId, visitor);
844         accept(qualifiedTypeNameId, visitor);
845         accept(initializer, visitor);
846     }
847
848     visitor->endVisit(this);
849 }
850
851 void UiScriptBinding::accept0(Visitor *visitor)
852 {
853     if (visitor->visit(this)) {
854         accept(qualifiedId, visitor);
855         accept(statement, visitor);
856     }
857
858     visitor->endVisit(this);
859 }
860
861 void UiArrayBinding::accept0(Visitor *visitor)
862 {
863     if (visitor->visit(this)) {
864         accept(qualifiedId, visitor);
865         accept(members, visitor);
866     }
867
868     visitor->endVisit(this);
869 }
870
871 void UiObjectMemberList::accept0(Visitor *visitor)
872 {
873     if (visitor->visit(this)) {
874         for (UiObjectMemberList *it = this; it; it = it->next)
875             accept(it->member, visitor);
876     }
877
878     visitor->endVisit(this);
879 }
880
881 void UiArrayMemberList::accept0(Visitor *visitor)
882 {
883     if (visitor->visit(this)) {
884         for (UiArrayMemberList *it = this; it; it = it->next)
885             accept(it->member, visitor);
886     }
887
888     visitor->endVisit(this);
889 }
890
891 void UiQualifiedId::accept0(Visitor *visitor)
892 {
893     if (visitor->visit(this)) {
894     }
895
896     visitor->endVisit(this);
897 }
898
899 void UiImport::accept0(Visitor *visitor)
900 {
901     if (visitor->visit(this)) {
902         accept(importUri, visitor);
903     }
904
905     visitor->endVisit(this);
906 }
907
908 void UiImportList::accept0(Visitor *visitor)
909 {
910     if (visitor->visit(this)) {
911         accept(import, visitor);
912         accept(next, visitor);
913     }
914
915     visitor->endVisit(this);
916 }
917
918 void UiSourceElement::accept0(Visitor *visitor)
919 {
920     if (visitor->visit(this)) {
921         accept(sourceElement, visitor);
922     }
923
924     visitor->endVisit(this);
925 }
926
927 } } // namespace QDeclarativeJS::AST
928
929 QT_QML_END_NAMESPACE
930
931