virtual void SetAllBreak( ProgNodeP target) { if( down != NULL && !keepDown) { down->SetAllBreak( target); } if( right != NULL && !keepRight) { right->SetAllBreak( target); } }
FOR_LOOPNode( ProgNodeP r, ProgNodeP d): BreakableNode() { SetType( GDLTokenTypes::FOR_LOOP, "for_loop"); SetRightDown( r, d); assert( down != NULL); statementList = this->GetStatementList(); if( statementList != NULL) { statementList->SetAllContinue( this); statementList->GetLastSibling()->KeepRight( this); // also NULL is fine for "right" when the FOR statement // is the last in the subroutine // it is important, that breakTargetSet is set hence // this call must be done even with right == NULL statementList->SetAllBreak( right); // if( right != NULL) statementList->SetAllBreak( right); } else { down->KeepRight( this); statementList = this; } }
WHILENode( const RefDNode& refNode): BreakableNode( refNode) { assert( down != NULL); // down->GetLastSibling()->KeepRight( this); // for empty body ProgNodeP statementList = this->GetStatementList(); if( statementList != NULL) { statementList->SetAllContinue( this); // must be called even with right == NULL, see FOR_LOOPNode statementList->SetAllBreak( right); // if( right != NULL) statementList->SetAllBreak( right); statementList->GetLastSibling()->KeepRight( this); // for empty body } }
SWITCHNode( const RefDNode& refNode): BreakableNode( refNode) { assert( down != NULL); ProgNodeP statementList = this->GetStatementList(); statementList->SetAllBreak( right); // down is expr ProgNodeP csBlock = GetStatementList(); ProgNodeP lastStatementList = NULL; while( csBlock != NULL) { if( csBlock->getType() == GDLTokenTypes::ELSEBLK) { ProgNodeP statementList = csBlock->GetFirstChild(); if( statementList != NULL) { if( lastStatementList != NULL) lastStatementList->GetLastSibling()->KeepRight( statementList); lastStatementList = statementList; } } else { // keep expr in case of empty statement ProgNodeP statementList = csBlock->GetFirstChild()->GetNextSibling(); if( statementList != NULL) { if( lastStatementList != NULL) lastStatementList->GetLastSibling()->KeepRight( statementList); lastStatementList = statementList; } } if( csBlock->GetNextSibling() == NULL) { if( lastStatementList != NULL) lastStatementList->GetLastSibling()->KeepRight( right); break; } csBlock = csBlock->GetNextSibling(); } }
REPEAT_LOOPNode( ProgNodeP r, ProgNodeP d): BreakableNode() { SetType( GDLTokenTypes::REPEAT_LOOP, "repeat_loop"); SetRightDown( r, d); assert( down != NULL); ProgNodeP statementList = this->GetStatementList(); if( statementList != NULL) { statementList->SetAllContinue( this); statementList->GetLastSibling()->KeepRight( this); // must be called even with right == NULL, see FOR_LOOPNode statementList->SetAllBreak( right); // if( right != NULL) statementList->SetAllBreak( right); } }