Changes in src/Parser/StatementNode.cc [2f22cc4:d1625f8]
- File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r2f22cc4 rd1625f8 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 10 13:54:21201613 // Update Count : 1 7012 // Last Modified On : Tue Aug 9 10:14:33 2016 13 // Update Count : 141 14 14 // 15 15 … … 206 206 } 207 207 case If: 208 // { 209 // Statement *thenb = 0, *elseb = 0; 210 // assert( branches.size() >= 1 ); 211 212 // thenb = branches.front(); 213 // branches.pop_front(); 214 // if ( ! branches.empty() ) { 215 // elseb = branches.front(); 216 // branches.pop_front(); 217 // } // if 218 // return new IfStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), thenb, elseb ); 219 // } 220 assert( false ); 208 { 209 Statement *thenb = 0, *elseb = 0; 210 assert( branches.size() >= 1 ); 211 212 thenb = branches.front(); 213 branches.pop_front(); 214 if ( ! branches.empty() ) { 215 elseb = branches.front(); 216 branches.pop_front(); 217 } // if 218 return new IfStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), thenb, elseb ); 219 } 220 case While: 221 assert( branches.size() == 1 ); 222 return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front() ); 223 case Do: 224 assert( branches.size() == 1 ); 225 return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front(), true ); 226 case For: 227 { 228 assert( branches.size() == 1 ); 229 230 ForCtlExprNode *ctl = dynamic_cast<ForCtlExprNode *>( get_control() ); 231 assert( ctl != 0 ); 232 233 std::list<Statement *> init; 234 if ( ctl->get_init() != 0 ) { 235 buildList( ctl->get_init(), init ); 236 } // if 237 238 Expression *cond = 0; 239 if ( ctl->get_condition() != 0 ) 240 cond = notZeroExpr( maybeBuild<Expression>(ctl->get_condition()) ); 241 242 Expression *incr = 0; 243 if ( ctl->get_change() != 0 ) 244 incr = maybeBuild<Expression>(ctl->get_change()); 245 246 return new ForStmt( labs, init, cond, incr, branches.front() ); 247 } 221 248 case Switch: 222 //return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches ); 223 assert( false ); 249 return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches ); 224 250 case Case: 225 return new CaseStmt( labs, maybeBuild<Expression>(get_control() ), branches );251 return new CaseStmt( labs, maybeBuild<Expression>(get_control()), branches ); 226 252 case Default: 227 253 return new CaseStmt( labs, 0, branches, true ); 228 case While:229 // assert( branches.size() == 1 );230 // return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front() );231 assert( false );232 case Do:233 // assert( branches.size() == 1 );234 // return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front(), true );235 assert( false );236 case For:237 // {238 // assert( branches.size() == 1 );239 240 // ForCtlExprNode *ctl = dynamic_cast<ForCtlExprNode *>( get_control() );241 // assert( ctl != 0 );242 243 // std::list<Statement *> init;244 // if ( ctl->get_init() != 0 ) {245 // buildList( ctl->get_init(), init );246 // } // if247 248 // Expression *cond = 0;249 // if ( ctl->get_condition() != 0 )250 // cond = notZeroExpr( maybeBuild<Expression>(ctl->get_condition()) );251 252 // Expression *incr = 0;253 // if ( ctl->get_change() != 0 )254 // incr = maybeBuild<Expression>(ctl->get_change());255 256 // return new ForStmt( labs, init, cond, incr, branches.front() );257 // }258 assert( false );259 254 case Goto: 260 255 { … … 310 305 } 311 306 312 Statement *build_if( ExpressionNode *ctl, StatementNode *then_stmt, StatementNode *else_stmt ) {313 Statement *thenb, *elseb = 0;314 std::list<Statement *> branches;315 buildList<Statement, StatementNode>( then_stmt, branches );316 assert( branches.size() >= 1 );317 thenb = branches.front();318 319 if ( else_stmt ) {320 std::list<Statement *> branches;321 buildList<Statement, StatementNode>( else_stmt, branches );322 assert( branches.size() >= 1 );323 elseb = branches.front();324 } // if325 return new IfStmt( noLabels, notZeroExpr( maybeBuild<Expression>(ctl) ), thenb, elseb );326 }327 328 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {329 std::list<Statement *> branches;330 buildList<Statement, StatementNode>( stmt, branches );331 assert( branches.size() >= 1 );332 return new SwitchStmt( noLabels, maybeBuild<Expression>(ctl), branches );333 }334 335 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {336 std::list<Statement *> branches;337 buildList<Statement, StatementNode>( stmt, branches );338 assert( branches.size() == 1 );339 return new WhileStmt( noLabels, notZeroExpr( maybeBuild<Expression>(ctl) ), branches.front(), kind );340 }341 342 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {343 std::list<Statement *> branches;344 buildList<Statement, StatementNode>( stmt, branches );345 assert( branches.size() == 1 );346 347 std::list<Statement *> init;348 if ( forctl->init != 0 ) {349 buildList( forctl->init, init );350 } // if351 352 Expression *cond = 0;353 if ( forctl->condition != 0 )354 cond = notZeroExpr( maybeBuild<Expression>(forctl->condition) );355 356 Expression *incr = 0;357 if ( forctl->change != 0 )358 incr = maybeBuild<Expression>(forctl->change);359 360 delete forctl;361 return new ForStmt( noLabels, init, cond, incr, branches.front() );362 }363 364 307 365 308 CompoundStmtNode::CompoundStmtNode() : first( 0 ), last( 0 ) {}
Note:
See TracChangeset
for help on using the changeset viewer.