Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    r7880579 r7ecbb7e  
    6262        StatementNode *node = dynamic_cast< StatementNode * >(prev);
    6363        std::list< Statement * > stmts;
    64         buildList( stmt, stmts );
     64        buildMoveList( stmt, stmts );
    6565        // splice any new Statements to end of current Statements
    6666        CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt);
     
    7070
    7171Statement *build_expr( ExpressionNode *ctl ) {
    72         Expression *e = maybeBuild< Expression >( ctl );
     72        Expression *e = maybeMoveBuild< Expression >( ctl );
    7373
    7474        if ( e )
     
    8181        Statement *thenb, *elseb = 0;
    8282        std::list< Statement * > branches;
    83         buildList< Statement, StatementNode >( then_stmt, branches );
     83        buildMoveList< Statement, StatementNode >( then_stmt, branches );
    8484        assert( branches.size() == 1 );
    8585        thenb = branches.front();
     
    8787        if ( else_stmt ) {
    8888                std::list< Statement * > branches;
    89                 buildList< Statement, StatementNode >( else_stmt, branches );
     89                buildMoveList< Statement, StatementNode >( else_stmt, branches );
    9090                assert( branches.size() == 1 );
    9191                elseb = branches.front();
    9292        } // if
    93         return new IfStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), thenb, elseb );
     93        return new IfStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), thenb, elseb );
    9494}
    9595
    9696Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
    9797        std::list< Statement * > branches;
    98         buildList< Statement, StatementNode >( stmt, branches );
     98        buildMoveList< Statement, StatementNode >( stmt, branches );
    9999        assert( branches.size() >= 0 );                                         // size == 0 for switch (...) {}, i.e., no declaration or statements
    100         return new SwitchStmt( noLabels, maybeBuild< Expression >(ctl), branches );
     100        return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
    101101}
    102102Statement *build_case( ExpressionNode *ctl ) {
    103103        std::list< Statement * > branches;
    104         return new CaseStmt( noLabels, maybeBuild< Expression >(ctl), branches );
     104        return new CaseStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
    105105}
    106106Statement *build_default() {
     
    111111Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {
    112112        std::list< Statement * > branches;
    113         buildList< Statement, StatementNode >( stmt, branches );
     113        buildMoveList< Statement, StatementNode >( stmt, branches );
    114114        assert( branches.size() == 1 );
    115         return new WhileStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), branches.front(), kind );
     115        return new WhileStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind );
    116116}
    117117
    118118Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {
    119119        std::list< Statement * > branches;
    120         buildList< Statement, StatementNode >( stmt, branches );
     120        buildMoveList< Statement, StatementNode >( stmt, branches );
    121121        assert( branches.size() == 1 );
    122122
    123123        std::list< Statement * > init;
    124124        if ( forctl->init != 0 ) {
    125                 buildList( forctl->init, init );
     125                buildMoveList( forctl->init, init );
    126126        } // if
    127127
    128128        Expression *cond = 0;
    129129        if ( forctl->condition != 0 )
    130                 cond = notZeroExpr( maybeBuild< Expression >(forctl->condition) );
     130                cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
    131131
    132132        Expression *incr = 0;
    133133        if ( forctl->change != 0 )
    134                 incr = maybeBuild< Expression >(forctl->change);
     134                incr = maybeMoveBuild< Expression >(forctl->change);
    135135
    136136        delete forctl;
     
    142142}
    143143Statement *build_computedgoto( ExpressionNode *ctl ) {
    144         return new BranchStmt( noLabels, maybeBuild< Expression >(ctl), BranchStmt::Goto );
     144        return new BranchStmt( noLabels, maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );
    145145}
    146146
    147147Statement *build_return( ExpressionNode *ctl ) {
    148148        std::list< Expression * > exps;
    149         buildList( ctl, exps );
     149        buildMoveList( ctl, exps );
    150150        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr );
    151151}
    152152Statement *build_throw( ExpressionNode *ctl ) {
    153153        std::list< Expression * > exps;
    154         buildList( ctl, exps );
     154        buildMoveList( ctl, exps );
    155155        return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true );
    156156}
     
    158158Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
    159159        std::list< Statement * > branches;
    160         buildList< Statement, StatementNode >( catch_stmt, branches );
    161         CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeBuild< Statement >(try_stmt));
     160        buildMoveList< Statement, StatementNode >( catch_stmt, branches );
     161        CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    162162        assert( tryBlock );
    163         FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeBuild< Statement >(finally_stmt) );
     163        FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
    164164        return new TryStmt( noLabels, tryBlock, branches, finallyBlock );
    165165}
    166166Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) {
    167167        std::list< Statement * > branches;
    168         buildList< Statement, StatementNode >( stmt, branches );
     168        buildMoveList< Statement, StatementNode >( stmt, branches );
    169169        assert( branches.size() == 1 );
    170         return new CatchStmt( noLabels, maybeBuild< Declaration >(decl), branches.front(), catchAny );
     170        return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny );
    171171}
    172172Statement *build_finally( StatementNode *stmt ) {
    173173        std::list< Statement * > branches;
    174         buildList< Statement, StatementNode >( stmt, branches );
     174        buildMoveList< Statement, StatementNode >( stmt, branches );
    175175        assert( branches.size() == 1 );
    176176        return new FinallyStmt( noLabels, dynamic_cast< CompoundStmt * >( branches.front() ) );
     
    179179Statement *build_compound( StatementNode *first ) {
    180180        CompoundStmt *cs = new CompoundStmt( noLabels );
    181         buildList( first, cs->get_kids() );
     181        buildMoveList( first, cs->get_kids() );
    182182        return cs;
    183183}
     
    187187        std::list< ConstantExpr * > clob;
    188188
    189         buildList( output, out );
    190         buildList( input, in );
    191         buildList( clobber, clob );
     189        buildMoveList( output, out );
     190        buildMoveList( input, in );
     191        buildMoveList( clobber, clob );
    192192        return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
    193193}
Note: See TracChangeset for help on using the changeset viewer.