ScummVM API documentation
lingo-ast.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef DIRECTOR_LINGO_LINGO_AST_H
23 #define DIRECTOR_LINGO_LINGO_AST_H
24 
25 namespace Director {
26 
27 struct Node;
28 struct ScriptNode;
29 struct FactoryNode;
30 struct HandlerNode;
31 struct CmdNode;
32 struct PutIntoNode;
33 struct PutAfterNode;
34 struct PutBeforeNode;
35 struct SetNode;
36 struct GlobalNode;
37 struct PropertyNode;
38 struct InstanceNode;
39 struct IfStmtNode;
40 struct IfElseStmtNode;
41 struct RepeatWhileNode;
42 struct RepeatWithToNode;
43 struct RepeatWithInNode;
44 struct NextRepeatNode;
45 struct ExitRepeatNode;
46 struct ExitNode;
47 struct ReturnNode;
48 struct TellNode;
49 struct WhenNode;
50 struct DeleteNode;
51 struct HiliteNode;
52 struct AssertErrorNode;
53 struct IntNode;
54 struct FloatNode;
55 struct SymbolNode;
56 struct StringNode;
57 struct ListNode;
58 struct PropListNode;
59 struct PropPairNode;
60 struct FuncNode;
61 struct VarNode;
62 struct ParensNode;
63 struct UnaryOpNode;
64 struct BinaryOpNode;
65 struct FrameNode;
66 struct MovieNode;
67 struct IntersectsNode;
68 struct WithinNode;
69 struct TheNode;
70 struct TheOfNode;
71 struct TheNumberOfNode;
72 struct TheLastNode;
73 struct TheDateTimeNode;
74 struct MenuNode;
75 struct MenuItemNode;
76 struct SoundNode;
77 struct SpriteNode;
78 struct ChunkExprNode;
79 
80 typedef Common::Array<Node *> NodeList;
81 typedef Common::Array<Common::String *> IDList;
82 
83 typedef void (*inst)(void);
84 
85 template <typename T>
86 void deleteList(Common::Array<T> *list) {
87  for (uint i = 0; i < list->size(); i++) {
88  delete (*list)[i];
89  }
90  delete list;
91 }
92 
93 enum NodeType {
94  kScriptNode,
95  kFactoryNode,
96  kHandlerNode,
97  kCmdNode,
98  kPutIntoNode,
99  kPutAfterNode,
100  kPutBeforeNode,
101  kSetNode,
102  kGlobalNode,
103  kPropertyNode,
104  kInstanceNode,
105  kIfStmtNode,
106  kIfElseStmtNode,
107  kRepeatWhileNode,
108  kRepeatWithToNode,
109  kRepeatWithInNode,
110  kNextRepeatNode,
111  kExitRepeatNode,
112  kExitNode,
113  kReturnNode,
114  kTellNode,
115  kWhenNode,
116  kDeleteNode,
117  kHiliteNode,
118  kAssertErrorNode,
119  kIntNode,
120  kFloatNode,
121  kSymbolNode,
122  kStringNode,
123  kListNode,
124  kPropListNode,
125  kPropPairNode,
126  kFuncNode,
127  kVarNode,
128  kParensNode,
129  kUnaryOpNode,
130  kBinaryOpNode,
131  kFrameNode,
132  kMovieNode,
133  kIntersectsNode,
134  kWithinNode,
135  kTheNode,
136  kTheOfNode,
137  kTheNumberOfNode,
138  kTheLastNode,
139  kTheDateTimeNode,
140  kMenuNode,
141  kMenuItemNode,
142  kSoundNode,
143  kSpriteNode,
144  kChunkExprNode
145 };
146 
147 enum NumberOfType {
148  kNumberOfChars,
149  kNumberOfWords,
150  kNumberOfItems,
151  kNumberOfLines,
152  kNumberOfMenuItems,
153  kNumberOfMenus,
154  kNumberOfXtras,
155  kNumberOfCastlibs,
156 };
157 
158 /* NodeVisitor */
159 
160 class NodeVisitor {
161 public:
162  NodeVisitor() {}
163  virtual ~NodeVisitor() {}
164 
165  virtual bool visitScriptNode(ScriptNode *node) = 0;
166  virtual bool visitFactoryNode(FactoryNode *node) = 0;
167  virtual bool visitHandlerNode(HandlerNode *node) = 0;
168  virtual bool visitCmdNode(CmdNode *node) = 0;
169  virtual bool visitPutIntoNode(PutIntoNode *node) = 0;
170  virtual bool visitPutAfterNode(PutAfterNode *node) = 0;
171  virtual bool visitPutBeforeNode(PutBeforeNode *node) = 0;
172  virtual bool visitSetNode(SetNode *node) = 0;
173  virtual bool visitGlobalNode(GlobalNode *node) = 0;
174  virtual bool visitPropertyNode(PropertyNode *node) = 0;
175  virtual bool visitInstanceNode(InstanceNode *node) = 0;
176  virtual bool visitIfStmtNode(IfStmtNode *node) = 0;
177  virtual bool visitIfElseStmtNode(IfElseStmtNode *node) = 0;
178  virtual bool visitRepeatWhileNode(RepeatWhileNode *node) = 0;
179  virtual bool visitRepeatWithToNode(RepeatWithToNode *node) = 0;
180  virtual bool visitRepeatWithInNode(RepeatWithInNode *node) = 0;
181  virtual bool visitNextRepeatNode(NextRepeatNode *node) = 0;
182  virtual bool visitExitRepeatNode(ExitRepeatNode *node) = 0;
183  virtual bool visitExitNode(ExitNode *node) = 0;
184  virtual bool visitReturnNode(ReturnNode *node) = 0;
185  virtual bool visitTellNode(TellNode *node) = 0;
186  virtual bool visitWhenNode(WhenNode *node) = 0;
187  virtual bool visitDeleteNode(DeleteNode *node) = 0;
188  virtual bool visitHiliteNode(HiliteNode *node) = 0;
189  virtual bool visitAssertErrorNode(AssertErrorNode *node) = 0;
190  virtual bool visitIntNode(IntNode *node) = 0;
191  virtual bool visitFloatNode(FloatNode *node) = 0;
192  virtual bool visitSymbolNode(SymbolNode *node) = 0;
193  virtual bool visitStringNode(StringNode *node) = 0;
194  virtual bool visitListNode(ListNode *node) = 0;
195  virtual bool visitPropListNode(PropListNode *node) = 0;
196  virtual bool visitPropPairNode(PropPairNode *node) = 0;
197  virtual bool visitFuncNode(FuncNode *node) = 0;
198  virtual bool visitVarNode(VarNode *node) = 0;
199  virtual bool visitParensNode(ParensNode *node) = 0;
200  virtual bool visitUnaryOpNode(UnaryOpNode *node) = 0;
201  virtual bool visitBinaryOpNode(BinaryOpNode *node) = 0;
202  virtual bool visitFrameNode(FrameNode *node) = 0;
203  virtual bool visitMovieNode(MovieNode *node) = 0;
204  virtual bool visitIntersectsNode(IntersectsNode *node) = 0;
205  virtual bool visitWithinNode(WithinNode *node) = 0;
206  virtual bool visitTheNode(TheNode *node) = 0;
207  virtual bool visitTheOfNode(TheOfNode *node) = 0;
208  virtual bool visitTheNumberOfNode(TheNumberOfNode *node) = 0;
209  virtual bool visitTheLastNode(TheLastNode *node) = 0;
210  virtual bool visitTheDateTimeNode(TheDateTimeNode *node) = 0;
211  virtual bool visitMenuNode(MenuNode *node) = 0;
212  virtual bool visitMenuItemNode(MenuItemNode *node) = 0;
213  virtual bool visitSoundNode(SoundNode *node) = 0;
214  virtual bool visitSpriteNode(SpriteNode *node) = 0;
215  virtual bool visitChunkExprNode(ChunkExprNode *node) = 0;
216 };
217 
218 /* Node */
219 
220 struct Node {
221  NodeType type;
222  bool isExpression;
223  bool isStatement;
224  bool isLoop;
225 
226  Node(NodeType t) : type(t), isExpression(false), isStatement(false), isLoop(false) {}
227  virtual ~Node() {}
228  virtual bool accept(NodeVisitor *visitor) = 0;
229 };
230 
231 /* ExprNode */
232 
233 struct ExprNode : Node {
234  ExprNode(NodeType t) : Node(t) {
235  isExpression = true;
236  }
237  virtual ~ExprNode() {}
238 };
239 
240 /* StmtNode */
241 
242 struct StmtNode : Node {
243  StmtNode(NodeType t) : Node(t) {
244  isStatement = true;
245  }
246  virtual ~StmtNode() {}
247 };
248 
249 /* LoopNode */
250 
251 struct LoopNode : StmtNode {
252  Common::Array<uint> nextRepeats;
253  Common::Array<uint> exitRepeats;
254 
255  LoopNode(NodeType t) : StmtNode(t) {
256  isLoop = true;
257  }
258  virtual ~LoopNode() {}
259 };
260 
261 /* ScriptNode */
262 
263 struct ScriptNode : Node {
264  NodeList *children;
265 
266  ScriptNode(NodeList *childrenIn): Node(kScriptNode), children(childrenIn) {}
267  virtual ~ScriptNode() {
268  deleteList(children);
269  }
270  virtual bool accept(NodeVisitor *visitor) {
271  return visitor->visitScriptNode(this);
272  }
273 };
274 
275 /* FactoryNode */
276 
277 struct FactoryNode : Node {
278  Common::String *name;
279  NodeList *methods;
280 
281  FactoryNode(Common::String *nameIn, NodeList *methodsIn)
282  : Node(kFactoryNode), name(nameIn), methods(methodsIn) {}
283  virtual ~FactoryNode() {
284  delete name;
285  deleteList(methods);
286  }
287  virtual bool accept(NodeVisitor *visitor) {
288  return visitor->visitFactoryNode(this);
289  }
290 };
291 
292 /* HandlerNode */
293 
294 struct HandlerNode : Node {
295  Common::String *name;
296  IDList *args;
297  NodeList *stmts;
298 
299  HandlerNode(Common::String *nameIn, IDList *argsIn, NodeList *stmtsIn)
300  : Node(kHandlerNode), name(nameIn), args(argsIn), stmts(stmtsIn) {}
301  virtual ~HandlerNode() {
302  delete name;
303  deleteList(args);
304  deleteList(stmts);
305  }
306  virtual bool accept(NodeVisitor *visitor) {
307  return visitor->visitHandlerNode(this);
308  }
309 };
310 
311 /* CmdNode */
312 
313 struct CmdNode : StmtNode {
314  Common::String *name;
315  NodeList *args;
316  uint lineNumber;
317 
318  CmdNode(Common::String *nameIn, NodeList *argsIn, uint lineNumberIn)
319  : StmtNode(kCmdNode), name(nameIn), args(argsIn), lineNumber(lineNumberIn) {}
320  virtual ~CmdNode() {
321  delete name;
322  deleteList(args);
323  }
324  virtual bool accept(NodeVisitor *visitor) {
325  return visitor->visitCmdNode(this);
326  }
327 };
328 
329 /* PutIntoNode */
330 
332  Node *val;
333  Node *var;
334 
335  PutIntoNode(Node *valIn, Node *varIn)
336  : StmtNode(kPutIntoNode), val(valIn), var(varIn) {}
337  virtual ~PutIntoNode() {
338  delete val;
339  delete var;
340  }
341  virtual bool accept(NodeVisitor *visitor) {
342  return visitor->visitPutIntoNode(this);
343  }
344 };
345 
346 /* PutAfterNode */
347 
349  Node *val;
350  Node *var;
351 
352  PutAfterNode(Node *valIn, Node *varIn)
353  : StmtNode(kPutAfterNode), val(valIn), var(varIn) {}
354  virtual ~PutAfterNode() {
355  delete val;
356  delete var;
357  }
358  virtual bool accept(NodeVisitor *visitor) {
359  return visitor->visitPutAfterNode(this);
360  }
361 };
362 
363 /* PutBeforeNode */
364 
366  Node *val;
367  Node *var;
368 
369  PutBeforeNode(Node *valIn, Node *varIn)
370  : StmtNode(kPutBeforeNode), val(valIn), var(varIn) {}
371  virtual ~PutBeforeNode() {
372  delete val;
373  delete var;
374  }
375  virtual bool accept(NodeVisitor *visitor) {
376  return visitor->visitPutBeforeNode(this);
377  }
378 };
379 
380 /* SetNode */
381 
382 struct SetNode : StmtNode {
383  Node *var;
384  Node *val;
385 
386  SetNode(Node *varIn, Node *valIn)
387  : StmtNode(kSetNode), var(varIn), val(valIn) {}
388  virtual ~SetNode() {
389  delete var;
390  delete val;
391  }
392  virtual bool accept(NodeVisitor *visitor) {
393  return visitor->visitSetNode(this);
394  }
395 };
396 
397 /* GlobalNode */
398 
400  IDList *names;
401 
402  GlobalNode(IDList *namesIn) : StmtNode(kGlobalNode), names(namesIn) {}
403  virtual ~GlobalNode() {
404  deleteList(names);
405  }
406  virtual bool accept(NodeVisitor *visitor) {
407  return visitor->visitGlobalNode(this);
408  }
409 };
410 
411 /* PropertyNode */
412 
414  IDList *names;
415 
416  PropertyNode(IDList *namesIn) : StmtNode(kPropertyNode), names(namesIn) {}
417  virtual ~PropertyNode() {
418  deleteList(names);
419  }
420  virtual bool accept(NodeVisitor *visitor) {
421  return visitor->visitPropertyNode(this);
422  }
423 };
424 
425 /* InstanceNode */
426 
428  IDList *names;
429 
430  InstanceNode(IDList *namesIn) : StmtNode(kInstanceNode), names(namesIn) {}
431  virtual ~InstanceNode() {
432  deleteList(names);
433  }
434  virtual bool accept(NodeVisitor *visitor) {
435  return visitor->visitInstanceNode(this);
436  }
437 };
438 
439 /* IfStmtNode */
440 
442  Node *cond;
443  NodeList *stmts;
444 
445  IfStmtNode(Node *condIn, NodeList *stmtsIn)
446  : StmtNode(kIfStmtNode), cond(condIn), stmts(stmtsIn) {}
447  virtual ~IfStmtNode() {
448  delete cond;
449  deleteList(stmts);
450  }
451  virtual bool accept(NodeVisitor *visitor) {
452  return visitor->visitIfStmtNode(this);
453  }
454 };
455 
456 /* IfElseStmtNode */
457 
459  Node *cond;
460  NodeList *stmts1;
461  NodeList *stmts2;
462 
463  IfElseStmtNode(Node *condIn, NodeList *stmts1In, NodeList *stmts2In)
464  : StmtNode(kIfElseStmtNode), cond(condIn), stmts1(stmts1In), stmts2(stmts2In) {}
465  virtual ~IfElseStmtNode() {
466  delete cond;
467  deleteList(stmts1);
468  deleteList(stmts2);
469  }
470  virtual bool accept(NodeVisitor *visitor) {
471  return visitor->visitIfElseStmtNode(this);
472  }
473 };
474 
475 /* RepeatWhileNode */
476 
478  Node *cond;
479  NodeList *stmts;
480 
481  RepeatWhileNode(Node *condIn, NodeList *stmtsIn)
482  : LoopNode(kRepeatWhileNode), cond(condIn), stmts(stmtsIn) {}
483  virtual ~RepeatWhileNode() {
484  delete cond;
485  deleteList(stmts);
486  }
487  virtual bool accept(NodeVisitor *visitor) {
488  return visitor->visitRepeatWhileNode(this);
489  }
490 };
491 
492 /* RepeatWithToNode */
493 
495  Common::String *var;
496  Node *start;
497  bool down;
498  Node *end;
499  NodeList *stmts;
500 
501  RepeatWithToNode(Common::String *varIn, Node *startIn, bool downIn, Node *endIn, NodeList *stmtsIn)
502  : LoopNode(kRepeatWithToNode), var(varIn), start(startIn), down(downIn), end(endIn), stmts(stmtsIn) {}
503  virtual ~RepeatWithToNode() {
504  delete var;
505  delete start;
506  delete end;
507  deleteList(stmts);
508  }
509  virtual bool accept(NodeVisitor *visitor) {
510  return visitor->visitRepeatWithToNode(this);
511  }
512 };
513 
514 /* RepeatWithInNode */
515 
517  Common::String *var;
518  Node *list;
519  NodeList *stmts;
520 
521  RepeatWithInNode(Common::String *varIn, Node *listIn, NodeList *stmtsIn)
522  : LoopNode(kRepeatWithInNode), var(varIn), list(listIn), stmts(stmtsIn) {}
523  virtual ~RepeatWithInNode() {
524  delete var;
525  delete list;
526  deleteList(stmts);
527  }
528  virtual bool accept(NodeVisitor *visitor) {
529  return visitor->visitRepeatWithInNode(this);
530  }
531 };
532 
533 /* NextRepeatNode */
534 
536  NextRepeatNode() : StmtNode(kNextRepeatNode) {}
537  virtual ~NextRepeatNode() {}
538  virtual bool accept(NodeVisitor *visitor) {
539  return visitor->visitNextRepeatNode(this);
540  }
541 };
542 
543 /* ExitRepeatNode */
544 
546  ExitRepeatNode() : StmtNode(kExitRepeatNode) {}
547  virtual ~ExitRepeatNode() {}
548  virtual bool accept(NodeVisitor *visitor) {
549  return visitor->visitExitRepeatNode(this);
550  }
551 };
552 
553 /* ExitNode */
554 
555 struct ExitNode : StmtNode {
556  ExitNode() : StmtNode(kExitNode) {}
557  virtual ~ExitNode() {}
558  virtual bool accept(NodeVisitor *visitor) {
559  return visitor->visitExitNode(this);
560  }
561 };
562 
563 /* ReturnNode */
564 
566  Node *expr;
567  ReturnNode(Node *exprIn) : StmtNode(kReturnNode), expr(exprIn) {}
568  virtual ~ReturnNode() {
569  if (expr)
570  delete expr;
571  }
572  virtual bool accept(NodeVisitor *visitor) {
573  return visitor->visitReturnNode(this);
574  }
575 };
576 
577 
578 /* TellNode */
579 
580 struct TellNode : StmtNode {
581  Node *target;
582  NodeList *stmts;
583 
584  TellNode(Node *targetIn, NodeList *stmtsIn)
585  : StmtNode(kTellNode), target(targetIn), stmts(stmtsIn) {}
586  virtual ~TellNode() {
587  delete target;
588  deleteList(stmts);
589  }
590  virtual bool accept(NodeVisitor *visitor) {
591  return visitor->visitTellNode(this);
592  }
593 };
594 
595 /* WhenNode */
596 
597 struct WhenNode : StmtNode {
598  Common::String *event;
599  Common::String *code;
600 
601  WhenNode(Common::String *eventIn, Common::String *codeIn)
602  : StmtNode(kWhenNode), event(eventIn), code(codeIn) {}
603  virtual ~WhenNode() {
604  delete event;
605  delete code;
606  }
607  virtual bool accept(NodeVisitor *visitor) {
608  return visitor->visitWhenNode(this);
609  }
610 };
611 
612 /* DeleteNode */
613 
615  Node *chunk;
616 
617  DeleteNode(Node *chunkIn) : StmtNode(kDeleteNode), chunk(chunkIn) {}
618  virtual ~DeleteNode() {
619  delete chunk;
620  }
621  virtual bool accept(NodeVisitor *visitor) {
622  return visitor->visitDeleteNode(this);
623  }
624 };
625 
626 /* HiliteNode */
627 
629  Node *chunk;
630 
631  HiliteNode(Node *chunkIn) : StmtNode(kHiliteNode), chunk(chunkIn) {}
632  virtual ~HiliteNode() {
633  delete chunk;
634  }
635  virtual bool accept(NodeVisitor *visitor) {
636  return visitor->visitHiliteNode(this);
637  }
638 };
639 
640 /* AssertErrorNode */
641 
643  Node *stmt;
644 
645  AssertErrorNode(Node *stmtIn) : StmtNode(kAssertErrorNode), stmt(stmtIn) {}
646  virtual ~AssertErrorNode() {
647  delete stmt;
648  }
649  virtual bool accept(NodeVisitor *visitor) {
650  return visitor->visitAssertErrorNode(this);
651  }
652 };
653 
654 /* IntNode */
655 
656 struct IntNode : ExprNode {
657  int val;
658 
659  IntNode(int valIn) : ExprNode(kIntNode), val(valIn) {}
660  virtual ~IntNode() {}
661  virtual bool accept(NodeVisitor *visitor) {
662  return visitor->visitIntNode(this);
663  }
664 };
665 
666 /* FloatNode */
667 
668 struct FloatNode : ExprNode {
669  double val;
670 
671  FloatNode(double valIn) : ExprNode(kFloatNode), val(valIn) {}
672  virtual ~FloatNode() {}
673  virtual bool accept(NodeVisitor *visitor) {
674  return visitor->visitFloatNode(this);
675  }
676 };
677 
678 /* SymbolNode */
679 
681  Common::String *val;
682 
683  SymbolNode(Common::String *valIn) : ExprNode(kSymbolNode), val(valIn) {}
684  virtual ~SymbolNode() {
685  delete val;
686  }
687  virtual bool accept(NodeVisitor *visitor) {
688  return visitor->visitSymbolNode(this);
689  }
690 };
691 
692 /* StringNode */
693 
695  Common::String *val;
696 
697  StringNode(Common::String *valIn) : ExprNode(kStringNode), val(valIn) {}
698  virtual ~StringNode() {
699  delete val;
700  }
701  virtual bool accept(NodeVisitor *visitor) {
702  return visitor->visitStringNode(this);
703  }
704 };
705 
706 /* ListNode */
707 
708 struct ListNode : ExprNode {
709  NodeList *items;
710 
711  ListNode(NodeList *itemsIn) : ExprNode(kListNode), items(itemsIn) {}
712  virtual ~ListNode() {
713  deleteList(items);
714  }
715  virtual bool accept(NodeVisitor *visitor) {
716  return visitor->visitListNode(this);
717  }
718 };
719 
720 /* PropListNode */
721 
723  NodeList *items;
724 
725  PropListNode(NodeList *itemsIn) : ExprNode(kListNode), items(itemsIn) {}
726  virtual ~PropListNode() {
727  deleteList(items);
728  }
729  virtual bool accept(NodeVisitor *visitor) {
730  return visitor->visitPropListNode(this);
731  }
732 };
733 
734 /* PropPairNode */
735 
737  Node *key;
738  Node *val;
739 
740  PropPairNode(Node *keyIn, Node *valIn)
741  : ExprNode(kPropPairNode), key(keyIn), val(valIn) {}
742  virtual ~PropPairNode() {
743  delete key;
744  delete val;
745  }
746  virtual bool accept(NodeVisitor *visitor) {
747  return visitor->visitPropPairNode(this);
748  }
749 };
750 
751 /* FuncNode */
752 
753 struct FuncNode : ExprNode {
754  Common::String *name;
755  NodeList *args;
756 
757  FuncNode(Common::String *nameIn, NodeList *argsIn)
758  : ExprNode(kFuncNode), name(nameIn), args(argsIn) {}
759  virtual ~FuncNode() {
760  delete name;
761  deleteList(args);
762  }
763  virtual bool accept(NodeVisitor *visitor) {
764  return visitor->visitFuncNode(this);
765  }
766 };
767 
768 /* VarNode */
769 
770 struct VarNode : ExprNode {
771  Common::String *name;
772 
773  VarNode(Common::String *nameIn) : ExprNode(kVarNode), name(nameIn) {}
774  virtual ~VarNode() {
775  delete name;
776  }
777  virtual bool accept(NodeVisitor *visitor) {
778  return visitor->visitVarNode(this);
779  }
780 };
781 
782 /* ParensNode */
783 
785  Node *expr;
786 
787  ParensNode(Node *exprIn) : ExprNode(kParensNode), expr(exprIn) {}
788  virtual ~ParensNode() {
789  delete expr;
790  }
791  virtual bool accept(NodeVisitor *visitor) {
792  return visitor->visitParensNode(this);
793  }
794 };
795 
796 /* UnaryOpNode */
797 
799  inst op;
800  Node *arg;
801 
802  UnaryOpNode(inst opIn, Node *argIn) : ExprNode(kUnaryOpNode), op(opIn), arg(argIn) {}
803  virtual ~UnaryOpNode() {
804  delete arg;
805  }
806  virtual bool accept(NodeVisitor *visitor) {
807  return visitor->visitUnaryOpNode(this);
808  }
809 };
810 
811 /* BinaryOpNode */
812 
814  inst op;
815  Node *a;
816  Node *b;
817 
818  BinaryOpNode(inst opIn, Node *aIn, Node *bIn) : ExprNode(kBinaryOpNode), op(opIn), a(aIn), b(bIn) {}
819  virtual ~BinaryOpNode() {
820  delete a;
821  delete b;
822  }
823  virtual bool accept(NodeVisitor *visitor) {
824  return visitor->visitBinaryOpNode(this);
825  }
826 };
827 
828 /* FrameNode */
829 
830 struct FrameNode : ExprNode {
831  Node *arg;
832 
833  FrameNode(Node *argIn) : ExprNode(kFrameNode), arg(argIn) {}
834  virtual ~FrameNode() {
835  delete arg;
836  }
837  virtual bool accept(NodeVisitor *visitor) {
838  return visitor->visitFrameNode(this);
839  }
840 };
841 
842 /* MovieNode */
843 
844 struct MovieNode : ExprNode {
845  Node *arg;
846 
847  MovieNode(Node *argIn) : ExprNode(kMovieNode), arg(argIn) {}
848  virtual ~MovieNode() {
849  delete arg;
850  }
851  virtual bool accept(NodeVisitor *visitor) {
852  return visitor->visitMovieNode(this);
853  }
854 };
855 
856 /* IntersectsNode */
857 
859  Node *sprite1;
860  Node *sprite2;
861 
862  IntersectsNode(Node *sprite1In, Node *sprite2In)
863  : ExprNode(kIntersectsNode), sprite1(sprite1In), sprite2(sprite2In) {}
864  virtual ~IntersectsNode() {
865  delete sprite1;
866  delete sprite2;
867  }
868  virtual bool accept(NodeVisitor *visitor) {
869  return visitor->visitIntersectsNode(this);
870  }
871 };
872 
873 /* WithinNode */
874 
876  Node *sprite1;
877  Node *sprite2;
878 
879  WithinNode(Node *sprite1In, Node *sprite2In)
880  : ExprNode(kWithinNode), sprite1(sprite1In), sprite2(sprite2In) {}
881  virtual ~WithinNode() {
882  delete sprite1;
883  delete sprite2;
884  }
885  virtual bool accept(NodeVisitor *visitor) {
886  return visitor->visitWithinNode(this);
887  }
888 };
889 
890 /* TheNode */
891 
892 struct TheNode : ExprNode {
893  Common::String *prop;
894 
895  TheNode(Common::String *propIn) : ExprNode(kTheNode), prop(propIn) {}
896  virtual ~TheNode() {
897  delete prop;
898  }
899  virtual bool accept(NodeVisitor *visitor) {
900  return visitor->visitTheNode(this);
901  }
902 };
903 
904 /* TheOfNode */
905 
906 struct TheOfNode : ExprNode {
907  Common::String *prop;
908  Node *obj;
909 
910  TheOfNode(Common::String *propIn, Node *objIn)
911  : ExprNode(kTheOfNode), prop(propIn), obj(objIn) {}
912  virtual ~TheOfNode() {
913  delete prop;
914  delete obj;
915  }
916  virtual bool accept(NodeVisitor *visitor) {
917  return visitor->visitTheOfNode(this);
918  }
919 };
920 
921 /* TheNumberOfNode */
922 
924  NumberOfType type;
925  Node *arg;
926 
927  TheNumberOfNode(NumberOfType typeIn, Node *argIn)
928  : ExprNode(kTheNumberOfNode), type(typeIn), arg(argIn) {}
929  virtual ~TheNumberOfNode() {
930  delete arg;
931  }
932  virtual bool accept(NodeVisitor *visitor) {
933  return visitor->visitTheNumberOfNode(this);
934  }
935 };
936 
937 /* TheLastNode */
938 
940  ChunkType type;
941  Node *arg;
942 
943  TheLastNode(ChunkType typeIn, Node *argIn)
944  : ExprNode(kTheLastNode), type(typeIn), arg(argIn) {}
945  virtual ~TheLastNode() {
946  delete arg;
947  }
948  virtual bool accept(NodeVisitor *visitor) {
949  return visitor->visitTheLastNode(this);
950  }
951 };
952 
953 /* TheDateTimeNode */
954 
956  int field;
957  int entity;
958 
959  TheDateTimeNode(int fieldIn, int entityIn)
960  : ExprNode(kTheDateTimeNode), field(fieldIn), entity(entityIn) {}
961  virtual ~TheDateTimeNode() {}
962  virtual bool accept(NodeVisitor *visitor) {
963  return visitor->visitTheDateTimeNode(this);
964  }
965 };
966 
967 /* MenuNode */
968 
969 struct MenuNode : ExprNode {
970  Node *arg;
971 
972  MenuNode(Node *argIn) : ExprNode(kMenuNode), arg(argIn) {}
973  virtual ~MenuNode() {
974  delete arg;
975  }
976  virtual bool accept(NodeVisitor *visitor) {
977  return visitor->visitMenuNode(this);
978  }
979 };
980 
981 /* MenuItemNode */
982 
984  Node *arg1;
985  Node *arg2;
986 
987  MenuItemNode(Node *arg1In, Node *arg2In)
988  : ExprNode(kMenuItemNode), arg1(arg1In), arg2(arg2In) {}
989  virtual ~MenuItemNode() {
990  delete arg1;
991  delete arg2;
992  }
993  virtual bool accept(NodeVisitor *visitor) {
994  return visitor->visitMenuItemNode(this);
995  }
996 };
997 
998 /* SoundNode */
999 
1001  Node *arg;
1002 
1003  SoundNode(Node *argIn) : ExprNode(kSoundNode), arg(argIn) {}
1004  virtual ~SoundNode() {
1005  delete arg;
1006  }
1007  virtual bool accept(NodeVisitor *visitor) {
1008  return visitor->visitSoundNode(this);
1009  }
1010 };
1011 
1012 /* SpriteNode */
1013 
1015  Node *arg;
1016 
1017  SpriteNode(Node *argIn) : ExprNode(kSpriteNode), arg(argIn) {}
1018  virtual ~SpriteNode() {
1019  delete arg;
1020  }
1021  virtual bool accept(NodeVisitor *visitor) {
1022  return visitor->visitSpriteNode(this);
1023  }
1024 };
1025 
1026 /* ChunkExprNode */
1027 
1029  ChunkType type;
1030  Node *start;
1031  Node *end;
1032  Node *src;
1033 
1034  ChunkExprNode(ChunkType typeIn, Node *startIn, Node *endIn, Node *srcIn)
1035  : ExprNode(kChunkExprNode), type(typeIn), start(startIn), end(endIn), src(srcIn) {}
1036  virtual ~ChunkExprNode() {
1037  delete start;
1038  delete end;
1039  delete src;
1040  }
1041  virtual bool accept(NodeVisitor *visitor) {
1042  return visitor->visitChunkExprNode(this);
1043  }
1044 };
1045 
1046 } // End of namespace Director
1047 
1048 #endif
Definition: lingo-ast.h:753
Definition: lingo-ast.h:798
Definition: lingo-ast.h:708
Definition: str.h:59
Definition: lingo-ast.h:813
Definition: lingo-ast.h:565
Definition: lingo-ast.h:516
Definition: lingo-ast.h:441
Definition: lingo-ast.h:458
Definition: lingo-ast.h:736
Definition: lingo-ast.h:939
Definition: array.h:52
Definition: lingo-ast.h:923
Definition: lingo-ast.h:784
Definition: lingo-ast.h:1014
Definition: lingo-ast.h:313
Definition: lingo-ast.h:160
Definition: lingo-ast.h:969
Definition: lingo-ast.h:294
Definition: archive.h:35
Definition: lingo-ast.h:1000
Definition: lingo-ast.h:642
Definition: lingo-ast.h:722
Definition: lingo-ast.h:277
Definition: lingo-ast.h:545
Definition: lingo-ast.h:331
Definition: lingo-ast.h:892
Definition: lingo-ast.h:680
Definition: lingo-ast.h:858
Definition: lingo-ast.h:399
Definition: lingo-ast.h:233
Definition: lingo-ast.h:668
Definition: lingo-ast.h:694
Definition: lingo-ast.h:348
Definition: lingo-ast.h:1028
Definition: lingo-ast.h:494
Definition: lingo-ast.h:263
Definition: lingo-ast.h:830
size_type size() const
Definition: array.h:275
Definition: lingo-ast.h:580
Definition: lingo-ast.h:614
Definition: lingo-ast.h:770
Definition: lingo-ast.h:242
Definition: lingo-ast.h:555
Definition: lingo-ast.h:955
Definition: lingo-ast.h:220
Definition: lingo-ast.h:875
Definition: lingo-ast.h:983
Definition: lingo-ast.h:906
Definition: lingo-ast.h:477
Definition: lingo-ast.h:844
Definition: lingo-ast.h:365
Definition: lingo-ast.h:656
Definition: lobject.h:332
Definition: lingo-ast.h:251
Definition: lingo-ast.h:628
Definition: lingo-ast.h:535
Definition: lingo-ast.h:382
Definition: lingo-ast.h:427
Definition: lingo-ast.h:597
Definition: lingo-ast.h:413