Changes in src/Parser/StatementNode.cc [7880579:7ecbb7e]
- File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r7880579 r7ecbb7e 62 62 StatementNode *node = dynamic_cast< StatementNode * >(prev); 63 63 std::list< Statement * > stmts; 64 build List( stmt, stmts );64 buildMoveList( stmt, stmts ); 65 65 // splice any new Statements to end of current Statements 66 66 CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt); … … 70 70 71 71 Statement *build_expr( ExpressionNode *ctl ) { 72 Expression *e = maybe Build< Expression >( ctl );72 Expression *e = maybeMoveBuild< Expression >( ctl ); 73 73 74 74 if ( e ) … … 81 81 Statement *thenb, *elseb = 0; 82 82 std::list< Statement * > branches; 83 build List< Statement, StatementNode >( then_stmt, branches );83 buildMoveList< Statement, StatementNode >( then_stmt, branches ); 84 84 assert( branches.size() == 1 ); 85 85 thenb = branches.front(); … … 87 87 if ( else_stmt ) { 88 88 std::list< Statement * > branches; 89 build List< Statement, StatementNode >( else_stmt, branches );89 buildMoveList< Statement, StatementNode >( else_stmt, branches ); 90 90 assert( branches.size() == 1 ); 91 91 elseb = branches.front(); 92 92 } // if 93 return new IfStmt( noLabels, notZeroExpr( maybe Build< Expression >(ctl) ), thenb, elseb );93 return new IfStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), thenb, elseb ); 94 94 } 95 95 96 96 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) { 97 97 std::list< Statement * > branches; 98 build List< Statement, StatementNode >( stmt, branches );98 buildMoveList< Statement, StatementNode >( stmt, branches ); 99 99 assert( branches.size() >= 0 ); // size == 0 for switch (...) {}, i.e., no declaration or statements 100 return new SwitchStmt( noLabels, maybe Build< Expression >(ctl), branches );100 return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches ); 101 101 } 102 102 Statement *build_case( ExpressionNode *ctl ) { 103 103 std::list< Statement * > branches; 104 return new CaseStmt( noLabels, maybe Build< Expression >(ctl), branches );104 return new CaseStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches ); 105 105 } 106 106 Statement *build_default() { … … 111 111 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) { 112 112 std::list< Statement * > branches; 113 build List< Statement, StatementNode >( stmt, branches );113 buildMoveList< Statement, StatementNode >( stmt, branches ); 114 114 assert( branches.size() == 1 ); 115 return new WhileStmt( noLabels, notZeroExpr( maybe Build< Expression >(ctl) ), branches.front(), kind );115 return new WhileStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind ); 116 116 } 117 117 118 118 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) { 119 119 std::list< Statement * > branches; 120 build List< Statement, StatementNode >( stmt, branches );120 buildMoveList< Statement, StatementNode >( stmt, branches ); 121 121 assert( branches.size() == 1 ); 122 122 123 123 std::list< Statement * > init; 124 124 if ( forctl->init != 0 ) { 125 build List( forctl->init, init );125 buildMoveList( forctl->init, init ); 126 126 } // if 127 127 128 128 Expression *cond = 0; 129 129 if ( forctl->condition != 0 ) 130 cond = notZeroExpr( maybe Build< Expression >(forctl->condition) );130 cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) ); 131 131 132 132 Expression *incr = 0; 133 133 if ( forctl->change != 0 ) 134 incr = maybe Build< Expression >(forctl->change);134 incr = maybeMoveBuild< Expression >(forctl->change); 135 135 136 136 delete forctl; … … 142 142 } 143 143 Statement *build_computedgoto( ExpressionNode *ctl ) { 144 return new BranchStmt( noLabels, maybe Build< Expression >(ctl), BranchStmt::Goto );144 return new BranchStmt( noLabels, maybeMoveBuild< Expression >(ctl), BranchStmt::Goto ); 145 145 } 146 146 147 147 Statement *build_return( ExpressionNode *ctl ) { 148 148 std::list< Expression * > exps; 149 build List( ctl, exps );149 buildMoveList( ctl, exps ); 150 150 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr ); 151 151 } 152 152 Statement *build_throw( ExpressionNode *ctl ) { 153 153 std::list< Expression * > exps; 154 build List( ctl, exps );154 buildMoveList( ctl, exps ); 155 155 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true ); 156 156 } … … 158 158 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) { 159 159 std::list< Statement * > branches; 160 build List< Statement, StatementNode >( catch_stmt, branches );161 CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybe Build< Statement >(try_stmt));160 buildMoveList< Statement, StatementNode >( catch_stmt, branches ); 161 CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt)); 162 162 assert( tryBlock ); 163 FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybe Build< Statement >(finally_stmt) );163 FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) ); 164 164 return new TryStmt( noLabels, tryBlock, branches, finallyBlock ); 165 165 } 166 166 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) { 167 167 std::list< Statement * > branches; 168 build List< Statement, StatementNode >( stmt, branches );168 buildMoveList< Statement, StatementNode >( stmt, branches ); 169 169 assert( branches.size() == 1 ); 170 return new CatchStmt( noLabels, maybe Build< Declaration >(decl), branches.front(), catchAny );170 return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny ); 171 171 } 172 172 Statement *build_finally( StatementNode *stmt ) { 173 173 std::list< Statement * > branches; 174 build List< Statement, StatementNode >( stmt, branches );174 buildMoveList< Statement, StatementNode >( stmt, branches ); 175 175 assert( branches.size() == 1 ); 176 176 return new FinallyStmt( noLabels, dynamic_cast< CompoundStmt * >( branches.front() ) ); … … 179 179 Statement *build_compound( StatementNode *first ) { 180 180 CompoundStmt *cs = new CompoundStmt( noLabels ); 181 build List( first, cs->get_kids() );181 buildMoveList( first, cs->get_kids() ); 182 182 return cs; 183 183 } … … 187 187 std::list< ConstantExpr * > clob; 188 188 189 build List( output, out );190 build List( input, in );191 build List( clobber, clob );189 buildMoveList( output, out ); 190 buildMoveList( input, in ); 191 buildMoveList( clobber, clob ); 192 192 return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels ); 193 193 }
Note:
See TracChangeset
for help on using the changeset viewer.