Changeset dac593fd for src/Parser/StatementNode.cc
- Timestamp:
- Aug 12, 2016, 11:24:15 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 9903ebb
- Parents:
- 71b5d4d3 (diff), 1ca15c1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r71b5d4d3 rdac593fd 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 22:08:38201613 // Update Count : 17312 // Last Modified On : Thu Aug 11 16:19:45 2016 13 // Update Count : 210 14 14 // 15 15 … … 118 118 119 119 StatementNode *StatementNode::append_last_case( StatementNode *stmt ) { 120 assert( false ); 120 121 if ( stmt != 0 ) { 121 122 StatementNode *next = ( StatementNode *)get_link(); 122 123 if ( next && ( next->get_type() == StatementNode::Case || next->get_type() == StatementNode::Default ) ) 123 next->append_last_case 124 next->append_last_case( stmt ); 124 125 else 125 126 if ( block == 0 ) … … 128 129 block->set_link( stmt ); 129 130 } // if 131 return this; 132 } 133 134 StatementNode *StatementNode2::append_last_case( StatementNode *stmt ) { 135 StatementNode *prev = this; 136 for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_link() ) { 137 StatementNode2 *node = dynamic_cast<StatementNode2 *>(curr); 138 assert( node ); 139 assert( dynamic_cast<CaseStmt *>(node->stmt) ); 140 prev = curr; 141 } // for 142 StatementNode2 *node = dynamic_cast<StatementNode2 *>(prev); 143 std::list<Statement *> stmts; 144 buildList( stmt, stmts ); 145 CaseStmt * caseStmt; 146 caseStmt = dynamic_cast<CaseStmt *>(node->stmt); 147 caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts ); 130 148 return this; 131 149 } … … 205 223 return new NullStmt( labs ); 206 224 } 225 assert( false ); 207 226 case If: 208 227 // { … … 220 239 assert( false ); 221 240 case Switch: 222 // return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches );241 // return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches ); 223 242 assert( false ); 224 243 case Case: 225 return new CaseStmt( labs, maybeBuild<Expression>(get_control() ), branches );244 //return new CaseStmt( labs, maybeBuild<Expression>(get_control() ), branches ); 226 245 assert( false ); 227 246 case Default: 228 return new CaseStmt( labs, 0, branches, true );247 //return new CaseStmt( labs, 0, branches, true ); 229 248 assert( false ); 230 249 case While: … … 260 279 assert( false ); 261 280 case Goto: 262 { 263 if ( get_target() == "" ) { // computed goto 264 assert( get_control() != 0 ); 265 return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto ); 266 } // if 267 268 return new BranchStmt( labs, get_target(), BranchStmt::Goto ); 269 } 281 // { 282 // if ( get_target() == "" ) { // computed goto 283 // assert( get_control() != 0 ); 284 // return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto ); 285 // } // if 286 287 // return new BranchStmt( labs, get_target(), BranchStmt::Goto ); 288 // } 289 assert( false ); 270 290 case Break: 271 return new BranchStmt( labs, get_target(), BranchStmt::Break );291 // return new BranchStmt( labs, get_target(), BranchStmt::Break ); 272 292 assert( false ); 273 293 case Continue: 274 return new BranchStmt( labs, get_target(), BranchStmt::Continue );294 // return new BranchStmt( labs, get_target(), BranchStmt::Continue ); 275 295 assert( false ); 276 296 case Return: 277 297 case Throw : 278 buildList( get_control(), exps ); 279 if ( exps.size() ==0 ) 280 return new ReturnStmt( labs, 0, type == Throw ); 281 if ( exps.size() > 0 ) 282 return new ReturnStmt( labs, exps.back(), type == Throw ); 298 // buildList( get_control(), exps ); 299 // if ( exps.size() ==0 ) 300 // return new ReturnStmt( labs, 0, type == Throw ); 301 // if ( exps.size() > 0 ) 302 // return new ReturnStmt( labs, exps.back(), type == Throw ); 303 assert( false ); 283 304 case Try: 284 305 { … … 314 335 } 315 336 337 Statement *build_expr( ExpressionNode *ctl ) { 338 Expression *e = maybeBuild< Expression >( ctl ); 339 340 if ( e ) 341 return new ExprStmt( noLabels, e ); 342 else 343 return new NullStmt( noLabels ); 344 } 345 316 346 Statement *build_if( ExpressionNode *ctl, StatementNode *then_stmt, StatementNode *else_stmt ) { 317 347 Statement *thenb, *elseb = 0; … … 338 368 Statement *build_case( ExpressionNode *ctl ) { 339 369 std::list<Statement *> branches; 340 buildList<Statement, StatementNode>( nullptr, branches );341 370 return new CaseStmt( noLabels, maybeBuild<Expression>(ctl), branches ); 342 371 } … … 377 406 Statement *build_branch( std::string identifier, BranchStmt::Type kind ) { 378 407 return new BranchStmt( noLabels, identifier, kind ); 408 } 409 Statement *build_computedgoto( ExpressionNode *ctl ) { 410 return new BranchStmt( noLabels, maybeBuild<Expression>(ctl), BranchStmt::Goto ); 411 } 412 413 Statement *build_return( ExpressionNode *ctl ) { 414 std::list<Expression *> exps; 415 buildList( ctl, exps ); 416 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr ); 417 } 418 Statement *build_throw( ExpressionNode *ctl ) { 419 std::list<Expression *> exps; 420 buildList( ctl, exps ); 421 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true ); 379 422 } 380 423
Note: See TracChangeset
for help on using the changeset viewer.