Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    rcc32d83 ree3c93d  
    8080}
    8181
    82 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
    83         Statement * thenb, * elseb = 0;
    84         std::list< Statement * > branches;
    85         buildMoveList< Statement, StatementNode >( then_stmt, branches );
    86         assert( branches.size() == 1 );
    87         thenb = branches.front();
    88 
    89         if ( else_stmt ) {
    90                 std::list< Statement * > branches;
    91                 buildMoveList< Statement, StatementNode >( else_stmt, branches );
    92                 assert( branches.size() == 1 );
    93                 elseb = branches.front();
    94         } // if
    95 
    96         std::list< Statement * > init;
     82Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init ) {
    9783        if ( ctl->init != 0 ) {
    9884                buildMoveList( ctl->init, init );
     
    10288        if ( ctl->condition ) {
    10389                // compare the provided condition against 0
    104                 cond =  notZeroExpr( maybeMoveBuild< Expression >(ctl->condition) );
     90                cond = notZeroExpr( maybeMoveBuild< Expression >(ctl->condition) );
    10591        } else {
    10692                for ( Statement * stmt : init ) {
     
    11399        }
    114100        delete ctl;
     101        return cond;
     102}
     103
     104Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
     105        Statement * thenb, * elseb = 0;
     106        std::list< Statement * > branches;
     107        buildMoveList< Statement, StatementNode >( then_stmt, branches );
     108        assert( branches.size() == 1 );
     109        thenb = branches.front();
     110
     111        if ( else_stmt ) {
     112                std::list< Statement * > branches;
     113                buildMoveList< Statement, StatementNode >( else_stmt, branches );
     114                assert( branches.size() == 1 );
     115                elseb = branches.front();
     116        } // if
     117
     118        std::list< Statement * > init;
     119        Expression * cond = build_if_control( ctl, init );
    115120        return new IfStmt( cond, thenb, elseb, init );
    116121}
     
    144149        buildMoveList< Statement, StatementNode >( stmt, branches );
    145150        assert( branches.size() == 1 );
    146         return new WhileStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind );
     151
     152        std::list< Statement * > init;
     153        return new WhileStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), init, kind );
    147154}
    148155
Note: See TracChangeset for help on using the changeset viewer.