10 #include "common/array.h" 11 #include "common/ptr.h" 12 #include "common/str.h" 13 #include "common/util.h" 22 struct RepeatWithInStmtNode;
70 Node(NodeType t, uint32 offset) : type(t), isExpression(
false), isStatement(
false), isLabel(
false), isLoop(
false), parent(
nullptr), _startOffset(offset), _endOffset(offset) {}
72 virtual void accept(
NodeVisitor& visitor)
const = 0;
74 Node *ancestorStatement();
76 virtual bool hasSpaces(
bool dot);
108 LoopNode(NodeType t, uint32 startIndex_, uint32 offset) :
StmtNode(t, offset), startIndex(startIndex_) {
117 virtual bool hasSpaces(
bool dot)
override;
118 virtual void accept(
NodeVisitor &visitor)
const override;
127 virtual void accept(
NodeVisitor &visitor)
const override;
139 virtual bool hasSpaces(
bool dot)
override;
140 virtual void accept(
NodeVisitor &visitor)
const override;
152 explicit BlockNode(uint32 offset) :
Node(kBlockNode, offset), endPos(-1), currentCaseLabel(
nullptr) {}
154 virtual void accept(
NodeVisitor &visitor)
const override;
164 :
Node(kHandlerNode, offset), handler(h) {
166 block->parent =
this;
168 virtual void accept(
NodeVisitor &visitor)
const override;
175 virtual void accept(
NodeVisitor &visitor)
const override;
185 operand->parent =
this;
187 virtual void accept(
NodeVisitor &visitor)
const override;
197 operand->parent =
this;
199 virtual void accept(
NodeVisitor &visitor)
const override;
210 :
ExprNode(kBinaryOpNode, offset), opcode(op) {
214 right->parent =
this;
216 virtual unsigned int getPrecedence()
const;
217 virtual void accept(
NodeVisitor &visitor)
const override;
229 :
ExprNode(kChunkExprNode, offset), type(t) {
231 first->parent =
this;
235 string->parent =
this;
237 virtual void accept(
NodeVisitor &visitor)
const override;
247 chunk->parent =
this;
249 virtual void accept(
NodeVisitor &visitor)
const override;
259 chunk->parent =
this;
261 virtual void accept(
NodeVisitor &visitor)
const override;
271 :
ExprNode(kSpriteIntersectsExprNode, offset) {
273 firstSprite->parent =
this;
275 secondSprite->parent =
this;
277 virtual void accept(
NodeVisitor &visitor)
const override;
287 :
ExprNode(kSpriteWithinExprNode, offset) {
289 firstSprite->parent =
this;
291 secondSprite->parent =
this;
293 virtual void accept(
NodeVisitor &visitor)
const override;
304 :
ExprNode(kMemberExprNode, offset), type(type_) {
306 this->memberID->parent =
this;
309 this->castID->parent =
this;
312 virtual bool hasSpaces(
bool dot)
override;
313 virtual void accept(
NodeVisitor &visitor)
const override;
322 virtual bool hasSpaces(
bool dot)
override;
323 virtual void accept(
NodeVisitor &visitor)
const override;
334 :
StmtNode(kAssignmentStmtNode, offset), forceVerbose(forceVerbose_) {
336 variable->parent =
this;
338 value->parent =
this;
341 virtual void accept(
NodeVisitor &visitor)
const override;
354 condition->parent =
this;
356 block1->parent =
this;
358 block2->parent =
this;
360 virtual void accept(
NodeVisitor &visitor)
const override;
370 :
LoopNode(kRepeatWhileStmtNode, startIndex_, offset) {
372 condition->parent =
this;
374 block->parent =
this;
376 virtual void accept(
NodeVisitor &visitor)
const override;
387 :
LoopNode(kRepeatWithInStmtNode, startIndex_, offset) {
392 block->parent =
this;
394 virtual void accept(
NodeVisitor &visitor)
const override;
407 :
LoopNode(kRepeatWithToStmtNode, startIndex_, offset), up(_up) {
410 start->parent =
this;
414 block->parent =
this;
416 virtual void accept(
NodeVisitor &visitor)
const override;
432 value->parent =
this;
434 virtual void accept(
NodeVisitor &visitor)
const override;
444 block->parent =
this;
446 virtual void accept(
NodeVisitor &visitor)
const override;
453 virtual void accept(
NodeVisitor &visitor)
const override;
465 int32 potentialOtherwisePos = -1;
469 value->parent =
this;
471 void addOtherwise(uint32 offset);
472 virtual void accept(
NodeVisitor &visitor)
const override;
483 window->parent =
this;
485 block->parent =
this;
487 virtual void accept(
NodeVisitor &visitor)
const override;
499 argList->parent =
this;
501 virtual void accept(
NodeVisitor &visitor)
const override;
511 argList->parent =
this;
513 virtual void accept(
NodeVisitor &visitor)
const override;
525 argList->parent =
this;
526 if (argList->getValue()->type == kDatumArgListNoRet)
531 bool noParens()
const;
532 bool isMemberExpr()
const;
533 virtual bool hasSpaces(
bool dot)
override;
534 virtual void accept(
NodeVisitor &visitor)
const override;
546 argList->parent =
this;
547 if (argList->getValue()->type == kDatumArgListNoRet)
552 virtual bool hasSpaces(
bool dot)
override;
553 virtual void accept(
NodeVisitor &visitor)
const override;
565 argList->parent =
this;
566 if (argList->getValue()->type == kDatumArgListNoRet)
571 virtual bool hasSpaces(
bool dot)
override;
572 virtual void accept(
NodeVisitor &visitor)
const override;
581 virtual void accept(
NodeVisitor &visitor)
const override;
591 :
ExprNode(kLastStringChunkExprNode, offset), type(t) {
595 virtual void accept(
NodeVisitor &visitor)
const override;
605 :
ExprNode(kStringChunkCountExprNode, offset), type(t) {
609 virtual void accept(
NodeVisitor &visitor)
const override;
619 :
ExprNode(kMenuPropExprNode, offset), prop(p) {
621 menuID->parent =
this;
623 virtual void accept(
NodeVisitor &visitor)
const override;
634 :
ExprNode(kMenuItemPropExprNode, offset), prop(p) {
636 menuID->parent =
this;
638 itemID->parent =
this;
640 virtual void accept(
NodeVisitor &visitor)
const override;
650 :
ExprNode(kSoundPropExprNode, offset), prop(p) {
652 soundID->parent =
this;
654 virtual void accept(
NodeVisitor &visitor)
const override;
664 :
ExprNode(kSpritePropExprNode, offset), prop(p) {
666 spriteID->parent =
this;
668 virtual void accept(
NodeVisitor &visitor)
const override;
678 :
ExprNode(kThePropExprNode, offset), prop(p) {
682 virtual void accept(
NodeVisitor &visitor)
const override;
692 :
ExprNode(kObjPropExprNode, offset), prop(p) {
696 virtual bool hasSpaces(
bool dot)
override;
697 virtual void accept(
NodeVisitor &visitor)
const override;
707 :
ExprNode(kObjBracketExprNode, offset) {
713 virtual bool hasSpaces(
bool dot)
override;
714 virtual void accept(
NodeVisitor &visitor)
const override;
726 :
ExprNode(kObjPropIndexExprNode, offset), prop(p) {
730 index->parent =
this;
733 index2->parent =
this;
736 virtual bool hasSpaces(
bool dot)
override;
737 virtual void accept(
NodeVisitor &visitor)
const override;
744 virtual void accept(
NodeVisitor &visitor)
const override;
751 virtual void accept(
NodeVisitor &visitor)
const override;
762 :
StmtNode(kPutStmtNode, offset), type(t) {
764 variable->parent =
this;
766 value->parent =
this;
768 virtual void accept(
NodeVisitor &visitor)
const override;
778 :
StmtNode(kWhenStmtNode, offset), event(e), script(s) {}
779 virtual void accept(
NodeVisitor &visitor)
const override;
789 virtual void accept(
NodeVisitor &visitor)
const override;
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); }
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); }
843 virtual void defaultVisit(
const Node &) {}
854 currentBlock = root->block.
get();
864 #endif // LINGODEC_AST_H
PointerType get() const
Definition: ptr.h:229
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: lobject.h:332