Changeset ba3706f for src/Parser
- Timestamp:
- Nov 30, 2017, 4:43:59 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- c50d54d
- Parents:
- 4429b04
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r4429b04 rba3706f 37 37 DeclarationNode *agg = decl->extractAggregate(); 38 38 if ( agg ) { 39 StatementNode *nextStmt = new StatementNode( new DeclStmt( noLabels,maybeBuild< Declaration >( decl ) ) );39 StatementNode *nextStmt = new StatementNode( new DeclStmt( 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( noLabels,maybeMoveBuild< Declaration >(agg) ) );52 stmt.reset( new DeclStmt( maybeMoveBuild< Declaration >(agg) ) ); 53 53 } // StatementNode::StatementNode 54 54 … … 75 75 76 76 if ( e ) 77 return new ExprStmt( noLabels,e );77 return new ExprStmt( e ); 78 78 else 79 return new NullStmt( noLabels);79 return new NullStmt(); 80 80 } 81 81 … … 113 113 } 114 114 delete ctl; 115 return new IfStmt( noLabels,cond, thenb, elseb, init );115 return new IfStmt( 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( noLabels,maybeMoveBuild< Expression >(ctl), branches );122 return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches ); 123 123 } 124 124 Statement *build_case( ExpressionNode *ctl ) { 125 125 std::list< Statement * > branches; 126 return new CaseStmt( noLabels,maybeMoveBuild< Expression >(ctl), branches );126 return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches ); 127 127 } 128 128 Statement *build_default() { 129 129 std::list< Statement * > branches; 130 return new CaseStmt( n oLabels, nullptr, branches, true );130 return new CaseStmt( 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 Labels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind );137 return new WhileStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind ); 138 138 } 139 139 … … 157 157 158 158 delete forctl; 159 return new ForStmt( noLabels,init, cond, incr, branches.front() );159 return new ForStmt( init, cond, incr, branches.front() ); 160 160 } 161 161 162 162 Statement *build_branch( BranchStmt::Type kind ) { 163 Statement * ret = new BranchStmt( noLabels,"", kind );163 Statement * ret = new BranchStmt( "", kind ); 164 164 return ret; 165 165 } 166 166 Statement *build_branch( std::string *identifier, BranchStmt::Type kind ) { 167 Statement * ret = new BranchStmt( noLabels,*identifier, kind );167 Statement * ret = new BranchStmt( *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( noLabels,maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );172 return new BranchStmt( maybeMoveBuild< Expression >(ctl), BranchStmt::Goto ); 173 173 } 174 174 … … 176 176 std::list< Expression * > exps; 177 177 buildMoveList( ctl, exps ); 178 return new ReturnStmt( noLabels,exps.size() > 0 ? exps.back() : nullptr );178 return new ReturnStmt( 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( noLabels,ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr );185 return new ThrowStmt( 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( noLabels,ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr );192 return new ThrowStmt( 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( noLabels,tryBlock, branches, finallyBlock );206 return new TryStmt( 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( noLabels,kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );212 return new CatchStmt( 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( noLabels,dynamic_cast< CompoundStmt * >( branches.front() ) );218 return new FinallyStmt( dynamic_cast< CompoundStmt * >( branches.front() ) ); 219 219 } 220 220 … … 289 289 290 290 Statement *build_compound( StatementNode *first ) { 291 CompoundStmt *cs = new CompoundStmt( noLabels);291 CompoundStmt *cs = new CompoundStmt(); 292 292 buildMoveList( first, cs->get_kids() ); 293 293 return cs; … … 301 301 buildMoveList( input, in ); 302 302 buildMoveList( clobber, clob ); 303 return new AsmStmt( noLabels,voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );303 return new AsmStmt( voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels ); 304 304 } 305 305
Note: See TracChangeset
for help on using the changeset viewer.