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  uint32 startOffset;
226  uint32 endOffset;
227 
228  Node(NodeType t) : type(t), isExpression(false), isStatement(false), isLoop(false), startOffset(0), endOffset(0) {}
229  virtual ~Node() {}
230  virtual bool accept(NodeVisitor *visitor) = 0;
231 };
232 
233 /* ExprNode */
234 
235 struct ExprNode : Node {
236  ExprNode(NodeType t) : Node(t) {
237  isExpression = true;
238  }
239  virtual ~ExprNode() {}
240 };
241 
242 /* StmtNode */
243 
244 struct StmtNode : Node {
245  StmtNode(NodeType t) : Node(t) {
246  isStatement = true;
247  }
248  virtual ~StmtNode() {}
249 };
250 
251 /* LoopNode */
252 
253 struct LoopNode : StmtNode {
254  Common::Array<uint> nextRepeats;
255  Common::Array<uint> exitRepeats;
256 
257  LoopNode(NodeType t) : StmtNode(t) {
258  isLoop = true;
259  }
260  virtual ~LoopNode() {}
261 };
262 
263 /* ScriptNode */
264 
265 struct ScriptNode : Node {
266  NodeList *children;
267 
268  ScriptNode(NodeList *childrenIn): Node(kScriptNode), children(childrenIn) {}
269  virtual ~ScriptNode() {
270  deleteList(children);
271  }
272  virtual bool accept(NodeVisitor *visitor) {
273  return visitor->visitScriptNode(this);
274  }
275 };
276 
277 /* FactoryNode */
278 
279 struct FactoryNode : Node {
280  Common::String *name;
281  NodeList *methods;
282 
283  FactoryNode(Common::String *nameIn, NodeList *methodsIn)
284  : Node(kFactoryNode), name(nameIn), methods(methodsIn) {}
285  virtual ~FactoryNode() {
286  delete name;
287  deleteList(methods);
288  }
289  virtual bool accept(NodeVisitor *visitor) {
290  return visitor->visitFactoryNode(this);
291  }
292 };
293 
294 /* HandlerNode */
295 
296 struct HandlerNode : Node {
297  Common::String *name;
298  IDList *args;
299  NodeList *stmts;
300 
301  HandlerNode(Common::String *nameIn, IDList *argsIn, NodeList *stmtsIn)
302  : Node(kHandlerNode), name(nameIn), args(argsIn), stmts(stmtsIn) {}
303  virtual ~HandlerNode() {
304  delete name;
305  deleteList(args);
306  deleteList(stmts);
307  }
308  virtual bool accept(NodeVisitor *visitor) {
309  return visitor->visitHandlerNode(this);
310  }
311 };
312 
313 /* CmdNode */
314 
315 struct CmdNode : StmtNode {
316  Common::String *name;
317  NodeList *args;
318  uint lineNumber;
319 
320  CmdNode(Common::String *nameIn, NodeList *argsIn, uint lineNumberIn)
321  : StmtNode(kCmdNode), name(nameIn), args(argsIn), lineNumber(lineNumberIn) {}
322  virtual ~CmdNode() {
323  delete name;
324  deleteList(args);
325  }
326  virtual bool accept(NodeVisitor *visitor) {
327  return visitor->visitCmdNode(this);
328  }
329 };
330 
331 /* PutIntoNode */
332 
334  Node *val;
335  Node *var;
336 
337  PutIntoNode(Node *valIn, Node *varIn)
338  : StmtNode(kPutIntoNode), val(valIn), var(varIn) {}
339  virtual ~PutIntoNode() {
340  delete val;
341  delete var;
342  }
343  virtual bool accept(NodeVisitor *visitor) {
344  return visitor->visitPutIntoNode(this);
345  }
346 };
347 
348 /* PutAfterNode */
349 
351  Node *val;
352  Node *var;
353 
354  PutAfterNode(Node *valIn, Node *varIn)
355  : StmtNode(kPutAfterNode), val(valIn), var(varIn) {}
356  virtual ~PutAfterNode() {
357  delete val;
358  delete var;
359  }
360  virtual bool accept(NodeVisitor *visitor) {
361  return visitor->visitPutAfterNode(this);
362  }
363 };
364 
365 /* PutBeforeNode */
366 
368  Node *val;
369  Node *var;
370 
371  PutBeforeNode(Node *valIn, Node *varIn)
372  : StmtNode(kPutBeforeNode), val(valIn), var(varIn) {}
373  virtual ~PutBeforeNode() {
374  delete val;
375  delete var;
376  }
377  virtual bool accept(NodeVisitor *visitor) {
378  return visitor->visitPutBeforeNode(this);
379  }
380 };
381 
382 /* SetNode */
383 
384 struct SetNode : StmtNode {
385  Node *var;
386  Node *val;
387 
388  SetNode(Node *varIn, Node *valIn)
389  : StmtNode(kSetNode), var(varIn), val(valIn) {}
390  virtual ~SetNode() {
391  delete var;
392  delete val;
393  }
394  virtual bool accept(NodeVisitor *visitor) {
395  return visitor->visitSetNode(this);
396  }
397 };
398 
399 /* GlobalNode */
400 
402  IDList *names;
403 
404  GlobalNode(IDList *namesIn) : StmtNode(kGlobalNode), names(namesIn) {}
405  virtual ~GlobalNode() {
406  deleteList(names);
407  }
408  virtual bool accept(NodeVisitor *visitor) {
409  return visitor->visitGlobalNode(this);
410  }
411 };
412 
413 /* PropertyNode */
414 
416  IDList *names;
417 
418  PropertyNode(IDList *namesIn) : StmtNode(kPropertyNode), names(namesIn) {}
419  virtual ~PropertyNode() {
420  deleteList(names);
421  }
422  virtual bool accept(NodeVisitor *visitor) {
423  return visitor->visitPropertyNode(this);
424  }
425 };
426 
427 /* InstanceNode */
428 
430  IDList *names;
431 
432  InstanceNode(IDList *namesIn) : StmtNode(kInstanceNode), names(namesIn) {}
433  virtual ~InstanceNode() {
434  deleteList(names);
435  }
436  virtual bool accept(NodeVisitor *visitor) {
437  return visitor->visitInstanceNode(this);
438  }
439 };
440 
441 /* IfStmtNode */
442 
444  Node *cond;
445  NodeList *stmts;
446 
447  IfStmtNode(Node *condIn, NodeList *stmtsIn)
448  : StmtNode(kIfStmtNode), cond(condIn), stmts(stmtsIn) {}
449  virtual ~IfStmtNode() {
450  delete cond;
451  deleteList(stmts);
452  }
453  virtual bool accept(NodeVisitor *visitor) {
454  return visitor->visitIfStmtNode(this);
455  }
456 };
457 
458 /* IfElseStmtNode */
459 
461  Node *cond;
462  NodeList *stmts1;
463  NodeList *stmts2;
464 
465  IfElseStmtNode(Node *condIn, NodeList *stmts1In, NodeList *stmts2In)
466  : StmtNode(kIfElseStmtNode), cond(condIn), stmts1(stmts1In), stmts2(stmts2In) {}
467  virtual ~IfElseStmtNode() {
468  delete cond;
469  deleteList(stmts1);
470  deleteList(stmts2);
471  }
472  virtual bool accept(NodeVisitor *visitor) {
473  return visitor->visitIfElseStmtNode(this);
474  }
475 };
476 
477 /* RepeatWhileNode */
478 
480  Node *cond;
481  NodeList *stmts;
482 
483  RepeatWhileNode(Node *condIn, NodeList *stmtsIn)
484  : LoopNode(kRepeatWhileNode), cond(condIn), stmts(stmtsIn) {}
485  virtual ~RepeatWhileNode() {
486  delete cond;
487  deleteList(stmts);
488  }
489  virtual bool accept(NodeVisitor *visitor) {
490  return visitor->visitRepeatWhileNode(this);
491  }
492 };
493 
494 /* RepeatWithToNode */
495 
497  Common::String *var;
498  Node *start;
499  bool down;
500  Node *end;
501  NodeList *stmts;
502 
503  RepeatWithToNode(Common::String *varIn, Node *startIn, bool downIn, Node *endIn, NodeList *stmtsIn)
504  : LoopNode(kRepeatWithToNode), var(varIn), start(startIn), down(downIn), end(endIn), stmts(stmtsIn) {}
505  virtual ~RepeatWithToNode() {
506  delete var;
507  delete start;
508  delete end;
509  deleteList(stmts);
510  }
511  virtual bool accept(NodeVisitor *visitor) {
512  return visitor->visitRepeatWithToNode(this);
513  }
514 };
515 
516 /* RepeatWithInNode */
517 
519  Common::String *var;
520  Node *list;
521  NodeList *stmts;
522 
523  RepeatWithInNode(Common::String *varIn, Node *listIn, NodeList *stmtsIn)
524  : LoopNode(kRepeatWithInNode), var(varIn), list(listIn), stmts(stmtsIn) {}
525  virtual ~RepeatWithInNode() {
526  delete var;
527  delete list;
528  deleteList(stmts);
529  }
530  virtual bool accept(NodeVisitor *visitor) {
531  return visitor->visitRepeatWithInNode(this);
532  }
533 };
534 
535 /* NextRepeatNode */
536 
538  NextRepeatNode() : StmtNode(kNextRepeatNode) {}
539  virtual ~NextRepeatNode() {}
540  virtual bool accept(NodeVisitor *visitor) {
541  return visitor->visitNextRepeatNode(this);
542  }
543 };
544 
545 /* ExitRepeatNode */
546 
548  ExitRepeatNode() : StmtNode(kExitRepeatNode) {}
549  virtual ~ExitRepeatNode() {}
550  virtual bool accept(NodeVisitor *visitor) {
551  return visitor->visitExitRepeatNode(this);
552  }
553 };
554 
555 /* ExitNode */
556 
557 struct ExitNode : StmtNode {
558  ExitNode() : StmtNode(kExitNode) {}
559  virtual ~ExitNode() {}
560  virtual bool accept(NodeVisitor *visitor) {
561  return visitor->visitExitNode(this);
562  }
563 };
564 
565 /* ReturnNode */
566 
568  Node *expr;
569  ReturnNode(Node *exprIn) : StmtNode(kReturnNode), expr(exprIn) {}
570  virtual ~ReturnNode() {
571  if (expr)
572  delete expr;
573  }
574  virtual bool accept(NodeVisitor *visitor) {
575  return visitor->visitReturnNode(this);
576  }
577 };
578 
579 
580 /* TellNode */
581 
582 struct TellNode : StmtNode {
583  Node *target;
584  NodeList *stmts;
585 
586  TellNode(Node *targetIn, NodeList *stmtsIn)
587  : StmtNode(kTellNode), target(targetIn), stmts(stmtsIn) {}
588  virtual ~TellNode() {
589  delete target;
590  deleteList(stmts);
591  }
592  virtual bool accept(NodeVisitor *visitor) {
593  return visitor->visitTellNode(this);
594  }
595 };
596 
597 /* WhenNode */
598 
599 struct WhenNode : StmtNode {
600  Common::String *event;
601  Common::String *code;
602 
603  WhenNode(Common::String *eventIn, Common::String *codeIn)
604  : StmtNode(kWhenNode), event(eventIn), code(codeIn) {}
605  virtual ~WhenNode() {
606  delete event;
607  delete code;
608  }
609  virtual bool accept(NodeVisitor *visitor) {
610  return visitor->visitWhenNode(this);
611  }
612 };
613 
614 /* DeleteNode */
615 
617  Node *chunk;
618 
619  DeleteNode(Node *chunkIn) : StmtNode(kDeleteNode), chunk(chunkIn) {}
620  virtual ~DeleteNode() {
621  delete chunk;
622  }
623  virtual bool accept(NodeVisitor *visitor) {
624  return visitor->visitDeleteNode(this);
625  }
626 };
627 
628 /* HiliteNode */
629 
631  Node *chunk;
632 
633  HiliteNode(Node *chunkIn) : StmtNode(kHiliteNode), chunk(chunkIn) {}
634  virtual ~HiliteNode() {
635  delete chunk;
636  }
637  virtual bool accept(NodeVisitor *visitor) {
638  return visitor->visitHiliteNode(this);
639  }
640 };
641 
642 /* AssertErrorNode */
643 
645  Node *stmt;
646 
647  AssertErrorNode(Node *stmtIn) : StmtNode(kAssertErrorNode), stmt(stmtIn) {}
648  virtual ~AssertErrorNode() {
649  delete stmt;
650  }
651  virtual bool accept(NodeVisitor *visitor) {
652  return visitor->visitAssertErrorNode(this);
653  }
654 };
655 
656 /* IntNode */
657 
658 struct IntNode : ExprNode {
659  int val;
660 
661  IntNode(int valIn) : ExprNode(kIntNode), val(valIn) {}
662  virtual ~IntNode() {}
663  virtual bool accept(NodeVisitor *visitor) {
664  return visitor->visitIntNode(this);
665  }
666 };
667 
668 /* FloatNode */
669 
670 struct FloatNode : ExprNode {
671  double val;
672 
673  FloatNode(double valIn) : ExprNode(kFloatNode), val(valIn) {}
674  virtual ~FloatNode() {}
675  virtual bool accept(NodeVisitor *visitor) {
676  return visitor->visitFloatNode(this);
677  }
678 };
679 
680 /* SymbolNode */
681 
683  Common::String *val;
684 
685  SymbolNode(Common::String *valIn) : ExprNode(kSymbolNode), val(valIn) {}
686  virtual ~SymbolNode() {
687  delete val;
688  }
689  virtual bool accept(NodeVisitor *visitor) {
690  return visitor->visitSymbolNode(this);
691  }
692 };
693 
694 /* StringNode */
695 
697  Common::String *val;
698 
699  StringNode(Common::String *valIn) : ExprNode(kStringNode), val(valIn) {}
700  virtual ~StringNode() {
701  delete val;
702  }
703  virtual bool accept(NodeVisitor *visitor) {
704  return visitor->visitStringNode(this);
705  }
706 };
707 
708 /* ListNode */
709 
710 struct ListNode : ExprNode {
711  NodeList *items;
712 
713  ListNode(NodeList *itemsIn) : ExprNode(kListNode), items(itemsIn) {}
714  virtual ~ListNode() {
715  deleteList(items);
716  }
717  virtual bool accept(NodeVisitor *visitor) {
718  return visitor->visitListNode(this);
719  }
720 };
721 
722 /* PropListNode */
723 
725  NodeList *items;
726 
727  PropListNode(NodeList *itemsIn) : ExprNode(kListNode), items(itemsIn) {}
728  virtual ~PropListNode() {
729  deleteList(items);
730  }
731  virtual bool accept(NodeVisitor *visitor) {
732  return visitor->visitPropListNode(this);
733  }
734 };
735 
736 /* PropPairNode */
737 
739  Node *key;
740  Node *val;
741 
742  PropPairNode(Node *keyIn, Node *valIn)
743  : ExprNode(kPropPairNode), key(keyIn), val(valIn) {}
744  virtual ~PropPairNode() {
745  delete key;
746  delete val;
747  }
748  virtual bool accept(NodeVisitor *visitor) {
749  return visitor->visitPropPairNode(this);
750  }
751 };
752 
753 /* FuncNode */
754 
755 struct FuncNode : ExprNode {
756  Common::String *name;
757  NodeList *args;
758 
759  FuncNode(Common::String *nameIn, NodeList *argsIn)
760  : ExprNode(kFuncNode), name(nameIn), args(argsIn) {}
761  virtual ~FuncNode() {
762  delete name;
763  deleteList(args);
764  }
765  virtual bool accept(NodeVisitor *visitor) {
766  return visitor->visitFuncNode(this);
767  }
768 };
769 
770 /* VarNode */
771 
772 struct VarNode : ExprNode {
773  Common::String *name;
774 
775  VarNode(Common::String *nameIn) : ExprNode(kVarNode), name(nameIn) {}
776  virtual ~VarNode() {
777  delete name;
778  }
779  virtual bool accept(NodeVisitor *visitor) {
780  return visitor->visitVarNode(this);
781  }
782 };
783 
784 /* ParensNode */
785 
787  Node *expr;
788 
789  ParensNode(Node *exprIn) : ExprNode(kParensNode), expr(exprIn) {}
790  virtual ~ParensNode() {
791  delete expr;
792  }
793  virtual bool accept(NodeVisitor *visitor) {
794  return visitor->visitParensNode(this);
795  }
796 };
797 
798 /* UnaryOpNode */
799 
801  inst op;
802  Node *arg;
803 
804  UnaryOpNode(inst opIn, Node *argIn) : ExprNode(kUnaryOpNode), op(opIn), arg(argIn) {}
805  virtual ~UnaryOpNode() {
806  delete arg;
807  }
808  virtual bool accept(NodeVisitor *visitor) {
809  return visitor->visitUnaryOpNode(this);
810  }
811 };
812 
813 /* BinaryOpNode */
814 
816  inst op;
817  Node *a;
818  Node *b;
819 
820  BinaryOpNode(inst opIn, Node *aIn, Node *bIn) : ExprNode(kBinaryOpNode), op(opIn), a(aIn), b(bIn) {}
821  virtual ~BinaryOpNode() {
822  delete a;
823  delete b;
824  }
825  virtual bool accept(NodeVisitor *visitor) {
826  return visitor->visitBinaryOpNode(this);
827  }
828 };
829 
830 /* FrameNode */
831 
832 struct FrameNode : ExprNode {
833  Node *arg;
834 
835  FrameNode(Node *argIn) : ExprNode(kFrameNode), arg(argIn) {}
836  virtual ~FrameNode() {
837  delete arg;
838  }
839  virtual bool accept(NodeVisitor *visitor) {
840  return visitor->visitFrameNode(this);
841  }
842 };
843 
844 /* MovieNode */
845 
846 struct MovieNode : ExprNode {
847  Node *arg;
848 
849  MovieNode(Node *argIn) : ExprNode(kMovieNode), arg(argIn) {}
850  virtual ~MovieNode() {
851  delete arg;
852  }
853  virtual bool accept(NodeVisitor *visitor) {
854  return visitor->visitMovieNode(this);
855  }
856 };
857 
858 /* IntersectsNode */
859 
861  Node *sprite1;
862  Node *sprite2;
863 
864  IntersectsNode(Node *sprite1In, Node *sprite2In)
865  : ExprNode(kIntersectsNode), sprite1(sprite1In), sprite2(sprite2In) {}
866  virtual ~IntersectsNode() {
867  delete sprite1;
868  delete sprite2;
869  }
870  virtual bool accept(NodeVisitor *visitor) {
871  return visitor->visitIntersectsNode(this);
872  }
873 };
874 
875 /* WithinNode */
876 
878  Node *sprite1;
879  Node *sprite2;
880 
881  WithinNode(Node *sprite1In, Node *sprite2In)
882  : ExprNode(kWithinNode), sprite1(sprite1In), sprite2(sprite2In) {}
883  virtual ~WithinNode() {
884  delete sprite1;
885  delete sprite2;
886  }
887  virtual bool accept(NodeVisitor *visitor) {
888  return visitor->visitWithinNode(this);
889  }
890 };
891 
892 /* TheNode */
893 
894 struct TheNode : ExprNode {
895  Common::String *prop;
896 
897  TheNode(Common::String *propIn) : ExprNode(kTheNode), prop(propIn) {}
898  virtual ~TheNode() {
899  delete prop;
900  }
901  virtual bool accept(NodeVisitor *visitor) {
902  return visitor->visitTheNode(this);
903  }
904 };
905 
906 /* TheOfNode */
907 
908 struct TheOfNode : ExprNode {
909  Common::String *prop;
910  Node *obj;
911 
912  TheOfNode(Common::String *propIn, Node *objIn)
913  : ExprNode(kTheOfNode), prop(propIn), obj(objIn) {}
914  virtual ~TheOfNode() {
915  delete prop;
916  delete obj;
917  }
918  virtual bool accept(NodeVisitor *visitor) {
919  return visitor->visitTheOfNode(this);
920  }
921 };
922 
923 /* TheNumberOfNode */
924 
926  NumberOfType type;
927  Node *arg;
928 
929  TheNumberOfNode(NumberOfType typeIn, Node *argIn)
930  : ExprNode(kTheNumberOfNode), type(typeIn), arg(argIn) {}
931  virtual ~TheNumberOfNode() {
932  delete arg;
933  }
934  virtual bool accept(NodeVisitor *visitor) {
935  return visitor->visitTheNumberOfNode(this);
936  }
937 };
938 
939 /* TheLastNode */
940 
942  ChunkType type;
943  Node *arg;
944 
945  TheLastNode(ChunkType typeIn, Node *argIn)
946  : ExprNode(kTheLastNode), type(typeIn), arg(argIn) {}
947  virtual ~TheLastNode() {
948  delete arg;
949  }
950  virtual bool accept(NodeVisitor *visitor) {
951  return visitor->visitTheLastNode(this);
952  }
953 };
954 
955 /* TheDateTimeNode */
956 
958  int field;
959  int entity;
960 
961  TheDateTimeNode(int fieldIn, int entityIn)
962  : ExprNode(kTheDateTimeNode), field(fieldIn), entity(entityIn) {}
963  virtual ~TheDateTimeNode() {}
964  virtual bool accept(NodeVisitor *visitor) {
965  return visitor->visitTheDateTimeNode(this);
966  }
967 };
968 
969 /* MenuNode */
970 
971 struct MenuNode : ExprNode {
972  Node *arg;
973 
974  MenuNode(Node *argIn) : ExprNode(kMenuNode), arg(argIn) {}
975  virtual ~MenuNode() {
976  delete arg;
977  }
978  virtual bool accept(NodeVisitor *visitor) {
979  return visitor->visitMenuNode(this);
980  }
981 };
982 
983 /* MenuItemNode */
984 
986  Node *arg1;
987  Node *arg2;
988 
989  MenuItemNode(Node *arg1In, Node *arg2In)
990  : ExprNode(kMenuItemNode), arg1(arg1In), arg2(arg2In) {}
991  virtual ~MenuItemNode() {
992  delete arg1;
993  delete arg2;
994  }
995  virtual bool accept(NodeVisitor *visitor) {
996  return visitor->visitMenuItemNode(this);
997  }
998 };
999 
1000 /* SoundNode */
1001 
1003  Node *arg;
1004 
1005  SoundNode(Node *argIn) : ExprNode(kSoundNode), arg(argIn) {}
1006  virtual ~SoundNode() {
1007  delete arg;
1008  }
1009  virtual bool accept(NodeVisitor *visitor) {
1010  return visitor->visitSoundNode(this);
1011  }
1012 };
1013 
1014 /* SpriteNode */
1015 
1017  Node *arg;
1018 
1019  SpriteNode(Node *argIn) : ExprNode(kSpriteNode), arg(argIn) {}
1020  virtual ~SpriteNode() {
1021  delete arg;
1022  }
1023  virtual bool accept(NodeVisitor *visitor) {
1024  return visitor->visitSpriteNode(this);
1025  }
1026 };
1027 
1028 /* ChunkExprNode */
1029 
1031  ChunkType type;
1032  Node *start;
1033  Node *end;
1034  Node *src;
1035 
1036  ChunkExprNode(ChunkType typeIn, Node *startIn, Node *endIn, Node *srcIn)
1037  : ExprNode(kChunkExprNode), type(typeIn), start(startIn), end(endIn), src(srcIn) {}
1038  virtual ~ChunkExprNode() {
1039  delete start;
1040  delete end;
1041  delete src;
1042  }
1043  virtual bool accept(NodeVisitor *visitor) {
1044  return visitor->visitChunkExprNode(this);
1045  }
1046 };
1047 
1048 } // End of namespace Director
1049 
1050 #endif
Definition: lingo-ast.h:755
Definition: lingo-ast.h:800
Definition: lingo-ast.h:710
Definition: str.h:59
Definition: lingo-ast.h:815
Definition: lingo-ast.h:567
Definition: lingo-ast.h:518
Definition: lingo-ast.h:443
Definition: lingo-ast.h:460
Definition: lingo-ast.h:738
Definition: lingo-ast.h:941
Definition: array.h:52
Definition: lingo-ast.h:925
Definition: lingo-ast.h:786
Definition: lingo-ast.h:1016
Definition: lingo-ast.h:315
Definition: lingo-ast.h:160
Definition: lingo-ast.h:971
Definition: lingo-ast.h:296
Definition: archive.h:35
Definition: lingo-ast.h:1002
Definition: lingo-ast.h:644
Definition: lingo-ast.h:724
Definition: lingo-ast.h:279
Definition: lingo-ast.h:547
Definition: lingo-ast.h:333
Definition: lingo-ast.h:894
Definition: lingo-ast.h:682
Definition: lingo-ast.h:860
Definition: lingo-ast.h:401
Definition: lingo-ast.h:235
Definition: lingo-ast.h:670
Definition: lingo-ast.h:696
Definition: lingo-ast.h:350
Definition: lingo-ast.h:1030
Definition: lingo-ast.h:496
Definition: lingo-ast.h:265
Definition: lingo-ast.h:832
size_type size() const
Definition: array.h:315
Definition: lingo-ast.h:582
Definition: lingo-ast.h:616
Definition: lingo-ast.h:772
Definition: lingo-ast.h:244
Definition: lingo-ast.h:557
Definition: lingo-ast.h:957
Definition: lingo-ast.h:220
Definition: lingo-ast.h:877
Definition: lingo-ast.h:985
Definition: lingo-ast.h:908
Definition: lingo-ast.h:479
Definition: lingo-ast.h:846
Definition: lingo-ast.h:367
Definition: lingo-ast.h:658
Definition: lobject.h:332
Definition: lingo-ast.h:253
Definition: lingo-ast.h:630
Definition: lingo-ast.h:537
Definition: lingo-ast.h:384
Definition: lingo-ast.h:429
Definition: lingo-ast.h:599
Definition: lingo-ast.h:415