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