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 | #ifndef QSCRIPTAST_P_H |
41 | #define QSCRIPTAST_P_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists purely as an |
48 | // implementation detail. This header file may change from version to |
49 | // version without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | |
54 | #include <QtCore/qstring.h> |
55 | |
56 | #include "qscriptastvisitor_p.h" |
57 | |
58 | QT_BEGIN_NAMESPACE |
59 | |
60 | class QScriptNameIdImpl; |
61 | |
62 | namespace QSOperator // ### rename |
63 | { |
64 | |
65 | enum Op { |
66 | Add, |
67 | And, |
68 | InplaceAnd, |
69 | Assign, |
70 | BitAnd, |
71 | BitOr, |
72 | BitXor, |
73 | InplaceSub, |
74 | Div, |
75 | InplaceDiv, |
76 | Equal, |
77 | Ge, |
78 | Gt, |
79 | In, |
80 | InplaceAdd, |
81 | InstanceOf, |
82 | Le, |
83 | LShift, |
84 | InplaceLeftShift, |
85 | Lt, |
86 | Mod, |
87 | InplaceMod, |
88 | Mul, |
89 | InplaceMul, |
90 | NotEqual, |
91 | Or, |
92 | InplaceOr, |
93 | RShift, |
94 | InplaceRightShift, |
95 | StrictEqual, |
96 | StrictNotEqual, |
97 | Sub, |
98 | URShift, |
99 | InplaceURightShift, |
100 | InplaceXor |
101 | }; |
102 | |
103 | } // namespace QSOperator |
104 | |
105 | namespace QScript { namespace AST { |
106 | |
107 | class Node |
108 | { |
109 | public: |
110 | enum Kind { |
111 | Kind_Node, |
112 | Kind_ExpressionNode, |
113 | Kind_Statement, |
114 | Kind_ThisExpression, |
115 | Kind_IdentifierExpression, |
116 | Kind_NullExpression, |
117 | Kind_TrueLiteral, |
118 | Kind_FalseLiteral, |
119 | Kind_NumericLiteral, |
120 | Kind_StringLiteral, |
121 | Kind_RegExpLiteral, |
122 | Kind_ArrayLiteral, |
123 | Kind_ObjectLiteral, |
124 | Kind_ElementList, |
125 | Kind_Elision, |
126 | Kind_PropertyNameAndValueList, |
127 | Kind_PropertyName, |
128 | Kind_IdentifierPropertyName, |
129 | Kind_StringLiteralPropertyName, |
130 | Kind_NumericLiteralPropertyName, |
131 | Kind_ArrayMemberExpression, |
132 | Kind_FieldMemberExpression, |
133 | Kind_NewMemberExpression, |
134 | Kind_NewExpression, |
135 | Kind_CallExpression, |
136 | Kind_ArgumentList, |
137 | Kind_PostIncrementExpression, |
138 | Kind_PostDecrementExpression, |
139 | Kind_DeleteExpression, |
140 | Kind_VoidExpression, |
141 | Kind_TypeOfExpression, |
142 | Kind_PreIncrementExpression, |
143 | Kind_PreDecrementExpression, |
144 | Kind_UnaryPlusExpression, |
145 | Kind_UnaryMinusExpression, |
146 | Kind_TildeExpression, |
147 | Kind_NotExpression, |
148 | Kind_BinaryExpression, |
149 | Kind_ConditionalExpression, |
150 | Kind_Expression, |
151 | Kind_Block, |
152 | Kind_StatementList, |
153 | Kind_VariableStatement, |
154 | Kind_VariableDeclarationList, |
155 | Kind_VariableDeclaration, |
156 | Kind_EmptyStatement, |
157 | Kind_ExpressionStatement, |
158 | Kind_IfStatement, |
159 | Kind_DoWhileStatement, |
160 | Kind_WhileStatement, |
161 | Kind_ForStatement, |
162 | Kind_LocalForStatement, |
163 | Kind_ForEachStatement, |
164 | Kind_LocalForEachStatement, |
165 | Kind_ContinueStatement, |
166 | Kind_BreakStatement, |
167 | Kind_ReturnStatement, |
168 | Kind_WithStatement, |
169 | Kind_SwitchStatement, |
170 | Kind_CaseBlock, |
171 | Kind_CaseClauses, |
172 | Kind_CaseClause, |
173 | Kind_DefaultClause, |
174 | Kind_LabelledStatement, |
175 | Kind_ThrowStatement, |
176 | Kind_TryStatement, |
177 | Kind_Catch, |
178 | Kind_Finally, |
179 | Kind_FunctionDeclaration, |
180 | Kind_FunctionExpression, |
181 | Kind_FormalParameterList, |
182 | Kind_FunctionBody, |
183 | Kind_Program, |
184 | Kind_SourceElements, |
185 | Kind_SourceElement, |
186 | Kind_FunctionSourceElement, |
187 | Kind_StatementSourceElement, |
188 | Kind_DebuggerStatement |
189 | }; |
190 | |
191 | inline Node(): |
192 | startLine(0), startColumn(0), |
193 | endLine(0), endColumn(0), kind(Kind_Node) {} |
194 | |
195 | virtual ~Node() {} |
196 | |
197 | virtual ExpressionNode *expressionCast(); |
198 | virtual BinaryExpression *binaryExpressionCast(); |
199 | virtual Statement *statementCast(); |
200 | |
201 | inline void accept(Visitor *visitor) |
202 | { |
203 | if (visitor->preVisit(this)) { |
204 | accept0(visitor); |
205 | visitor->postVisit(this); |
206 | } |
207 | } |
208 | |
209 | static void acceptChild(Node *node, Visitor *visitor) |
210 | { |
211 | if (node) |
212 | node->accept(visitor); |
213 | } |
214 | |
215 | virtual void accept0(Visitor *visitor) = 0; |
216 | |
217 | int startLine; |
218 | int startColumn; |
219 | int endLine; |
220 | int endColumn; |
221 | Kind kind; |
222 | }; |
223 | |
224 | class ExpressionNode: public Node |
225 | { |
226 | public: |
227 | ExpressionNode() { kind = Kind_ExpressionNode; } |
228 | virtual ~ExpressionNode() {} |
229 | |
230 | virtual ExpressionNode *expressionCast(); |
231 | }; |
232 | |
233 | class Statement: public Node |
234 | { |
235 | public: |
236 | Statement() { kind = Kind_Statement; } |
237 | virtual ~Statement() {} |
238 | |
239 | virtual Statement *statementCast(); |
240 | }; |
241 | |
242 | class ThisExpression: public ExpressionNode |
243 | { |
244 | public: |
245 | ThisExpression() { kind = Kind_ThisExpression; } |
246 | virtual ~ThisExpression() {} |
247 | |
248 | virtual void accept0(Visitor *visitor); |
249 | }; |
250 | |
251 | class IdentifierExpression: public ExpressionNode |
252 | { |
253 | public: |
254 | IdentifierExpression(QScriptNameIdImpl *n): |
255 | name (n) { kind = Kind_IdentifierExpression; } |
256 | |
257 | virtual ~IdentifierExpression() {} |
258 | |
259 | virtual void accept0(Visitor *visitor); |
260 | |
261 | // attributes |
262 | QScriptNameIdImpl *name; |
263 | }; |
264 | |
265 | class NullExpression: public ExpressionNode |
266 | { |
267 | public: |
268 | NullExpression() { kind = Kind_NullExpression; } |
269 | virtual ~NullExpression() {} |
270 | |
271 | virtual void accept0(Visitor *visitor); |
272 | }; |
273 | |
274 | class TrueLiteral: public ExpressionNode |
275 | { |
276 | public: |
277 | TrueLiteral() { kind = Kind_TrueLiteral; } |
278 | virtual ~TrueLiteral() {} |
279 | |
280 | virtual void accept0(Visitor *visitor); |
281 | }; |
282 | |
283 | class FalseLiteral: public ExpressionNode |
284 | { |
285 | public: |
286 | FalseLiteral() { kind = Kind_FalseLiteral; } |
287 | virtual ~FalseLiteral() {} |
288 | |
289 | virtual void accept0(Visitor *visitor); |
290 | }; |
291 | |
292 | class NumericLiteral: public ExpressionNode |
293 | { |
294 | public: |
295 | NumericLiteral(double v): |
296 | value (v) { kind = Kind_NumericLiteral; } |
297 | virtual ~NumericLiteral() {} |
298 | |
299 | virtual void accept0(Visitor *visitor); |
300 | |
301 | // attributes: |
302 | double value; |
303 | }; |
304 | |
305 | class StringLiteral: public ExpressionNode |
306 | { |
307 | public: |
308 | StringLiteral(QScriptNameIdImpl *v): |
309 | value (v) { kind = Kind_StringLiteral; } |
310 | |
311 | virtual ~StringLiteral() {} |
312 | |
313 | virtual void accept0(Visitor *visitor); |
314 | |
315 | // attributes: |
316 | QScriptNameIdImpl *value; |
317 | }; |
318 | |
319 | class RegExpLiteral: public ExpressionNode |
320 | { |
321 | public: |
322 | RegExpLiteral(QScriptNameIdImpl *p, int f): |
323 | pattern (p), flags (f) { kind = Kind_RegExpLiteral; } |
324 | |
325 | virtual ~RegExpLiteral() {} |
326 | |
327 | virtual void accept0(Visitor *visitor); |
328 | |
329 | // attributes: |
330 | QScriptNameIdImpl *pattern; |
331 | int flags; |
332 | }; |
333 | |
334 | class ArrayLiteral: public ExpressionNode |
335 | { |
336 | public: |
337 | ArrayLiteral(Elision *e): |
338 | elements (0), elision (e) |
339 | { kind = Kind_ArrayLiteral; } |
340 | |
341 | ArrayLiteral(ElementList *elts): |
342 | elements (elts), elision (0) |
343 | { kind = Kind_ArrayLiteral; } |
344 | |
345 | ArrayLiteral(ElementList *elts, Elision *e): |
346 | elements (elts), elision (e) |
347 | { kind = Kind_ArrayLiteral; } |
348 | |
349 | virtual ~ArrayLiteral() {} |
350 | |
351 | virtual void accept0(Visitor *visitor); |
352 | |
353 | // attributes |
354 | ElementList *elements; |
355 | Elision *elision; |
356 | }; |
357 | |
358 | class ObjectLiteral: public ExpressionNode |
359 | { |
360 | public: |
361 | ObjectLiteral(): |
362 | properties (0) { kind = Kind_ObjectLiteral; } |
363 | |
364 | ObjectLiteral(PropertyNameAndValueList *plist): |
365 | properties (plist) { kind = Kind_ObjectLiteral; } |
366 | |
367 | virtual ~ObjectLiteral() {} |
368 | |
369 | virtual void accept0(Visitor *visitor); |
370 | |
371 | // attributes |
372 | PropertyNameAndValueList *properties; |
373 | }; |
374 | |
375 | class ElementList: public Node |
376 | { |
377 | public: |
378 | ElementList(Elision *e, ExpressionNode *expr): |
379 | elision (e), expression (expr), next (this) |
380 | { kind = Kind_ElementList; } |
381 | |
382 | ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): |
383 | elision (e), expression (expr) |
384 | { |
385 | kind = Kind_ElementList; |
386 | next = previous->next; |
387 | previous->next = this; |
388 | } |
389 | |
390 | virtual ~ElementList() {} |
391 | |
392 | inline ElementList *finish () |
393 | { |
394 | ElementList *front = next; |
395 | next = 0; |
396 | return front; |
397 | } |
398 | |
399 | virtual void accept0(Visitor *visitor); |
400 | |
401 | // attributes |
402 | Elision *elision; |
403 | ExpressionNode *expression; |
404 | ElementList *next; |
405 | }; |
406 | |
407 | class Elision: public Node |
408 | { |
409 | public: |
410 | Elision(): |
411 | next (this) { kind = Kind_Elision; } |
412 | |
413 | Elision(Elision *previous) |
414 | { |
415 | kind = Kind_Elision; |
416 | next = previous->next; |
417 | previous->next = this; |
418 | } |
419 | |
420 | virtual ~Elision() {} |
421 | |
422 | virtual void accept0(Visitor *visitor); |
423 | |
424 | inline Elision *finish () |
425 | { |
426 | Elision *front = next; |
427 | next = 0; |
428 | return front; |
429 | } |
430 | |
431 | // attributes |
432 | Elision *next; |
433 | }; |
434 | |
435 | class PropertyNameAndValueList: public Node |
436 | { |
437 | public: |
438 | PropertyNameAndValueList(PropertyName *n, ExpressionNode *v): |
439 | name (n), value (v), next (this) |
440 | { kind = Kind_PropertyNameAndValueList; } |
441 | |
442 | PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v): |
443 | name (n), value (v) |
444 | { |
445 | kind = Kind_PropertyNameAndValueList; |
446 | next = previous->next; |
447 | previous->next = this; |
448 | } |
449 | |
450 | virtual ~PropertyNameAndValueList() {} |
451 | |
452 | virtual void accept0(Visitor *visitor); |
453 | |
454 | inline PropertyNameAndValueList *finish () |
455 | { |
456 | PropertyNameAndValueList *front = next; |
457 | next = 0; |
458 | return front; |
459 | } |
460 | |
461 | // attributes |
462 | PropertyName *name; |
463 | ExpressionNode *value; |
464 | PropertyNameAndValueList *next; |
465 | }; |
466 | |
467 | class PropertyName: public Node |
468 | { |
469 | public: |
470 | PropertyName() { kind = Kind_PropertyName; } |
471 | virtual ~PropertyName() {} |
472 | }; |
473 | |
474 | class IdentifierPropertyName: public PropertyName |
475 | { |
476 | public: |
477 | IdentifierPropertyName(QScriptNameIdImpl *n): |
478 | id (n) { kind = Kind_IdentifierPropertyName; } |
479 | |
480 | virtual ~IdentifierPropertyName() {} |
481 | |
482 | virtual void accept0(Visitor *visitor); |
483 | |
484 | // attributes |
485 | QScriptNameIdImpl *id; |
486 | }; |
487 | |
488 | class StringLiteralPropertyName: public PropertyName |
489 | { |
490 | public: |
491 | StringLiteralPropertyName(QScriptNameIdImpl *n): |
492 | id (n) { kind = Kind_StringLiteralPropertyName; } |
493 | virtual ~StringLiteralPropertyName() {} |
494 | |
495 | virtual void accept0(Visitor *visitor); |
496 | |
497 | // attributes |
498 | QScriptNameIdImpl *id; |
499 | }; |
500 | |
501 | class NumericLiteralPropertyName: public PropertyName |
502 | { |
503 | public: |
504 | NumericLiteralPropertyName(double n): |
505 | id (n) { kind = Kind_NumericLiteralPropertyName; } |
506 | virtual ~NumericLiteralPropertyName() {} |
507 | |
508 | virtual void accept0(Visitor *visitor); |
509 | |
510 | // attributes |
511 | double id; |
512 | }; |
513 | |
514 | class ArrayMemberExpression: public ExpressionNode |
515 | { |
516 | public: |
517 | ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): |
518 | base (b), expression (e) |
519 | { kind = Kind_ArrayMemberExpression; } |
520 | |
521 | virtual ~ArrayMemberExpression() {} |
522 | |
523 | virtual void accept0(Visitor *visitor); |
524 | |
525 | // attributes |
526 | ExpressionNode *base; |
527 | ExpressionNode *expression; |
528 | }; |
529 | |
530 | class FieldMemberExpression: public ExpressionNode |
531 | { |
532 | public: |
533 | FieldMemberExpression(ExpressionNode *b, QScriptNameIdImpl *n): |
534 | base (b), name (n) |
535 | { kind = Kind_FieldMemberExpression; } |
536 | |
537 | virtual ~FieldMemberExpression() {} |
538 | |
539 | virtual void accept0(Visitor *visitor); |
540 | |
541 | // attributes |
542 | ExpressionNode *base; |
543 | QScriptNameIdImpl *name; |
544 | }; |
545 | |
546 | class NewMemberExpression: public ExpressionNode |
547 | { |
548 | public: |
549 | NewMemberExpression(ExpressionNode *b, ArgumentList *a): |
550 | base (b), arguments (a) |
551 | { kind = Kind_NewMemberExpression; } |
552 | |
553 | virtual ~NewMemberExpression() {} |
554 | |
555 | virtual void accept0(Visitor *visitor); |
556 | |
557 | // attributes |
558 | ExpressionNode *base; |
559 | ArgumentList *arguments; |
560 | }; |
561 | |
562 | class NewExpression: public ExpressionNode |
563 | { |
564 | public: |
565 | NewExpression(ExpressionNode *e): |
566 | expression (e) { kind = Kind_NewExpression; } |
567 | |
568 | virtual ~NewExpression() {} |
569 | |
570 | virtual void accept0(Visitor *visitor); |
571 | |
572 | // attributes |
573 | ExpressionNode *expression; |
574 | }; |
575 | |
576 | class CallExpression: public ExpressionNode |
577 | { |
578 | public: |
579 | CallExpression(ExpressionNode *b, ArgumentList *a): |
580 | base (b), arguments (a) |
581 | { kind = Kind_CallExpression; } |
582 | |
583 | virtual ~CallExpression() {} |
584 | |
585 | virtual void accept0(Visitor *visitor); |
586 | |
587 | // attributes |
588 | ExpressionNode *base; |
589 | ArgumentList *arguments; |
590 | }; |
591 | |
592 | class ArgumentList: public Node |
593 | { |
594 | public: |
595 | ArgumentList(ExpressionNode *e): |
596 | expression (e), next (this) |
597 | { kind = Kind_ArgumentList; } |
598 | |
599 | ArgumentList(ArgumentList *previous, ExpressionNode *e): |
600 | expression (e) |
601 | { |
602 | kind = Kind_ArgumentList; |
603 | next = previous->next; |
604 | previous->next = this; |
605 | } |
606 | |
607 | virtual ~ArgumentList() {} |
608 | |
609 | virtual void accept0(Visitor *visitor); |
610 | |
611 | inline ArgumentList *finish () |
612 | { |
613 | ArgumentList *front = next; |
614 | next = 0; |
615 | return front; |
616 | } |
617 | |
618 | // attributes |
619 | ExpressionNode *expression; |
620 | ArgumentList *next; |
621 | }; |
622 | |
623 | class PostIncrementExpression: public ExpressionNode |
624 | { |
625 | public: |
626 | PostIncrementExpression(ExpressionNode *b): |
627 | base (b) { kind = Kind_PostIncrementExpression; } |
628 | |
629 | virtual ~PostIncrementExpression() {} |
630 | |
631 | virtual void accept0(Visitor *visitor); |
632 | |
633 | // attributes |
634 | ExpressionNode *base; |
635 | }; |
636 | |
637 | class PostDecrementExpression: public ExpressionNode |
638 | { |
639 | public: |
640 | PostDecrementExpression(ExpressionNode *b): |
641 | base (b) { kind = Kind_PostDecrementExpression; } |
642 | |
643 | virtual ~PostDecrementExpression() {} |
644 | |
645 | virtual void accept0(Visitor *visitor); |
646 | |
647 | // attributes |
648 | ExpressionNode *base; |
649 | }; |
650 | |
651 | class DeleteExpression: public ExpressionNode |
652 | { |
653 | public: |
654 | DeleteExpression(ExpressionNode *e): |
655 | expression (e) { kind = Kind_DeleteExpression; } |
656 | virtual ~DeleteExpression() {} |
657 | |
658 | virtual void accept0(Visitor *visitor); |
659 | |
660 | // attributes |
661 | ExpressionNode *expression; |
662 | }; |
663 | |
664 | class VoidExpression: public ExpressionNode |
665 | { |
666 | public: |
667 | VoidExpression(ExpressionNode *e): |
668 | expression (e) { kind = Kind_VoidExpression; } |
669 | |
670 | virtual ~VoidExpression() {} |
671 | |
672 | virtual void accept0(Visitor *visitor); |
673 | |
674 | // attributes |
675 | ExpressionNode *expression; |
676 | }; |
677 | |
678 | class TypeOfExpression: public ExpressionNode |
679 | { |
680 | public: |
681 | TypeOfExpression(ExpressionNode *e): |
682 | expression (e) { kind = Kind_TypeOfExpression; } |
683 | |
684 | virtual ~TypeOfExpression() {} |
685 | |
686 | virtual void accept0(Visitor *visitor); |
687 | |
688 | // attributes |
689 | ExpressionNode *expression; |
690 | }; |
691 | |
692 | class PreIncrementExpression: public ExpressionNode |
693 | { |
694 | public: |
695 | PreIncrementExpression(ExpressionNode *e): |
696 | expression (e) { kind = Kind_PreIncrementExpression; } |
697 | |
698 | virtual ~PreIncrementExpression() {} |
699 | |
700 | virtual void accept0(Visitor *visitor); |
701 | |
702 | // attributes |
703 | ExpressionNode *expression; |
704 | }; |
705 | |
706 | class PreDecrementExpression: public ExpressionNode |
707 | { |
708 | public: |
709 | PreDecrementExpression(ExpressionNode *e): |
710 | expression (e) { kind = Kind_PreDecrementExpression; } |
711 | |
712 | virtual ~PreDecrementExpression() {} |
713 | |
714 | virtual void accept0(Visitor *visitor); |
715 | |
716 | // attributes |
717 | ExpressionNode *expression; |
718 | }; |
719 | |
720 | class UnaryPlusExpression: public ExpressionNode |
721 | { |
722 | public: |
723 | UnaryPlusExpression(ExpressionNode *e): |
724 | expression (e) { kind = Kind_UnaryPlusExpression; } |
725 | |
726 | virtual ~UnaryPlusExpression() {} |
727 | |
728 | virtual void accept0(Visitor *visitor); |
729 | |
730 | // attributes |
731 | ExpressionNode *expression; |
732 | }; |
733 | |
734 | class UnaryMinusExpression: public ExpressionNode |
735 | { |
736 | public: |
737 | UnaryMinusExpression(ExpressionNode *e): |
738 | expression (e) { kind = Kind_UnaryMinusExpression; } |
739 | |
740 | virtual ~UnaryMinusExpression() {} |
741 | |
742 | virtual void accept0(Visitor *visitor); |
743 | |
744 | // attributes |
745 | ExpressionNode *expression; |
746 | }; |
747 | |
748 | class TildeExpression: public ExpressionNode |
749 | { |
750 | public: |
751 | TildeExpression(ExpressionNode *e): |
752 | expression (e) { kind = Kind_TildeExpression; } |
753 | |
754 | virtual ~TildeExpression() {} |
755 | |
756 | virtual void accept0(Visitor *visitor); |
757 | |
758 | // attributes |
759 | ExpressionNode *expression; |
760 | }; |
761 | |
762 | class NotExpression: public ExpressionNode |
763 | { |
764 | public: |
765 | NotExpression(ExpressionNode *e): |
766 | expression (e) { kind = Kind_NotExpression; } |
767 | |
768 | virtual ~NotExpression() {} |
769 | |
770 | virtual void accept0(Visitor *visitor); |
771 | |
772 | // attributes |
773 | ExpressionNode *expression; |
774 | }; |
775 | |
776 | class BinaryExpression: public ExpressionNode |
777 | { |
778 | public: |
779 | BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): |
780 | left (l), op (o), right (r) |
781 | { kind = Kind_BinaryExpression; } |
782 | |
783 | virtual ~BinaryExpression() {} |
784 | |
785 | virtual BinaryExpression *binaryExpressionCast(); |
786 | |
787 | virtual void accept0(Visitor *visitor); |
788 | |
789 | // attributes |
790 | ExpressionNode *left; |
791 | int op; |
792 | ExpressionNode *right; |
793 | }; |
794 | |
795 | class ConditionalExpression: public ExpressionNode |
796 | { |
797 | public: |
798 | ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): |
799 | expression (e), ok (t), ko (f) |
800 | { kind = Kind_ConditionalExpression; } |
801 | |
802 | virtual ~ConditionalExpression() {} |
803 | |
804 | virtual void accept0(Visitor *visitor); |
805 | |
806 | // attributes |
807 | ExpressionNode *expression; |
808 | ExpressionNode *ok; |
809 | ExpressionNode *ko; |
810 | }; |
811 | |
812 | class Expression: public ExpressionNode // ### rename |
813 | { |
814 | public: |
815 | Expression(ExpressionNode *l, ExpressionNode *r): |
816 | left (l), right (r) { kind = Kind_Expression; } |
817 | |
818 | virtual ~Expression() {} |
819 | |
820 | virtual void accept0(Visitor *visitor); |
821 | |
822 | // attributes |
823 | ExpressionNode *left; |
824 | ExpressionNode *right; |
825 | }; |
826 | |
827 | class Block: public Statement |
828 | { |
829 | public: |
830 | Block(StatementList *slist): |
831 | statements (slist) { kind = Kind_Block; } |
832 | |
833 | virtual ~Block() {} |
834 | |
835 | virtual void accept0(Visitor *visitor); |
836 | |
837 | // attributes |
838 | StatementList *statements; |
839 | }; |
840 | |
841 | class StatementList: public Node |
842 | { |
843 | public: |
844 | StatementList(Statement *stmt): |
845 | statement (stmt), next (this) |
846 | { kind = Kind_StatementList; } |
847 | |
848 | StatementList(StatementList *previous, Statement *stmt): |
849 | statement (stmt) |
850 | { |
851 | kind = Kind_StatementList; |
852 | next = previous->next; |
853 | previous->next = this; |
854 | } |
855 | |
856 | virtual ~StatementList() {} |
857 | |
858 | virtual void accept0(Visitor *visitor); |
859 | |
860 | inline StatementList *finish () |
861 | { |
862 | StatementList *front = next; |
863 | next = 0; |
864 | return front; |
865 | } |
866 | |
867 | // attributes |
868 | Statement *statement; |
869 | StatementList *next; |
870 | }; |
871 | |
872 | class VariableStatement: public Statement |
873 | { |
874 | public: |
875 | VariableStatement(VariableDeclarationList *vlist): |
876 | declarations (vlist) |
877 | { kind = Kind_VariableStatement; } |
878 | |
879 | virtual ~VariableStatement() {} |
880 | |
881 | virtual void accept0(Visitor *visitor); |
882 | |
883 | // attributes |
884 | VariableDeclarationList *declarations; |
885 | }; |
886 | |
887 | class VariableDeclaration: public Node |
888 | { |
889 | public: |
890 | VariableDeclaration(QScriptNameIdImpl *n, ExpressionNode *e): |
891 | name (n), expression (e), readOnly(false) |
892 | { kind = Kind_VariableDeclaration; } |
893 | |
894 | virtual ~VariableDeclaration() {} |
895 | |
896 | virtual void accept0(Visitor *visitor); |
897 | |
898 | // attributes |
899 | QScriptNameIdImpl *name; |
900 | ExpressionNode *expression; |
901 | bool readOnly; |
902 | }; |
903 | |
904 | class VariableDeclarationList: public Node |
905 | { |
906 | public: |
907 | VariableDeclarationList(VariableDeclaration *decl): |
908 | declaration (decl), next (this) |
909 | { kind = Kind_VariableDeclarationList; } |
910 | |
911 | VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): |
912 | declaration (decl) |
913 | { |
914 | kind = Kind_VariableDeclarationList; |
915 | next = previous->next; |
916 | previous->next = this; |
917 | } |
918 | |
919 | virtual ~VariableDeclarationList() {} |
920 | |
921 | virtual void accept0(Visitor *visitor); |
922 | |
923 | inline VariableDeclarationList *finish (bool readOnly) |
924 | { |
925 | VariableDeclarationList *front = next; |
926 | next = 0; |
927 | if (readOnly) { |
928 | VariableDeclarationList *vdl; |
929 | for (vdl = front; vdl != 0; vdl = vdl->next) |
930 | vdl->declaration->readOnly = true; |
931 | } |
932 | return front; |
933 | } |
934 | |
935 | // attributes |
936 | VariableDeclaration *declaration; |
937 | VariableDeclarationList *next; |
938 | }; |
939 | |
940 | class EmptyStatement: public Statement |
941 | { |
942 | public: |
943 | EmptyStatement() { kind = Kind_EmptyStatement; } |
944 | virtual ~EmptyStatement() {} |
945 | |
946 | virtual void accept0(Visitor *visitor); |
947 | }; |
948 | |
949 | class ExpressionStatement: public Statement |
950 | { |
951 | public: |
952 | ExpressionStatement(ExpressionNode *e): |
953 | expression (e) { kind = Kind_ExpressionStatement; } |
954 | |
955 | virtual ~ExpressionStatement() {} |
956 | |
957 | virtual void accept0(Visitor *visitor); |
958 | |
959 | // attributes |
960 | ExpressionNode *expression; |
961 | }; |
962 | |
963 | class IfStatement: public Statement |
964 | { |
965 | public: |
966 | IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): |
967 | expression (e), ok (t), ko (f) |
968 | { kind = Kind_IfStatement; } |
969 | |
970 | virtual ~IfStatement() {} |
971 | |
972 | virtual void accept0(Visitor *visitor); |
973 | |
974 | // attributes |
975 | ExpressionNode *expression; |
976 | Statement *ok; |
977 | Statement *ko; |
978 | }; |
979 | |
980 | class DoWhileStatement: public Statement |
981 | { |
982 | public: |
983 | DoWhileStatement(Statement *stmt, ExpressionNode *e): |
984 | statement (stmt), expression (e) |
985 | { kind = Kind_DoWhileStatement; } |
986 | |
987 | virtual ~DoWhileStatement() {} |
988 | |
989 | virtual void accept0(Visitor *visitor); |
990 | |
991 | // attributes |
992 | Statement *statement; |
993 | ExpressionNode *expression; |
994 | }; |
995 | |
996 | class WhileStatement: public Statement |
997 | { |
998 | public: |
999 | WhileStatement(ExpressionNode *e, Statement *stmt): |
1000 | expression (e), statement (stmt) |
1001 | { kind = Kind_WhileStatement; } |
1002 | |
1003 | virtual ~WhileStatement() {} |
1004 | |
1005 | virtual void accept0(Visitor *visitor); |
1006 | |
1007 | // attributes |
1008 | ExpressionNode *expression; |
1009 | Statement *statement; |
1010 | }; |
1011 | |
1012 | class ForStatement: public Statement |
1013 | { |
1014 | public: |
1015 | ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): |
1016 | initialiser (i), condition (c), expression (e), statement (stmt) |
1017 | { kind = Kind_ForStatement; } |
1018 | |
1019 | virtual ~ForStatement() {} |
1020 | |
1021 | virtual void accept0(Visitor *visitor); |
1022 | |
1023 | // attributes |
1024 | ExpressionNode *initialiser; |
1025 | ExpressionNode *condition; |
1026 | ExpressionNode *expression; |
1027 | Statement *statement; |
1028 | }; |
1029 | |
1030 | class LocalForStatement: public Statement |
1031 | { |
1032 | public: |
1033 | LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): |
1034 | declarations (vlist), condition (c), expression (e), statement (stmt) |
1035 | { kind = Kind_LocalForStatement; } |
1036 | |
1037 | virtual ~LocalForStatement() {} |
1038 | |
1039 | virtual void accept0(Visitor *visitor); |
1040 | |
1041 | // attributes |
1042 | VariableDeclarationList *declarations; |
1043 | ExpressionNode *condition; |
1044 | ExpressionNode *expression; |
1045 | Statement *statement; |
1046 | }; |
1047 | |
1048 | class ForEachStatement: public Statement |
1049 | { |
1050 | public: |
1051 | ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): |
1052 | initialiser (i), expression (e), statement (stmt) |
1053 | { kind = Kind_ForEachStatement; } |
1054 | |
1055 | virtual ~ForEachStatement() {} |
1056 | |
1057 | virtual void accept0(Visitor *visitor); |
1058 | |
1059 | // attributes |
1060 | ExpressionNode *initialiser; |
1061 | ExpressionNode *expression; |
1062 | Statement *statement; |
1063 | }; |
1064 | |
1065 | class LocalForEachStatement: public Statement |
1066 | { |
1067 | public: |
1068 | LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): |
1069 | declaration (v), expression (e), statement (stmt) |
1070 | { kind = Kind_LocalForEachStatement; } |
1071 | |
1072 | virtual ~LocalForEachStatement() {} |
1073 | |
1074 | virtual void accept0(Visitor *visitor); |
1075 | |
1076 | // attributes |
1077 | VariableDeclaration *declaration; |
1078 | ExpressionNode *expression; |
1079 | Statement *statement; |
1080 | }; |
1081 | |
1082 | class ContinueStatement: public Statement |
1083 | { |
1084 | public: |
1085 | ContinueStatement(QScriptNameIdImpl *l = 0): |
1086 | label (l) { kind = Kind_ContinueStatement; } |
1087 | |
1088 | virtual ~ContinueStatement() {} |
1089 | |
1090 | virtual void accept0(Visitor *visitor); |
1091 | |
1092 | // attributes |
1093 | QScriptNameIdImpl *label; |
1094 | }; |
1095 | |
1096 | class BreakStatement: public Statement |
1097 | { |
1098 | public: |
1099 | BreakStatement(QScriptNameIdImpl *l = 0): |
1100 | label (l) { kind = Kind_BreakStatement; } |
1101 | |
1102 | virtual ~BreakStatement() {} |
1103 | |
1104 | virtual void accept0(Visitor *visitor); |
1105 | |
1106 | // attributes |
1107 | QScriptNameIdImpl *label; |
1108 | }; |
1109 | |
1110 | class ReturnStatement: public Statement |
1111 | { |
1112 | public: |
1113 | ReturnStatement(ExpressionNode *e): |
1114 | expression (e) { kind = Kind_ReturnStatement; } |
1115 | |
1116 | virtual ~ReturnStatement() {} |
1117 | |
1118 | virtual void accept0(Visitor *visitor); |
1119 | |
1120 | // attributes |
1121 | ExpressionNode *expression; |
1122 | }; |
1123 | |
1124 | class WithStatement: public Statement |
1125 | { |
1126 | public: |
1127 | WithStatement(ExpressionNode *e, Statement *stmt): |
1128 | expression (e), statement (stmt) |
1129 | { kind = Kind_WithStatement; } |
1130 | |
1131 | virtual ~WithStatement() {} |
1132 | |
1133 | virtual void accept0(Visitor *visitor); |
1134 | |
1135 | // attributes |
1136 | ExpressionNode *expression; |
1137 | Statement *statement; |
1138 | }; |
1139 | |
1140 | class SwitchStatement: public Statement |
1141 | { |
1142 | public: |
1143 | SwitchStatement(ExpressionNode *e, CaseBlock *b): |
1144 | expression (e), block (b) |
1145 | { kind = Kind_SwitchStatement; } |
1146 | |
1147 | virtual ~SwitchStatement() {} |
1148 | |
1149 | virtual void accept0(Visitor *visitor); |
1150 | |
1151 | // attributes |
1152 | ExpressionNode *expression; |
1153 | CaseBlock *block; |
1154 | }; |
1155 | |
1156 | class CaseBlock: public Node |
1157 | { |
1158 | public: |
1159 | CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): |
1160 | clauses (c), defaultClause (d), moreClauses (r) |
1161 | { kind = Kind_CaseBlock; } |
1162 | |
1163 | virtual ~CaseBlock() {} |
1164 | |
1165 | virtual void accept0(Visitor *visitor); |
1166 | |
1167 | // attributes |
1168 | CaseClauses *clauses; |
1169 | DefaultClause *defaultClause; |
1170 | CaseClauses *moreClauses; |
1171 | }; |
1172 | |
1173 | class CaseClauses: public Node |
1174 | { |
1175 | public: |
1176 | CaseClauses(CaseClause *c): |
1177 | clause (c), next (this) |
1178 | { kind = Kind_CaseClauses; } |
1179 | |
1180 | CaseClauses(CaseClauses *previous, CaseClause *c): |
1181 | clause (c) |
1182 | { |
1183 | kind = Kind_CaseClauses; |
1184 | next = previous->next; |
1185 | previous->next = this; |
1186 | } |
1187 | |
1188 | virtual ~CaseClauses() {} |
1189 | |
1190 | virtual void accept0(Visitor *visitor); |
1191 | |
1192 | inline CaseClauses *finish () |
1193 | { |
1194 | CaseClauses *front = next; |
1195 | next = 0; |
1196 | return front; |
1197 | } |
1198 | |
1199 | //attributes |
1200 | CaseClause *clause; |
1201 | CaseClauses *next; |
1202 | }; |
1203 | |
1204 | class CaseClause: public Node |
1205 | { |
1206 | public: |
1207 | CaseClause(ExpressionNode *e, StatementList *slist): |
1208 | expression (e), statements (slist) |
1209 | { kind = Kind_CaseClause; } |
1210 | |
1211 | virtual ~CaseClause() {} |
1212 | |
1213 | virtual void accept0(Visitor *visitor); |
1214 | |
1215 | // attributes |
1216 | ExpressionNode *expression; |
1217 | StatementList *statements; |
1218 | }; |
1219 | |
1220 | class DefaultClause: public Node |
1221 | { |
1222 | public: |
1223 | DefaultClause(StatementList *slist): |
1224 | statements (slist) |
1225 | { kind = Kind_DefaultClause; } |
1226 | |
1227 | virtual ~DefaultClause() {} |
1228 | |
1229 | virtual void accept0(Visitor *visitor); |
1230 | |
1231 | // attributes |
1232 | StatementList *statements; |
1233 | }; |
1234 | |
1235 | class LabelledStatement: public Statement |
1236 | { |
1237 | public: |
1238 | LabelledStatement(QScriptNameIdImpl *l, Statement *stmt): |
1239 | label (l), statement (stmt) |
1240 | { kind = Kind_LabelledStatement; } |
1241 | |
1242 | virtual ~LabelledStatement() {} |
1243 | |
1244 | virtual void accept0(Visitor *visitor); |
1245 | |
1246 | // attributes |
1247 | QScriptNameIdImpl *label; |
1248 | Statement *statement; |
1249 | }; |
1250 | |
1251 | class ThrowStatement: public Statement |
1252 | { |
1253 | public: |
1254 | ThrowStatement(ExpressionNode *e): |
1255 | expression (e) { kind = Kind_ThrowStatement; } |
1256 | |
1257 | virtual ~ThrowStatement() {} |
1258 | |
1259 | virtual void accept0(Visitor *visitor); |
1260 | |
1261 | // attributes |
1262 | ExpressionNode *expression; |
1263 | }; |
1264 | |
1265 | class TryStatement: public Statement |
1266 | { |
1267 | public: |
1268 | TryStatement(Statement *stmt, Catch *c, Finally *f): |
1269 | statement (stmt), catchExpression (c), finallyExpression (f) |
1270 | { kind = Kind_TryStatement; } |
1271 | |
1272 | TryStatement(Statement *stmt, Finally *f): |
1273 | statement (stmt), catchExpression (0), finallyExpression (f) |
1274 | { kind = Kind_TryStatement; } |
1275 | |
1276 | TryStatement(Statement *stmt, Catch *c): |
1277 | statement (stmt), catchExpression (c), finallyExpression (0) |
1278 | { kind = Kind_TryStatement; } |
1279 | |
1280 | virtual ~TryStatement() {} |
1281 | |
1282 | virtual void accept0(Visitor *visitor); |
1283 | |
1284 | // attributes |
1285 | Statement *statement; |
1286 | Catch *catchExpression; |
1287 | Finally *finallyExpression; |
1288 | }; |
1289 | |
1290 | class Catch: public Node |
1291 | { |
1292 | public: |
1293 | Catch(QScriptNameIdImpl *n, Statement *stmt): |
1294 | name (n), statement (stmt) |
1295 | { kind = Kind_Catch; } |
1296 | |
1297 | virtual ~Catch() {} |
1298 | |
1299 | virtual void accept0(Visitor *visitor); |
1300 | |
1301 | // attributes |
1302 | QScriptNameIdImpl *name; |
1303 | Statement *statement; |
1304 | }; |
1305 | |
1306 | class Finally: public Node |
1307 | { |
1308 | public: |
1309 | Finally(Statement *stmt): |
1310 | statement (stmt) |
1311 | { kind = Kind_Finally; } |
1312 | |
1313 | virtual ~Finally() {} |
1314 | |
1315 | virtual void accept0(Visitor *visitor); |
1316 | |
1317 | // attributes |
1318 | Statement *statement; |
1319 | }; |
1320 | |
1321 | class FunctionExpression: public ExpressionNode |
1322 | { |
1323 | public: |
1324 | FunctionExpression(QScriptNameIdImpl *n, FormalParameterList *f, FunctionBody *b): |
1325 | name (n), formals (f), body (b) |
1326 | { kind = Kind_FunctionExpression; } |
1327 | |
1328 | virtual ~FunctionExpression() {} |
1329 | |
1330 | virtual void accept0(Visitor *visitor); |
1331 | |
1332 | // attributes |
1333 | QScriptNameIdImpl *name; |
1334 | FormalParameterList *formals; |
1335 | FunctionBody *body; |
1336 | }; |
1337 | |
1338 | class FunctionDeclaration: public FunctionExpression |
1339 | { |
1340 | public: |
1341 | FunctionDeclaration(QScriptNameIdImpl *n, FormalParameterList *f, FunctionBody *b): |
1342 | FunctionExpression(n, f, b) |
1343 | { kind = Kind_FunctionDeclaration; } |
1344 | |
1345 | virtual ~FunctionDeclaration() {} |
1346 | |
1347 | virtual void accept0(Visitor *visitor); |
1348 | }; |
1349 | |
1350 | class FormalParameterList: public Node |
1351 | { |
1352 | public: |
1353 | FormalParameterList(QScriptNameIdImpl *n): |
1354 | name (n), next (this) |
1355 | { kind = Kind_FormalParameterList; } |
1356 | |
1357 | FormalParameterList(FormalParameterList *previous, QScriptNameIdImpl *n): |
1358 | name (n) |
1359 | { |
1360 | kind = Kind_FormalParameterList; |
1361 | next = previous->next; |
1362 | previous->next = this; |
1363 | } |
1364 | |
1365 | virtual ~FormalParameterList() {} |
1366 | |
1367 | virtual void accept0(Visitor *visitor); |
1368 | |
1369 | inline FormalParameterList *finish () |
1370 | { |
1371 | FormalParameterList *front = next; |
1372 | next = 0; |
1373 | return front; |
1374 | } |
1375 | |
1376 | // attributes |
1377 | QScriptNameIdImpl *name; |
1378 | FormalParameterList *next; |
1379 | }; |
1380 | |
1381 | class FunctionBody: public Node |
1382 | { |
1383 | public: |
1384 | FunctionBody(SourceElements *elts): |
1385 | elements (elts) |
1386 | { kind = Kind_FunctionBody; } |
1387 | |
1388 | virtual ~FunctionBody() {} |
1389 | |
1390 | virtual void accept0(Visitor *visitor); |
1391 | |
1392 | // attributes |
1393 | SourceElements *elements; |
1394 | }; |
1395 | |
1396 | class Program: public Node |
1397 | { |
1398 | public: |
1399 | Program(SourceElements *elts): |
1400 | elements (elts) |
1401 | { kind = Kind_Program; } |
1402 | |
1403 | virtual ~Program() {} |
1404 | |
1405 | virtual void accept0(Visitor *visitor); |
1406 | |
1407 | // attributes |
1408 | SourceElements *elements; |
1409 | }; |
1410 | |
1411 | class SourceElements: public Node |
1412 | { |
1413 | public: |
1414 | SourceElements(SourceElement *elt): |
1415 | element (elt), next (this) |
1416 | { kind = Kind_SourceElements; } |
1417 | |
1418 | SourceElements(SourceElements *previous, SourceElement *elt): |
1419 | element (elt) |
1420 | { |
1421 | kind = Kind_SourceElements; |
1422 | next = previous->next; |
1423 | previous->next = this; |
1424 | } |
1425 | |
1426 | virtual ~SourceElements() {} |
1427 | |
1428 | virtual void accept0(Visitor *visitor); |
1429 | |
1430 | inline SourceElements *finish () |
1431 | { |
1432 | SourceElements *front = next; |
1433 | next = 0; |
1434 | return front; |
1435 | } |
1436 | |
1437 | // attributes |
1438 | SourceElement *element; |
1439 | SourceElements *next; |
1440 | }; |
1441 | |
1442 | class SourceElement: public Node |
1443 | { |
1444 | public: |
1445 | inline SourceElement() |
1446 | { kind = Kind_SourceElement; } |
1447 | |
1448 | virtual ~SourceElement() {} |
1449 | }; |
1450 | |
1451 | class FunctionSourceElement: public SourceElement |
1452 | { |
1453 | public: |
1454 | FunctionSourceElement(FunctionDeclaration *f): |
1455 | declaration (f) |
1456 | { kind = Kind_FunctionSourceElement; } |
1457 | |
1458 | virtual ~FunctionSourceElement() {} |
1459 | |
1460 | virtual void accept0(Visitor *visitor); |
1461 | |
1462 | // attributes |
1463 | FunctionDeclaration *declaration; |
1464 | }; |
1465 | |
1466 | class StatementSourceElement: public SourceElement |
1467 | { |
1468 | public: |
1469 | StatementSourceElement(Statement *stmt): |
1470 | statement (stmt) |
1471 | { kind = Kind_StatementSourceElement; } |
1472 | |
1473 | virtual ~StatementSourceElement() {} |
1474 | |
1475 | virtual void accept0(Visitor *visitor); |
1476 | |
1477 | // attributes |
1478 | Statement *statement; |
1479 | }; |
1480 | |
1481 | class DebuggerStatement: public Statement |
1482 | { |
1483 | public: |
1484 | DebuggerStatement() |
1485 | { kind = Kind_DebuggerStatement; } |
1486 | |
1487 | virtual ~DebuggerStatement() {} |
1488 | |
1489 | virtual void accept0(Visitor *visitor); |
1490 | }; |
1491 | |
1492 | } } // namespace AST |
1493 | |
1494 | QT_END_NAMESPACE |
1495 | |
1496 | #endif |
1497 | |