Changes in src/Parser/StatementNode.cc [ba3706f:a378ca7]
- File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
rba3706f ra378ca7 37 37 DeclarationNode *agg = decl->extractAggregate(); 38 38 if ( agg ) { 39 StatementNode *nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );39 StatementNode *nextStmt = new StatementNode( new DeclStmt( noLabels, maybeBuild< Declaration >( decl ) ) ); 40 40 set_next( nextStmt ); 41 41 if ( decl->get_next() ) { … … 50 50 agg = decl; 51 51 } // if 52 stmt.reset( new DeclStmt( maybeMoveBuild< Declaration >(agg) ) );52 stmt.reset( new DeclStmt( noLabels, maybeMoveBuild< Declaration >(agg) ) ); 53 53 } // StatementNode::StatementNode 54 54 … … 75 75 76 76 if ( e ) 77 return new ExprStmt( e );77 return new ExprStmt( noLabels, e ); 78 78 else 79 return new NullStmt( );79 return new NullStmt( noLabels ); 80 80 } 81 81 … … 113 113 } 114 114 delete ctl; 115 return new IfStmt( cond, thenb, elseb, init );115 return new IfStmt( noLabels, cond, thenb, elseb, init ); 116 116 } 117 117 … … 120 120 buildMoveList< Statement, StatementNode >( stmt, branches ); 121 121 // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements 122 return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );122 return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches ); 123 123 } 124 124 Statement *build_case( ExpressionNode *ctl ) { 125 125 std::list< Statement * > branches; 126 return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches );126 return new CaseStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches ); 127 127 } 128 128 Statement *build_default() { 129 129 std::list< Statement * > branches; 130 return new CaseStmt( n ullptr, branches, true );130 return new CaseStmt( noLabels, nullptr, branches, true ); 131 131 } 132 132 … … 135 135 buildMoveList< Statement, StatementNode >( stmt, branches ); 136 136 assert( branches.size() == 1 ); 137 return new WhileStmt( no tZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind );137 return new WhileStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind ); 138 138 } 139 139 … … 157 157 158 158 delete forctl; 159 return new ForStmt( init, cond, incr, branches.front() );159 return new ForStmt( noLabels, init, cond, incr, branches.front() ); 160 160 } 161 161 162 162 Statement *build_branch( BranchStmt::Type kind ) { 163 Statement * ret = new BranchStmt( "", kind );163 Statement * ret = new BranchStmt( noLabels, "", kind ); 164 164 return ret; 165 165 } 166 166 Statement *build_branch( std::string *identifier, BranchStmt::Type kind ) { 167 Statement * ret = new BranchStmt( *identifier, kind );167 Statement * ret = new BranchStmt( noLabels, *identifier, kind ); 168 168 delete identifier; // allocated by lexer 169 169 return ret; 170 170 } 171 171 Statement *build_computedgoto( ExpressionNode *ctl ) { 172 return new BranchStmt( maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );172 return new BranchStmt( noLabels, maybeMoveBuild< Expression >(ctl), BranchStmt::Goto ); 173 173 } 174 174 … … 176 176 std::list< Expression * > exps; 177 177 buildMoveList( ctl, exps ); 178 return new ReturnStmt( exps.size() > 0 ? exps.back() : nullptr );178 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr ); 179 179 } 180 180 … … 183 183 buildMoveList( ctl, exps ); 184 184 assertf( exps.size() < 2, "This means we are leaking memory"); 185 return new ThrowStmt( ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr );185 return new ThrowStmt( noLabels, ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr ); 186 186 } 187 187 … … 190 190 buildMoveList( ctl, exps ); 191 191 assertf( exps.size() < 2, "This means we are leaking memory"); 192 return new ThrowStmt( ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr );192 return new ThrowStmt( noLabels, ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr ); 193 193 } 194 194 … … 204 204 CompoundStmt *tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt)); 205 205 FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) ); 206 return new TryStmt( tryBlock, branches, finallyBlock );206 return new TryStmt( noLabels, tryBlock, branches, finallyBlock ); 207 207 } 208 208 Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) { … … 210 210 buildMoveList< Statement, StatementNode >( body, branches ); 211 211 assert( branches.size() == 1 ); 212 return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );212 return new CatchStmt( noLabels, kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() ); 213 213 } 214 214 Statement *build_finally( StatementNode *stmt ) { … … 216 216 buildMoveList< Statement, StatementNode >( stmt, branches ); 217 217 assert( branches.size() == 1 ); 218 return new FinallyStmt( dynamic_cast< CompoundStmt * >( branches.front() ) );218 return new FinallyStmt( noLabels, dynamic_cast< CompoundStmt * >( branches.front() ) ); 219 219 } 220 220 … … 282 282 node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) ); 283 283 284 node->orelse.statement = maybeMoveBuild<Statement >( else_stmt );284 node->orelse.statement = maybeMoveBuild<Statement >( else_stmt ); 285 285 node->orelse.condition = notZeroExpr( maybeMoveBuild<Expression>( else_when ) ); 286 286 … … 288 288 } 289 289 290 WithStmt * build_with( ExpressionNode * exprs, StatementNode * stmt ) { 291 std::list< Expression * > e; 292 buildMoveList( exprs, e ); 293 Statement * s = maybeMoveBuild<Statement>( stmt ); 294 return new WithStmt( e, s ); 295 } 296 290 297 Statement *build_compound( StatementNode *first ) { 291 CompoundStmt *cs = new CompoundStmt( );298 CompoundStmt *cs = new CompoundStmt( noLabels ); 292 299 buildMoveList( first, cs->get_kids() ); 293 300 return cs; … … 301 308 buildMoveList( input, in ); 302 309 buildMoveList( clobber, clob ); 303 return new AsmStmt( voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );310 return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels ); 304 311 } 305 312
Note:
See TracChangeset
for help on using the changeset viewer.