void KeepRight( ProgNodeP r) { right = r; keepRight = true; ProgNodeP csBlock = GetStatementList(); ProgNodeP lastStatementList = NULL; while( csBlock != NULL) { if( csBlock->getType() == GDLTokenTypes::ELSEBLK) { ProgNodeP statementList = csBlock->GetFirstChild(); if( statementList != NULL) { lastStatementList = statementList; } } else { // keep expr in case of empty statement ProgNodeP statementList = csBlock->GetFirstChild()->GetNextSibling(); if( statementList != NULL) { lastStatementList = statementList; } } csBlock = csBlock->GetNextSibling(); } if( lastStatementList != NULL) lastStatementList->GetLastSibling()->KeepRight( right); GetStatementList()->SetAllBreak( right); }
void KeepRight( ProgNodeP r) { assert( down != NULL); right = r; keepRight = true; // down is expr ProgNodeP csBlock = GetStatementList(); while( csBlock != NULL) { if( csBlock->getType() == GDLTokenTypes::ELSEBLK) { ProgNodeP statementList = csBlock->GetFirstChild(); if( statementList != NULL) { statementList->GetLastSibling()->KeepRight( right); } } else { // keep expr in case of empty statement ProgNodeP statementList = csBlock->GetFirstChild()->GetNextSibling(); if( statementList != NULL) { statementList->GetLastSibling()->KeepRight( right); } } csBlock = csBlock->GetNextSibling(); } GetStatementList()->SetAllBreak( right); }
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(); } }