Changes in src/Parser/StatementNode.cc [702e826:f135b50]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r702e826 rf135b50 38 38 DeclarationNode * agg = decl->extractAggregate(); 39 39 if ( agg ) { 40 StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild ( decl ) ) );40 StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) ); 41 41 set_next( nextStmt ); 42 42 if ( decl->get_next() ) { … … 51 51 agg = decl; 52 52 } // if 53 stmt.reset( new DeclStmt( maybeMoveBuild ( agg) ) );53 stmt.reset( new DeclStmt( maybeMoveBuild< Declaration >(agg) ) ); 54 54 } // StatementNode::StatementNode 55 55 … … 73 73 74 74 Statement * build_expr( ExpressionNode * ctl ) { 75 Expression * e = maybeMoveBuild ( ctl );75 Expression * e = maybeMoveBuild< Expression >( ctl ); 76 76 77 77 if ( e ) return new ExprStmt( e ); … … 87 87 if ( ctl->condition ) { 88 88 // compare the provided condition against 0 89 cond = notZeroExpr( maybeMoveBuild ( ctl->condition) );89 cond = notZeroExpr( maybeMoveBuild< Expression >(ctl->condition) ); 90 90 } else { 91 91 for ( Statement * stmt : init ) { … … 134 134 } // if 135 135 // aststmt.size() == 0 for switch (...) {}, i.e., no declaration or statements 136 return new SwitchStmt( maybeMoveBuild ( ctl), aststmt );136 return new SwitchStmt( maybeMoveBuild< Expression >(ctl), aststmt ); 137 137 } // build_switch 138 138 139 139 Statement * build_case( ExpressionNode * ctl ) { 140 return new CaseStmt( maybeMoveBuild ( ctl), {} ); // stmt starts empty and then added to140 return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // stmt starts empty and then added to 141 141 } // build_case 142 142 … … 168 168 169 169 // do-while cannot have declarations in the contitional, so init is always empty 170 return new WhileDoStmt( notZeroExpr( maybeMoveBuild ( ctl) ), aststmt.front(), astelse.front(), {}, true );170 return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), {}, true ); 171 171 } // build_do_while 172 172 … … 176 176 177 177 Expression * astcond = nullptr; // maybe empty 178 astcond = notZeroExpr( maybeMoveBuild ( forctl->condition) );178 astcond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) ); 179 179 180 180 Expression * astincr = nullptr; // maybe empty 181 astincr = maybeMoveBuild ( forctl->change);181 astincr = maybeMoveBuild< Expression >(forctl->change); 182 182 delete forctl; 183 183 … … 199 199 Statement * build_branch( string * identifier, BranchStmt::Type kind ) { 200 200 Statement * ret = new BranchStmt( * identifier, kind ); 201 delete identifier; // allocated by lexer201 delete identifier; // allocated by lexer 202 202 return ret; 203 203 } // build_branch 204 204 205 205 Statement * build_computedgoto( ExpressionNode * ctl ) { 206 return new BranchStmt( maybeMoveBuild ( ctl), BranchStmt::Goto );206 return new BranchStmt( maybeMoveBuild< Expression >(ctl), BranchStmt::Goto ); 207 207 } // build_computedgoto 208 208 … … 236 236 list< CatchStmt * > aststmt; 237 237 buildMoveList< CatchStmt, StatementNode >( catch_, aststmt ); 238 CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >( maybeMoveBuild( try_ ));239 FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >( maybeMoveBuild( finally_) );238 CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_)); 239 FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_) ); 240 240 return new TryStmt( tryBlock, aststmt, finallyBlock ); 241 241 } // build_try … … 245 245 buildMoveList< Statement, StatementNode >( body, aststmt ); 246 246 assert( aststmt.size() == 1 ); 247 return new CatchStmt( kind, maybeMoveBuild ( decl ), maybeMoveBuild( cond), aststmt.front() );247 return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), aststmt.front() ); 248 248 } // build_catch 249 249 … … 274 274 275 275 WaitForStmt::Target target; 276 target.function = maybeBuild ( targetExpr );276 target.function = maybeBuild<Expression>( targetExpr ); 277 277 278 278 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() ); … … 284 284 node->clauses.push_back( WaitForStmt::Clause{ 285 285 target, 286 maybeMoveBuild ( stmt ),287 notZeroExpr( maybeMoveBuild ( when ) )286 maybeMoveBuild<Statement >( stmt ), 287 notZeroExpr( maybeMoveBuild<Expression>( when ) ) 288 288 }); 289 289 … … 293 293 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) { 294 294 WaitForStmt::Target target; 295 target.function = maybeBuild ( targetExpr );295 target.function = maybeBuild<Expression>( targetExpr ); 296 296 297 297 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() ); … … 303 303 node->clauses.insert( node->clauses.begin(), WaitForStmt::Clause{ 304 304 std::move( target ), 305 maybeMoveBuild ( stmt ),306 notZeroExpr( maybeMoveBuild ( when ) )305 maybeMoveBuild<Statement >( stmt ), 306 notZeroExpr( maybeMoveBuild<Expression>( when ) ) 307 307 }); 308 308 … … 314 314 315 315 if( timeout ) { 316 node->timeout.time = maybeMoveBuild ( timeout );317 node->timeout.statement = maybeMoveBuild ( stmt );318 node->timeout.condition = notZeroExpr( maybeMoveBuild ( when ) );316 node->timeout.time = maybeMoveBuild<Expression>( timeout ); 317 node->timeout.statement = maybeMoveBuild<Statement >( stmt ); 318 node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) ); 319 319 } else { 320 node->orelse.statement = maybeMoveBuild ( stmt );321 node->orelse.condition = notZeroExpr( maybeMoveBuild ( when ) );320 node->orelse.statement = maybeMoveBuild<Statement >( stmt ); 321 node->orelse.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) ); 322 322 } // if 323 323 … … 328 328 auto node = new WaitForStmt(); 329 329 330 node->timeout.time = maybeMoveBuild ( timeout );331 node->timeout.statement = maybeMoveBuild ( stmt );332 node->timeout.condition = notZeroExpr( maybeMoveBuild ( when ) );333 334 node->orelse.statement = maybeMoveBuild ( else_ );335 node->orelse.condition = notZeroExpr( maybeMoveBuild ( else_when ) );330 node->timeout.time = maybeMoveBuild<Expression>( timeout ); 331 node->timeout.statement = maybeMoveBuild<Statement >( stmt ); 332 node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) ); 333 334 node->orelse.statement = maybeMoveBuild<Statement >( else_ ); 335 node->orelse.condition = notZeroExpr( maybeMoveBuild<Expression>( else_when ) ); 336 336 337 337 return node; … … 341 341 list< Expression * > e; 342 342 buildMoveList( exprs, e ); 343 Statement * s = maybeMoveBuild ( stmt );343 Statement * s = maybeMoveBuild<Statement>( stmt ); 344 344 return new DeclStmt( new WithStmt( e, s ) ); 345 345 } // build_with … … 384 384 list< Expression * > expList; 385 385 buildMoveList( exprs, expList ); 386 Statement * body = maybeMoveBuild ( stmt );386 Statement * body = maybeMoveBuild<Statement>( stmt ); 387 387 return new MutexStmt( body, expList ); 388 388 } // build_mutex
Note: See TracChangeset
for help on using the changeset viewer.