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 bool hasSpaces(
bool dot)
override;
139 bool hasSpaces(
bool dot)
override;
152 explicit BlockNode(uint32 offset) :
Node(kBlockNode, offset), endPos(Common::String::npos) {}
164 :
Node(kHandlerNode, offset), handler(h) {
166 block->parent =
this;
185 operand->parent =
this;
197 operand->parent =
this;
210 :
ExprNode(kBinaryOpNode, offset), opcode(op) {
214 right->parent =
this;
216 virtual unsigned int getPrecedence()
const;
229 :
ExprNode(kChunkExprNode, offset), type(t) {
231 first->parent =
this;
235 string->parent =
this;
247 chunk->parent =
this;
259 chunk->parent =
this;
271 :
ExprNode(kSpriteIntersectsExprNode, offset) {
273 firstSprite->parent =
this;
275 secondSprite->parent =
this;
287 :
ExprNode(kSpriteWithinExprNode, offset) {
289 firstSprite->parent =
this;
291 secondSprite->parent =
this;
304 :
ExprNode(kMemberExprNode, offset), type(type_) {
306 this->memberID->parent =
this;
309 this->castID->parent =
this;
312 bool hasSpaces(
bool dot)
override;
322 bool hasSpaces(
bool dot)
override;
334 :
StmtNode(kAssignmentStmtNode, offset), forceVerbose(forceVerbose_) {
336 variable->parent =
this;
338 value->parent =
this;
354 condition->parent =
this;
356 block1->parent =
this;
358 block2->parent =
this;
370 :
LoopNode(kRepeatWhileStmtNode, startIndex_, offset) {
372 condition->parent =
this;
374 block->parent =
this;
387 :
LoopNode(kRepeatWithInStmtNode, startIndex_, offset) {
392 block->parent =
this;
407 :
LoopNode(kRepeatWithToStmtNode, startIndex_, offset), up(_up) {
410 start->parent =
this;
414 block->parent =
this;
432 value->parent =
this;
444 block->parent =
this;
465 int32 potentialOtherwisePos = -1;
469 value->parent =
this;
471 void addOtherwise(uint32 offset);
483 window->parent =
this;
485 block->parent =
this;
499 argList->parent =
this;
511 argList->parent =
this;
525 argList->parent =
this;
526 if (argList->getValue()->type == kDatumArgListNoRet)
531 bool noParens()
const;
532 bool isMemberExpr()
const;
533 bool hasSpaces(
bool dot)
override;
546 argList->parent =
this;
547 if (argList->getValue()->type == kDatumArgListNoRet)
552 bool hasSpaces(
bool dot)
override;
565 argList->parent =
this;
566 if (argList->getValue()->type == kDatumArgListNoRet)
571 bool hasSpaces(
bool dot)
override;
591 :
ExprNode(kLastStringChunkExprNode, offset), type(t) {
605 :
ExprNode(kStringChunkCountExprNode, offset), type(t) {
619 :
ExprNode(kMenuPropExprNode, offset), prop(p) {
621 menuID->parent =
this;
634 :
ExprNode(kMenuItemPropExprNode, offset), prop(p) {
636 menuID->parent =
this;
638 itemID->parent =
this;
650 :
ExprNode(kSoundPropExprNode, offset), prop(p) {
652 soundID->parent =
this;
664 :
ExprNode(kSpritePropExprNode, offset), prop(p) {
666 spriteID->parent =
this;
678 :
ExprNode(kThePropExprNode, offset), prop(p) {
692 :
ExprNode(kObjPropExprNode, offset), prop(p) {
696 bool hasSpaces(
bool dot)
override;
707 :
ExprNode(kObjBracketExprNode, offset) {
713 bool hasSpaces(
bool dot)
override;
726 :
ExprNode(kObjPropIndexExprNode, offset), prop(p) {
730 index->parent =
this;
733 index2->parent =
this;
736 bool hasSpaces(
bool dot)
override;
762 :
StmtNode(kPutStmtNode, offset), type(t) {
764 variable->parent =
this;
766 value->parent =
this;
778 :
StmtNode(kWhenStmtNode, offset), event(e), script(s) {}
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