Changeset f75e25b


Ignore:
Timestamp:
May 12, 2022, 3:10:22 PM (2 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
e5628db
Parents:
6825167
Message:

removed else clause from loop after inserting it in compund stmt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/MultiLevelExit.cpp

    r6825167 rf75e25b  
    588588                }
    589589
     590                ptr<Stmt> else_stmt = nullptr;
     591                Stmt * loop_kid = nullptr;
     592                // check if loop node and if so add else clause if it exists
     593                const WhileDoStmt * whilePtr = dynamic_cast<const WhileDoStmt *>(kid.get());
     594                if ( whilePtr && whilePtr->else_) {
     595                        else_stmt = whilePtr->else_;
     596                        WhileDoStmt * mutate_ptr = mutate(whilePtr);
     597                        mutate_ptr->else_ = nullptr;
     598                        loop_kid = mutate_ptr;
     599                }
     600                const ForStmt * forPtr = dynamic_cast<const ForStmt *>(kid.get());
     601                if ( forPtr && forPtr->else_) {
     602                        else_stmt = forPtr->else_;
     603                        ForStmt * mutate_ptr = mutate(forPtr);
     604                        mutate_ptr->else_ = nullptr;
     605                        loop_kid = mutate_ptr;
     606                }
     607
    590608                try {
    591                         ret.push_back( kid->accept( *visitor ) );
     609                        if (else_stmt) ret.push_back( loop_kid->accept( *visitor ) );
     610                        else ret.push_back( kid->accept( *visitor ) );
    592611                } catch ( SemanticErrorException & e ) {
    593612                        errors.append( e );
    594613                }
    595614
    596                 // check if loop node and if so add else clause if it exists
    597                 const WhileDoStmt * whilePtr = dynamic_cast<const WhileDoStmt *>(kid.get());
    598                 if ( whilePtr && whilePtr->else_) ret.push_back(whilePtr->else_);
    599                 const ForStmt * forPtr = dynamic_cast<const ForStmt *>(kid.get());
    600                 if ( forPtr && forPtr->else_) ret.push_back(forPtr->else_);
     615                if (else_stmt) ret.push_back(else_stmt);
    601616
    602617                if ( ! break_label.empty() ) {
Note: See TracChangeset for help on using the changeset viewer.