ScummVM API documentation
ast.h
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7#ifndef LINGODEC_AST_H
8#define LINGODEC_AST_H
9
10#include "common/array.h"
11#include "common/ptr.h"
12#include "common/str.h"
13#include "common/util.h"
14#include "./enums.h"
15
16namespace LingoDec {
17
18struct CaseLabelNode;
19struct Handler;
20struct LoopNode;
21struct Node;
22struct RepeatWithInStmtNode;
23
24/* Datum */
25
26struct Datum {
27 DatumType type;
28 int i = -1;
29 double f = 0.0f;
32
33 Datum() {
34 type = kDatumVoid;
35 }
36 Datum(int val) {
37 type = kDatumInt;
38 i = val;
39 }
40 Datum(double val) {
41 type = kDatumFloat;
42 f = val;
43 }
44 Datum(DatumType t, Common::String val) {
45 type = t;
46 s = val;
47 }
49 type = t;
50 l = val;
51 }
52
53 int toInt();
54};
55
56class NodeVisitor;
57
58/* Node */
59
60struct Node {
61 NodeType type;
62 bool isExpression;
63 bool isStatement;
64 bool isLabel;
65 bool isLoop;
66 Node *parent;
67 uint32 _startOffset;
68 uint32 _endOffset;
69
70 Node(NodeType t, uint32 offset) : type(t), isExpression(false), isStatement(false), isLabel(false), isLoop(false), parent(nullptr), _startOffset(offset), _endOffset(offset) {}
71 virtual ~Node() {}
72 virtual void accept(NodeVisitor& visitor) const = 0;
73 virtual Common::SharedPtr<Datum> getValue();
74 Node *ancestorStatement();
75 LoopNode *ancestorLoop();
76 virtual bool hasSpaces(bool dot);
77};
78
79/* ExprNode */
80
81struct ExprNode : Node {
82 ExprNode(NodeType t, uint32 offset) : Node(t, offset) {
83 isExpression = true;
84 }
85};
86
87/* StmtNode */
88
89struct StmtNode : Node {
90 StmtNode(NodeType t, uint32 offset) : Node(t, offset) {
91 isStatement = true;
92 }
93};
94
95/* LabelNode */
96
97struct LabelNode : Node {
98 LabelNode(NodeType t, uint32 offset) : Node(t, offset) {
99 isLabel = true;
100 }
101};
102
103/* LoopNode */
104
106 uint32 startIndex;
107
108 LoopNode(NodeType t, uint32 startIndex_, uint32 offset) : StmtNode(t, offset), startIndex(startIndex_) {
109 isLoop = true;
110 }
111};
112
113/* ErrorNode */
114
116 explicit ErrorNode(uint32 offset) : ExprNode(kErrorNode, offset) {}
117 bool hasSpaces(bool dot) override;
118 void accept(NodeVisitor &visitor) const override;
119};
120
121/* CommentNode */
122
124 Common::String text;
125
126 CommentNode(uint32 offset, Common::String t) : Node(kCommentNode, offset), text(t) {}
127 void accept(NodeVisitor &visitor) const override;
128};
129
130/* LiteralNode */
131
134
135 LiteralNode(uint32 offset, Common::SharedPtr<Datum> d) : ExprNode(kLiteralNode, offset) {
136 value = Common::move(d);
137 }
138 Common::SharedPtr<Datum> getValue() override;
139 bool hasSpaces(bool dot) override;
140 void accept(NodeVisitor &visitor) const override;
141};
142
143/* BlockNode */
144
145struct BlockNode : Node {
147
148 // for use during translation:
149 uint32 endPos;
150 CaseLabelNode *currentCaseLabel = nullptr;
151
152 explicit BlockNode(uint32 offset) : Node(kBlockNode, offset), endPos(Common::String::npos) {}
153 void addChild(Common::SharedPtr<Node> child);
154 void accept(NodeVisitor &visitor) const override;
155};
156
157/* HandlerNode */
158
160 Handler *handler;
162
163 HandlerNode(uint32 offset, Handler *h)
164 : Node(kHandlerNode, offset), handler(h) {
165 block = Common::SharedPtr<BlockNode>(new BlockNode(offset));
166 block->parent = this;
167 }
168 void accept(NodeVisitor &visitor) const override;
169};
170
171/* ExitStmtNode */
172
174 explicit ExitStmtNode(uint32 offset) : StmtNode(kExitStmtNode, offset) {}
175 void accept(NodeVisitor &visitor) const override;
176};
177
178/* InverseOpNode */
179
182
183 InverseOpNode(uint32 offset, Common::SharedPtr<Node> o) : ExprNode(kInverseOpNode, offset) {
184 operand = Common::move(o);
185 operand->parent = this;
186 }
187 void accept(NodeVisitor &visitor) const override;
188};
189
190/* NotOpNode */
191
194
195 NotOpNode(uint32 offset, Common::SharedPtr<Node> o) : ExprNode(kNotOpNode, offset) {
196 operand = Common::move(o);
197 operand->parent = this;
198 }
199 void accept(NodeVisitor &visitor) const override;
200};
201
202/* BinaryOpNode */
203
205 OpCode opcode;
208
209 BinaryOpNode(uint32 offset, OpCode op, Common::SharedPtr<Node> a, Common::SharedPtr<Node> b)
210 : ExprNode(kBinaryOpNode, offset), opcode(op) {
211 left = Common::move(a);
212 left->parent = this;
213 right = Common::move(b);
214 right->parent = this;
215 }
216 virtual unsigned int getPrecedence() const;
217 void accept(NodeVisitor &visitor) const override;
218};
219
220/* ChunkExprNode */
221
223 ChunkExprType type;
227
229 : ExprNode(kChunkExprNode, offset), type(t) {
230 first = Common::move(a);
231 first->parent = this;
232 last = Common::move(b);
233 last->parent = this;
234 string = Common::move(s);
235 string->parent = this;
236 }
237 void accept(NodeVisitor &visitor) const override;
238};
239
240/* ChunkHiliteStmtNode */
241
244
245 ChunkHiliteStmtNode(uint32 offset, Common::SharedPtr<Node> c) : StmtNode(kChunkHiliteStmtNode, offset) {
246 chunk = Common::move(c);
247 chunk->parent = this;
248 }
249 void accept(NodeVisitor &visitor) const override;
250};
251
252/* ChunkDeleteStmtNode */
253
256
257 ChunkDeleteStmtNode(uint32 offset, Common::SharedPtr<Node> c) : StmtNode(kChunkDeleteStmtNode, offset) {
258 chunk = Common::move(c);
259 chunk->parent = this;
260 }
261 void accept(NodeVisitor &visitor) const override;
262};
263
264/* SpriteIntersectsExprNode */
265
267 Common::SharedPtr<Node> firstSprite;
268 Common::SharedPtr<Node> secondSprite;
269
271 : ExprNode(kSpriteIntersectsExprNode, offset) {
272 firstSprite = Common::move(a);
273 firstSprite->parent = this;
274 secondSprite = Common::move(b);
275 secondSprite->parent = this;
276 }
277 void accept(NodeVisitor &visitor) const override;
278};
279
280/* SpriteWithinExprNode */
281
283 Common::SharedPtr<Node> firstSprite;
284 Common::SharedPtr<Node> secondSprite;
285
287 : ExprNode(kSpriteWithinExprNode, offset) {
288 firstSprite = Common::move(a);
289 firstSprite->parent = this;
290 secondSprite = Common::move(b);
291 secondSprite->parent = this;
292 }
293 void accept(NodeVisitor &visitor) const override;
294};
295
296/* MemberExprNode */
297
299 Common::String type;
302
303 MemberExprNode(uint32 offset, Common::String type_, Common::SharedPtr<Node> memberID_, Common::SharedPtr<Node> castID_)
304 : ExprNode(kMemberExprNode, offset), type(type_) {
305 this->memberID = Common::move(memberID_);
306 this->memberID->parent = this;
307 if (castID_) {
308 this->castID = Common::move(castID_);
309 this->castID->parent = this;
310 }
311 }
312 bool hasSpaces(bool dot) override;
313 void accept(NodeVisitor &visitor) const override;
314};
315
316/* VarNode */
317
319 Common::String varName;
320
321 VarNode(uint32 offset, Common::String v) : ExprNode(kVarNode, offset), varName(v) {}
322 bool hasSpaces(bool dot) override;
323 void accept(NodeVisitor &visitor) const override;
324};
325
326/* AssignmentStmtNode */
327
331 bool forceVerbose;
332
333 AssignmentStmtNode(uint32 offset, Common::SharedPtr<Node> var, Common::SharedPtr<Node> val, bool forceVerbose_ = false)
334 : StmtNode(kAssignmentStmtNode, offset), forceVerbose(forceVerbose_) {
335 variable = Common::move(var);
336 variable->parent = this;
337 value = Common::move(val);
338 value->parent = this;
339 }
340
341 void accept(NodeVisitor &visitor) const override;
342};
343
344/* IfStmtNode */
345
347 bool hasElse;
348 Common::SharedPtr<Node> condition;
351
352 IfStmtNode(uint32 offset, Common::SharedPtr<Node> c) : StmtNode(kIfStmtNode, offset), hasElse(false) {
353 condition = Common::move(c);
354 condition->parent = this;
355 block1 = Common::SharedPtr<BlockNode>(new BlockNode(offset));
356 block1->parent = this;
357 block2 = Common::SharedPtr<BlockNode>(new BlockNode(offset));
358 block2->parent = this;
359 }
360 void accept(NodeVisitor &visitor) const override;
361};
362
363/* RepeatWhileStmtNode */
364
366 Common::SharedPtr<Node> condition;
368
369 RepeatWhileStmtNode(uint32 startIndex_, Common::SharedPtr<Node> c, uint32 offset)
370 : LoopNode(kRepeatWhileStmtNode, startIndex_, offset) {
371 condition = Common::move(c);
372 condition->parent = this;
373 block = Common::SharedPtr<BlockNode>(new BlockNode(offset));
374 block->parent = this;
375 }
376 void accept(NodeVisitor &visitor) const override;
377};
378
379/* RepeatWithInStmtNode */
380
382 Common::String varName;
385
386 RepeatWithInStmtNode(uint32 startIndex_, Common::String v, Common::SharedPtr<Node> l, uint32 offset)
387 : LoopNode(kRepeatWithInStmtNode, startIndex_, offset) {
388 varName = v;
389 list = Common::move(l);
390 list->parent = this;
391 block = Common::SharedPtr<BlockNode>(new BlockNode(offset));
392 block->parent = this;
393 }
394 void accept(NodeVisitor &visitor) const override;
395};
396
397/* RepeatWithToStmtNode */
398
400 Common::String varName;
402 bool up;
405
406 RepeatWithToStmtNode(uint32 startIndex_, Common::String v, Common::SharedPtr<Node> s, bool _up, Common::SharedPtr<Node> e, uint32 offset)
407 : LoopNode(kRepeatWithToStmtNode, startIndex_, offset), up(_up) {
408 varName = v;
409 start = Common::move(s);
410 start->parent = this;
411 end = Common::move(e);
412 end->parent = this;
413 block = Common::SharedPtr<BlockNode>(new BlockNode(offset));
414 block->parent = this;
415 }
416 void accept(NodeVisitor &visitor) const override;
417};
418
419/* CaseLabelNode */
420
423 CaseExpect expect;
424
426
429
430 CaseLabelNode(uint32 offset, Common::SharedPtr<Node> v, CaseExpect e) : LabelNode(kCaseLabelNode, offset), expect(e) {
431 value = Common::move(v);
432 value->parent = this;
433 }
434 void accept(NodeVisitor &visitor) const override;
435};
436
437/* OtherwiseNode */
438
441
442 explicit OtherwiseNode(uint32 offset) : LabelNode(kOtherwiseNode, offset) {
443 block = Common::SharedPtr<BlockNode>(new BlockNode(offset));
444 block->parent = this;
445 }
446 void accept(NodeVisitor &visitor) const override;
447};
448
449/* EndCaseNode */
450
452 explicit EndCaseNode(uint32 offset) : LabelNode(kEndCaseNode, offset) {}
453 void accept(NodeVisitor &visitor) const override;
454};
455
456/* CaseStmtNode */
457
462
463 // for use during translation:
464 int32 endPos = -1;
465 int32 potentialOtherwisePos = -1;
466
467 CaseStmtNode(uint32 offset, Common::SharedPtr<Node> v) : StmtNode(kCaseStmtNode, offset) {
468 value = Common::move(v);
469 value->parent = this;
470 }
471 void addOtherwise(uint32 offset);
472 void accept(NodeVisitor &visitor) const override;
473};
474
475/* TellStmtNode */
476
480
481 TellStmtNode(uint32 offset, Common::SharedPtr<Node> w) : StmtNode(kTellStmtNode, offset) {
482 window = Common::move(w);
483 window->parent = this;
484 block = Common::SharedPtr<BlockNode>(new BlockNode(offset));
485 block->parent = this;
486 }
487 void accept(NodeVisitor &visitor) const override;
488};
489
490/* SoundCmdStmtNode */
491
493 Common::String cmd;
495
496 SoundCmdStmtNode(uint32 offset, Common::String c, Common::SharedPtr<Node> a) : StmtNode(kSoundCmdStmtNode, offset) {
497 cmd = c;
498 argList = Common::move(a);
499 argList->parent = this;
500 }
501 void accept(NodeVisitor &visitor) const override;
502};
503
504/* PlayCmdStmtNode */
505
508
509 PlayCmdStmtNode(uint32 offset, Common::SharedPtr<Node> a) : StmtNode(kPlayCmdStmtNode, offset) {
510 argList = Common::move(a);
511 argList->parent = this;
512 }
513 void accept(NodeVisitor &visitor) const override;
514};
515
516/* CallNode */
517
518struct CallNode : Node {
519 Common::String name;
521
522 CallNode(uint32 offset, Common::String n, Common::SharedPtr<Node> a) : Node(kCallNode, offset) {
523 name = n;
524 argList = Common::move(a);
525 argList->parent = this;
526 if (argList->getValue()->type == kDatumArgListNoRet)
527 isStatement = true;
528 else
529 isExpression = true;
530 }
531 bool noParens() const;
532 bool isMemberExpr() const;
533 bool hasSpaces(bool dot) override;
534 void accept(NodeVisitor &visitor) const override;
535};
536
537/* ObjCallNode */
538
540 Common::String name;
542
543 ObjCallNode(uint32 offset, Common::String n, Common::SharedPtr<Node> a) : Node(kObjCallNode, offset) {
544 name = n;
545 argList = Common::move(a);
546 argList->parent = this;
547 if (argList->getValue()->type == kDatumArgListNoRet)
548 isStatement = true;
549 else
550 isExpression = true;
551 }
552 bool hasSpaces(bool dot) override;
553 void accept(NodeVisitor &visitor) const override;
554};
555
556/* ObjCallV4Node */
557
561
562 ObjCallV4Node(uint32 offset, Common::SharedPtr<Node> o, Common::SharedPtr<Node> a) : Node(kObjCallV4Node, offset) {
563 obj = o;
564 argList = Common::move(a);
565 argList->parent = this;
566 if (argList->getValue()->type == kDatumArgListNoRet)
567 isStatement = true;
568 else
569 isExpression = true;
570 }
571 bool hasSpaces(bool dot) override;
572 void accept(NodeVisitor &visitor) const override;
573};
574
575/* TheExprNode */
576
578 Common::String prop;
579
580 TheExprNode(uint32 offset, Common::String p) : ExprNode(kTheExprNode, offset), prop(p) {}
581 void accept(NodeVisitor &visitor) const override;
582};
583
584/* LastStringChunkExprNode */
585
587 ChunkExprType type;
589
590 LastStringChunkExprNode(uint32 offset, ChunkExprType t, Common::SharedPtr<Node> o)
591 : ExprNode(kLastStringChunkExprNode, offset), type(t) {
592 obj = Common::move(o);
593 obj->parent = this;
594 }
595 void accept(NodeVisitor &visitor) const override;
596};
597
598/* StringChunkCountExprNode */
599
601 ChunkExprType type;
603
604 StringChunkCountExprNode(uint32 offset, ChunkExprType t, Common::SharedPtr<Node> o)
605 : ExprNode(kStringChunkCountExprNode, offset), type(t) {
606 obj = Common::move(o);
607 obj->parent = this;
608 }
609 void accept(NodeVisitor &visitor) const override;
610};
611
612/* MenuPropExprNode */
613
616 unsigned int prop;
617
618 MenuPropExprNode(uint32 offset, Common::SharedPtr<Node> m, unsigned int p)
619 : ExprNode(kMenuPropExprNode, offset), prop(p) {
620 menuID = Common::move(m);
621 menuID->parent = this;
622 }
623 void accept(NodeVisitor &visitor) const override;
624};
625
626/* MenuItemPropExprNode */
627
631 unsigned int prop;
632
633 MenuItemPropExprNode(uint32 offset, Common::SharedPtr<Node> m, Common::SharedPtr<Node> i, unsigned int p)
634 : ExprNode(kMenuItemPropExprNode, offset), prop(p) {
635 menuID = Common::move(m);
636 menuID->parent = this;
637 itemID = Common::move(i);
638 itemID->parent = this;
639 }
640 void accept(NodeVisitor &visitor) const override;
641};
642
643/* SoundPropExprNode */
644
647 unsigned int prop;
648
649 SoundPropExprNode(uint32 offset, Common::SharedPtr<Node> s, unsigned int p)
650 : ExprNode(kSoundPropExprNode, offset), prop(p) {
651 soundID = Common::move(s);
652 soundID->parent = this;
653 }
654 void accept(NodeVisitor &visitor) const override;
655};
656
657/* SpritePropExprNode */
658
661 unsigned int prop;
662
663 SpritePropExprNode(uint32 offset, Common::SharedPtr<Node> s, unsigned int p)
664 : ExprNode(kSpritePropExprNode, offset), prop(p) {
665 spriteID = Common::move(s);
666 spriteID->parent = this;
667 }
668 void accept(NodeVisitor &visitor) const override;
669};
670
671/* ThePropExprNode */
672
675 Common::String prop;
676
678 : ExprNode(kThePropExprNode, offset), prop(p) {
679 obj = Common::move(o);
680 obj->parent = this;
681 }
682 void accept(NodeVisitor &visitor) const override;
683};
684
685/* ObjPropExprNode */
686
689 Common::String prop;
690
692 : ExprNode(kObjPropExprNode, offset), prop(p) {
693 obj = Common::move(o);
694 obj->parent = this;
695 }
696 bool hasSpaces(bool dot) override;
697 void accept(NodeVisitor &visitor) const override;
698};
699
700/* ObjBracketExprNode */
701
705
707 : ExprNode(kObjBracketExprNode, offset) {
708 obj = Common::move(o);
709 obj->parent = this;
710 prop = Common::move(p);
711 prop->parent = this;
712 }
713 bool hasSpaces(bool dot) override;
714 void accept(NodeVisitor &visitor) const override;
715};
716
717/* ObjPropIndexExprNode */
718
721 Common::String prop;
724
726 : ExprNode(kObjPropIndexExprNode, offset), prop(p) {
727 obj = Common::move(o);
728 obj->parent = this;
729 index = Common::move(i);
730 index->parent = this;
731 if (i2) {
732 index2 = Common::move(i2);
733 index2->parent = this;
734 }
735 }
736 bool hasSpaces(bool dot) override;
737 void accept(NodeVisitor &visitor) const override;
738};
739
740/* ExitRepeatStmtNode */
741
743 explicit ExitRepeatStmtNode(uint32 offset) : StmtNode(kExitRepeatStmtNode, offset) {}
744 void accept(NodeVisitor &visitor) const override;
745};
746
747/* NextRepeatStmtNode */
748
750 explicit NextRepeatStmtNode(uint32 offset) : StmtNode(kNextRepeatStmtNode, offset) {}
751 void accept(NodeVisitor &visitor) const override;
752};
753
754/* PutStmtNode */
755
757 PutType type;
760
761 PutStmtNode(uint32 offset, PutType t, Common::SharedPtr<Node> var, Common::SharedPtr<Node> val)
762 : StmtNode(kPutStmtNode, offset), type(t) {
763 variable = Common::move(var);
764 variable->parent = this;
765 value = Common::move(val);
766 value->parent = this;
767 }
768 void accept(NodeVisitor &visitor) const override;
769};
770
771/* WhenStmtNode */
772
774 int event;
775 Common::String script;
776
777 WhenStmtNode(uint32 offset, int e, Common::String s)
778 : StmtNode(kWhenStmtNode, offset), event(e), script(s) {}
779 void accept(NodeVisitor &visitor) const override;
780};
781
782/* NewObjNode */
783
785 Common::String objType;
787
788 NewObjNode(uint32 offset, Common::String o, Common::SharedPtr<Node> args) : ExprNode(kNewObjNode, offset), objType(o), objArgs(args) {}
789 void accept(NodeVisitor &visitor) const override;
790};
791
793public:
794 virtual ~NodeVisitor() {}
795 virtual void visit(const HandlerNode &node) { defaultVisit(node); }
796 virtual void visit(const ErrorNode &node) { defaultVisit(node); }
797 virtual void visit(const CommentNode &node) { defaultVisit(node); }
798 virtual void visit(const NewObjNode &node) { defaultVisit(node); }
799 virtual void visit(const LiteralNode &node) { defaultVisit(node); }
800 virtual void visit(const IfStmtNode &node) { defaultVisit(node); }
801 virtual void visit(const EndCaseNode &node) { defaultVisit(node); }
802 virtual void visit(const ObjCallNode &node) { defaultVisit(node); }
803 virtual void visit(const PutStmtNode &node) { defaultVisit(node); }
804 virtual void visit(const TheExprNode &node) { defaultVisit(node); }
805 virtual void visit(const BinaryOpNode &node) { defaultVisit(node); }
806 virtual void visit(const CaseStmtNode &node) { defaultVisit(node); }
807 virtual void visit(const ExitStmtNode &node) { defaultVisit(node); }
808 virtual void visit(const TellStmtNode &node) { defaultVisit(node); }
809 virtual void visit(const WhenStmtNode &node) { defaultVisit(node); }
810 virtual void visit(const CaseLabelNode &node) { defaultVisit(node); }
811 virtual void visit(const ChunkExprNode &node) { defaultVisit(node); }
812 virtual void visit(const InverseOpNode &node) { defaultVisit(node); }
813 virtual void visit(const ObjCallV4Node &node) { defaultVisit(node); }
814 virtual void visit(const OtherwiseNode &node) { defaultVisit(node); }
815 virtual void visit(const MemberExprNode &node) { defaultVisit(node); }
816 virtual void visit(const ObjPropExprNode &node) { defaultVisit(node); }
817 virtual void visit(const PlayCmdStmtNode &node) { defaultVisit(node); }
818 virtual void visit(const ThePropExprNode &node) { defaultVisit(node); }
819 virtual void visit(const MenuPropExprNode &node) { defaultVisit(node); }
820 virtual void visit(const SoundCmdStmtNode &node) { defaultVisit(node); }
821 virtual void visit(const SoundPropExprNode &node) { defaultVisit(node); }
822 virtual void visit(const AssignmentStmtNode &node) { defaultVisit(node); }
823 virtual void visit(const ExitRepeatStmtNode &node) { defaultVisit(node); }
824 virtual void visit(const NextRepeatStmtNode &node) { defaultVisit(node); }
825 virtual void visit(const ObjBracketExprNode &node) { defaultVisit(node); }
826 virtual void visit(const SpritePropExprNode &node) { defaultVisit(node); }
827 virtual void visit(const ChunkDeleteStmtNode &node) { defaultVisit(node); }
828 virtual void visit(const ChunkHiliteStmtNode &node) { defaultVisit(node); }
829 virtual void visit(const RepeatWhileStmtNode &node) { defaultVisit(node); }
830 virtual void visit(const MenuItemPropExprNode &node) { defaultVisit(node); }
831 virtual void visit(const ObjPropIndexExprNode &node) { defaultVisit(node); }
832 virtual void visit(const RepeatWithInStmtNode &node) { defaultVisit(node); }
833 virtual void visit(const RepeatWithToStmtNode &node) { defaultVisit(node); }
834 virtual void visit(const SpriteWithinExprNode &node) { defaultVisit(node); }
835 virtual void visit(const LastStringChunkExprNode &node) { defaultVisit(node); }
836 virtual void visit(const SpriteIntersectsExprNode &node) { defaultVisit(node); }
837 virtual void visit(const StringChunkCountExprNode &node) { defaultVisit(node); }
838 virtual void visit(const VarNode &node) { defaultVisit(node); }
839 virtual void visit(const CallNode &node) { defaultVisit(node); }
840 virtual void visit(const BlockNode &node) { defaultVisit(node); }
841 virtual void visit(const NotOpNode &node) { defaultVisit(node); }
842
843 virtual void defaultVisit(const Node &) {}
844};
845
846/* AST */
847
848struct AST {
850 BlockNode *currentBlock;
851
852 AST(uint32 offset, Handler *handler){
853 root = Common::SharedPtr<HandlerNode>(new HandlerNode(offset, handler));
854 currentBlock = root->block.get();
855 }
856
857 void addStatement(Common::SharedPtr<Node> statement);
858 void enterBlock(BlockNode *block);
859 void exitBlock();
860};
861
862} // namespace LingoDec
863
864#endif // LINGODEC_AST_H
Definition: array.h:52
Definition: ptr.h:159
Definition: str.h:59
Definition: ast.h:792
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: ast.h:848
Definition: ast.h:328
Definition: ast.h:204
Definition: ast.h:145
Definition: ast.h:518
Definition: ast.h:421
Definition: ast.h:458
Definition: ast.h:254
Definition: ast.h:222
Definition: ast.h:242
Definition: ast.h:123
Definition: ast.h:26
Definition: ast.h:451
Definition: ast.h:115
Definition: ast.h:742
Definition: ast.h:173
Definition: ast.h:81
Definition: handler.h:29
Definition: ast.h:159
Definition: ast.h:346
Definition: ast.h:180
Definition: ast.h:97
Definition: ast.h:132
Definition: ast.h:105
Definition: ast.h:298
Definition: ast.h:628
Definition: ast.h:614
Definition: ast.h:784
Definition: ast.h:749
Definition: ast.h:60
Definition: ast.h:192
Definition: ast.h:702
Definition: ast.h:539
Definition: ast.h:558
Definition: ast.h:687
Definition: ast.h:719
Definition: ast.h:439
Definition: ast.h:506
Definition: ast.h:756
Definition: ast.h:365
Definition: ast.h:381
Definition: ast.h:399
Definition: ast.h:492
Definition: ast.h:645
Definition: ast.h:659
Definition: ast.h:282
Definition: ast.h:89
Definition: ast.h:477
Definition: ast.h:577
Definition: ast.h:673
Definition: ast.h:318
Definition: ast.h:773
Definition: lobject.h:332