Changeset ba3706f
- 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
- Location:
- src
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixNames.cc
r4429b04 rba3706f 121 121 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 122 122 } 123 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( n oLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );123 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) ); 124 124 CodeGen::FixMain::registerMain( functionDecl ); 125 125 } -
src/Common/PassVisitor.impl.h
r4429b04 rba3706f 55 55 it, 56 56 [](Declaration * decl) -> auto { 57 return new DeclStmt( noLabels,decl );57 return new DeclStmt( decl ); 58 58 } 59 59 ); … … 251 251 || ( empty( beforeDecls ) && empty( afterDecls )) ); 252 252 253 CompoundStmt *compound = new CompoundStmt( noLabels);253 CompoundStmt *compound = new CompoundStmt(); 254 254 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); } 255 255 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } -
src/Concurrency/Keywords.cc
r4429b04 rba3706f 38 38 39 39 namespace Concurrency { 40 41 namespace {42 const std::list<Label> noLabels;43 const std::list< Attribute * > noAttributes;44 Type::StorageClasses noStorage;45 Type::Qualifiers noQualifiers;46 }47 48 40 //============================================================================================= 49 41 // Pass declarations … … 296 288 ObjectDecl * this_decl = new ObjectDecl( 297 289 "this", 298 noStorage ,290 noStorageClasses, 299 291 LinkageSpec::Cforall, 300 292 nullptr, … … 313 305 new ObjectDecl( 314 306 "ret", 315 noStorage ,307 noStorageClasses, 316 308 LinkageSpec::Cforall, 317 309 nullptr, … … 346 338 main_decl = new FunctionDecl( 347 339 "main", 348 noStorage ,340 noStorageClasses, 349 341 LinkageSpec::Cforall, 350 342 main_type, … … 363 355 ObjectDecl * field = new ObjectDecl( 364 356 field_name, 365 noStorage ,357 noStorageClasses, 366 358 LinkageSpec::Cforall, 367 359 nullptr, … … 379 371 380 372 void ConcurrentSueKeyword::addRoutines( ObjectDecl * field, FunctionDecl * func ) { 381 CompoundStmt * statement = new CompoundStmt( noLabels);373 CompoundStmt * statement = new CompoundStmt(); 382 374 statement->push_back( 383 375 new ReturnStmt( 384 noLabels,385 376 new AddressExpr( 386 377 new MemberExpr( … … 488 479 ObjectDecl * monitors = new ObjectDecl( 489 480 "__monitor", 490 noStorage ,481 noStorageClasses, 491 482 LinkageSpec::Cforall, 492 483 nullptr, … … 509 500 // monitor_guard_t __guard = { __monitors, #, func }; 510 501 body->push_front( 511 new DeclStmt( n oLabels, new ObjectDecl(502 new DeclStmt( new ObjectDecl( 512 503 "__guard", 513 noStorage ,504 noStorageClasses, 514 505 LinkageSpec::Cforall, 515 506 nullptr, … … 530 521 531 522 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 532 body->push_front( new DeclStmt( noLabels,monitors) );523 body->push_front( new DeclStmt( monitors) ); 533 524 } 534 525 … … 536 527 ObjectDecl * monitors = new ObjectDecl( 537 528 "__monitors", 538 noStorage ,529 noStorageClasses, 539 530 LinkageSpec::Cforall, 540 531 nullptr, … … 569 560 // monitor_guard_t __guard = { __monitors, #, func }; 570 561 body->push_front( 571 new DeclStmt( n oLabels, new ObjectDecl(562 new DeclStmt( new ObjectDecl( 572 563 "__guard", 573 noStorage ,564 noStorageClasses, 574 565 LinkageSpec::Cforall, 575 566 nullptr, … … 591 582 592 583 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 593 body->push_front( new DeclStmt( noLabels,monitors) );584 body->push_front( new DeclStmt( monitors) ); 594 585 } 595 586 … … 631 622 stmt->push_back( 632 623 new ExprStmt( 633 noLabels,634 624 new UntypedExpr( 635 625 new NameExpr( "__thrd_start" ), -
src/Concurrency/Waitfor.cc
r4429b04 rba3706f 100 100 101 101 namespace Concurrency { 102 103 namespace {104 const std::list<Label> noLabels;105 const std::list< Attribute * > noAttributes;106 Type::StorageClasses noStorage;107 Type::Qualifiers noQualifiers;108 }109 110 102 //============================================================================================= 111 103 // Pass declarations … … 203 195 ResolvExpr::findVoidExpression( expr, indexer ); 204 196 205 return new ExprStmt( noLabels,expr );197 return new ExprStmt( expr ); 206 198 } 207 199 … … 259 251 if( !decl_monitor || !decl_acceptable || !decl_mask ) throw SemanticError( "waitfor keyword requires monitors to be in scope, add #include <monitor>", waitfor ); 260 252 261 CompoundStmt * stmt = new CompoundStmt( noLabels);253 CompoundStmt * stmt = new CompoundStmt(); 262 254 263 255 ObjectDecl * acceptables = declare( waitfor->clauses.size(), stmt ); … … 281 273 ); 282 274 283 CompoundStmt * compound = new CompoundStmt( noLabels);275 CompoundStmt * compound = new CompoundStmt(); 284 276 stmt->push_back( new IfStmt( 285 noLabels,286 277 safeCond( new VariableExpr( flag ) ), 287 278 compound, … … 313 304 ); 314 305 315 stmt->push_back( new DeclStmt( noLabels,acceptables) );306 stmt->push_back( new DeclStmt( acceptables) ); 316 307 317 308 Expression * set = new UntypedExpr( … … 326 317 ResolvExpr::findVoidExpression( set, indexer ); 327 318 328 stmt->push_back( new ExprStmt( noLabels,set ) );319 stmt->push_back( new ExprStmt( set ) ); 329 320 330 321 return acceptables; … … 341 332 ); 342 333 343 stmt->push_back( new DeclStmt( noLabels,flag) );334 stmt->push_back( new DeclStmt( flag) ); 344 335 345 336 return flag; … … 357 348 ResolvExpr::findVoidExpression( expr, indexer ); 358 349 359 return new ExprStmt( noLabels,expr );350 return new ExprStmt( expr ); 360 351 } 361 352 … … 399 390 ); 400 391 401 stmt->push_back( new DeclStmt( noLabels,mon) );392 stmt->push_back( new DeclStmt( mon) ); 402 393 403 394 return mon; … … 411 402 412 403 stmt->push_back( new IfStmt( 413 noLabels,414 404 safeCond( clause.condition ), 415 405 new CompoundStmt({ … … 447 437 ); 448 438 449 stmt->push_back( new DeclStmt( noLabels,timeout ) );439 stmt->push_back( new DeclStmt( timeout ) ); 450 440 451 441 if( time ) { 452 442 stmt->push_back( new IfStmt( 453 noLabels,454 443 safeCond( time_cond ), 455 444 new CompoundStmt({ 456 445 new ExprStmt( 457 noLabels,458 446 makeOpAssign( 459 447 new VariableExpr( timeout ), … … 471 459 if( has_else ) { 472 460 stmt->push_back( new IfStmt( 473 noLabels,474 461 safeCond( else_cond ), 475 462 new CompoundStmt({ 476 463 new ExprStmt( 477 noLabels,478 464 makeOpAssign( 479 465 new VariableExpr( timeout ), … … 511 497 ); 512 498 513 stmt->push_back( new DeclStmt( noLabels,index ) );499 stmt->push_back( new DeclStmt( index ) ); 514 500 515 501 ObjectDecl * mask = ObjectDecl::newObject( … … 526 512 ); 527 513 528 stmt->push_back( new DeclStmt( noLabels,mask ) );514 stmt->push_back( new DeclStmt( mask ) ); 529 515 530 516 stmt->push_back( new ExprStmt( 531 noLabels,532 517 new ApplicationExpr( 533 518 VariableExpr::functionPointer( decl_waitfor ), … … 557 542 ) { 558 543 SwitchStmt * swtch = new SwitchStmt( 559 noLabels,560 544 result, 561 545 std::list<Statement *>() … … 566 550 swtch->statements.push_back( 567 551 new CaseStmt( 568 noLabels,569 552 new ConstantExpr( Constant::from_ulong( i++ ) ), 570 553 { 571 554 clause.statement, 572 555 new BranchStmt( 573 noLabels,574 556 "", 575 557 BranchStmt::Break … … 583 565 swtch->statements.push_back( 584 566 new CaseStmt( 585 noLabels,586 567 new ConstantExpr( Constant::from_int( -2 ) ), 587 568 { 588 569 waitfor->timeout.statement, 589 570 new BranchStmt( 590 noLabels,591 571 "", 592 572 BranchStmt::Break … … 600 580 swtch->statements.push_back( 601 581 new CaseStmt( 602 noLabels,603 582 new ConstantExpr( Constant::from_int( -1 ) ), 604 583 { 605 584 waitfor->orelse.statement, 606 585 new BranchStmt( 607 noLabels,608 586 "", 609 587 BranchStmt::Break -
src/ControlStruct/ExceptTranslate.cc
r4429b04 rba3706f 30 30 #include "SynTree/Expression.h" // for UntypedExpr, ConstantExpr, Name... 31 31 #include "SynTree/Initializer.h" // for SingleInit, ListInit 32 #include "SynTree/Label.h" // for Label , noLabels32 #include "SynTree/Label.h" // for Label 33 33 #include "SynTree/Mutator.h" // for mutateAll 34 34 #include "SynTree/Statement.h" // for CompoundStmt, CatchStmt, ThrowStmt … … 57 57 58 58 void appendDeclStmt( CompoundStmt * block, Declaration * item ) { 59 block->push_back(new DeclStmt( noLabels,item));59 block->push_back(new DeclStmt(item)); 60 60 } 61 61 … … 205 205 throwStmt->set_expr( nullptr ); 206 206 delete throwStmt; 207 return new ExprStmt( noLabels,call );207 return new ExprStmt( call ); 208 208 } 209 209 … … 220 220 assert( handler_except_decl ); 221 221 222 CompoundStmt * result = new CompoundStmt( throwStmt->get_labels() ); 223 result->push_back( new ExprStmt( noLabels, UntypedExpr::createAssign( 222 CompoundStmt * result = new CompoundStmt(); 223 result->labels = throwStmt->labels; 224 result->push_back( new ExprStmt( UntypedExpr::createAssign( 224 225 nameOf( handler_except_decl ), 225 226 new ConstantExpr( Constant::null( … … 231 232 ) ) ); 232 233 result->push_back( new ExprStmt( 233 noLabels,234 234 new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) ) 235 235 ) ); … … 248 248 // return false; 249 249 Statement * result = new ReturnStmt( 250 throwStmt->get_labels(),251 250 new ConstantExpr( Constant::from_bool( false ) ) 252 251 ); 252 result->labels = throwStmt->labels; 253 253 delete throwStmt; 254 254 return result; … … 291 291 // } 292 292 // return; 293 CompoundStmt * block = new CompoundStmt( noLabels);293 CompoundStmt * block = new CompoundStmt(); 294 294 295 295 // Just copy the exception value. (Post Validation) … … 304 304 ) }) 305 305 ); 306 block->push_back( new DeclStmt( noLabels,local_except ) );306 block->push_back( new DeclStmt( local_except ) ); 307 307 308 308 // Add the cleanup attribute. … … 324 324 325 325 std::list<Statement *> caseBody 326 { block, new ReturnStmt( n oLabels, nullptr ) };326 { block, new ReturnStmt( nullptr ) }; 327 327 handler_wrappers.push_back( new CaseStmt( 328 noLabels,329 328 new ConstantExpr( Constant::from_int( index ) ), 330 329 caseBody … … 340 339 341 340 SwitchStmt * handler_lookup = new SwitchStmt( 342 noLabels,343 341 nameOf( index_obj ), 344 342 stmt_handlers 345 343 ); 346 CompoundStmt * body = new CompoundStmt( noLabels);344 CompoundStmt * body = new CompoundStmt(); 347 345 body->push_back( handler_lookup ); 348 346 … … 363 361 // } 364 362 365 CompoundStmt * block = new CompoundStmt( noLabels);363 CompoundStmt * block = new CompoundStmt(); 366 364 367 365 // Local Declaration … … 369 367 dynamic_cast<ObjectDecl *>( modded_handler->get_decl() ); 370 368 assert( local_except ); 371 block->push_back( new DeclStmt( noLabels,local_except ) );369 block->push_back( new DeclStmt( local_except ) ); 372 370 373 371 // Check for type match. … … 381 379 } 382 380 // Construct the match condition. 383 block->push_back( new IfStmt( noLabels,381 block->push_back( new IfStmt( 384 382 cond, modded_handler->get_body(), nullptr ) ); 385 383 … … 397 395 // } 398 396 399 CompoundStmt * body = new CompoundStmt( noLabels);397 CompoundStmt * body = new CompoundStmt(); 400 398 401 399 FunctionType * func_type = match_func_t.clone(); … … 413 411 414 412 // Create new body. 415 handler->set_body( new ReturnStmt( noLabels,413 handler->set_body( new ReturnStmt( 416 414 new ConstantExpr( Constant::from_int( index ) ) ) ); 417 415 … … 421 419 } 422 420 423 body->push_back( new ReturnStmt( noLabels,421 body->push_back( new ReturnStmt( 424 422 new ConstantExpr( Constant::from_int( 0 ) ) ) ); 425 423 … … 441 439 args.push_back( nameOf( terminate_match ) ); 442 440 443 CompoundStmt * callStmt = new CompoundStmt( noLabels);444 callStmt->push_back( new ExprStmt( noLabels,caller ) );441 CompoundStmt * callStmt = new CompoundStmt(); 442 callStmt->push_back( new ExprStmt( caller ) ); 445 443 return callStmt; 446 444 } … … 451 449 // HANDLER WRAPPERS { `hander->body`; return true; } 452 450 // } 453 CompoundStmt * body = new CompoundStmt( noLabels);451 CompoundStmt * body = new CompoundStmt(); 454 452 455 453 FunctionType * func_type = handle_func_t.clone(); … … 464 462 dynamic_cast<CompoundStmt*>( handler->get_body() ); 465 463 if ( ! handling_code ) { 466 handling_code = new CompoundStmt( noLabels);464 handling_code = new CompoundStmt(); 467 465 handling_code->push_back( handler->get_body() ); 468 466 } 469 handling_code->push_back( new ReturnStmt( noLabels,467 handling_code->push_back( new ReturnStmt( 470 468 new ConstantExpr( Constant::from_bool( true ) ) ) ); 471 469 handler->set_body( handling_code ); … … 476 474 } 477 475 478 body->push_back( new ReturnStmt( noLabels,476 body->push_back( new ReturnStmt( 479 477 new ConstantExpr( Constant::from_bool( false ) ) ) ); 480 478 … … 486 484 Statement * wraps, 487 485 FunctionDecl * resume_handler ) { 488 CompoundStmt * body = new CompoundStmt( noLabels);486 CompoundStmt * body = new CompoundStmt(); 489 487 490 488 // struct __try_resume_node __resume_node … … 521 519 setup->get_args().push_back( nameOf( resume_handler ) ); 522 520 523 body->push_back( new ExprStmt( noLabels,setup ) );521 body->push_back( new ExprStmt( setup ) ); 524 522 525 523 body->push_back( wraps ); … … 646 644 // Generate a prefix for the function names? 647 645 648 CompoundStmt * block = new CompoundStmt( noLabels);646 CompoundStmt * block = new CompoundStmt(); 649 647 CompoundStmt * inner = take_try_block( tryStmt ); 650 648 -
src/ControlStruct/ForExprMutator.cc
r4429b04 rba3706f 29 29 // Create compound statement, move initializers outside, 30 30 // the resut of the original stays as is. 31 CompoundStmt *block = new CompoundStmt( std::list< Label >());31 CompoundStmt *block = new CompoundStmt(); 32 32 std::list<Statement *> &stmts = block->get_kids(); 33 33 stmts.splice( stmts.end(), init ); -
src/ControlStruct/MLEMutator.cc
r4429b04 rba3706f 149 149 150 150 if ( CaseStmt * c = dynamic_cast< CaseStmt * >( statements.back() ) ) { 151 std::list<Label> temp; temp.push_back( brkLabel ); 152 c->get_statements().push_back( new BranchStmt( temp, Label("brkLabel"), BranchStmt::Break ) ); 151 Statement * stmt = new BranchStmt( Label("brkLabel"), BranchStmt::Break ); 152 stmt->labels.push_back( brkLabel ); 153 c->get_statements().push_back( stmt ); 153 154 } else assert(0); // as of this point, all statements of a switch are still CaseStmts 154 155 } // if … … 232 233 // transform break/continue statements into goto to simplify later handling of branches 233 234 delete branchStmt; 234 return new BranchStmt( std::list<Label>(),exitLabel, BranchStmt::Goto );235 return new BranchStmt( exitLabel, BranchStmt::Goto ); 235 236 } 236 237 … … 239 240 CompoundStmt *newBody; 240 241 if ( ! (newBody = dynamic_cast<CompoundStmt *>( bodyLoop )) ) { 241 newBody = new CompoundStmt( std::list< Label >());242 newBody = new CompoundStmt(); 242 243 newBody->get_kids().push_back( bodyLoop ); 243 244 } // if -
src/GenPoly/Box.cc
r4429b04 rba3706f 49 49 #include "SynTree/Expression.h" // for ApplicationExpr, UntypedExpr 50 50 #include "SynTree/Initializer.h" // for SingleInit, Initializer, Lis... 51 #include "SynTree/Label.h" // for Label , noLabels51 #include "SynTree/Label.h" // for Label 52 52 #include "SynTree/Mutator.h" // for maybeMutate, Mutator, mutateAll 53 53 #include "SynTree/Statement.h" // for ExprStmt, DeclStmt, ReturnStmt … … 293 293 FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ), 294 294 functionNesting > 0 ? Type::StorageClasses() : Type::StorageClasses( Type::Static ), 295 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels),295 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt(), 296 296 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ); 297 297 layoutDecl->fixUniqueId(); … … 321 321 /// makes an if-statement with a single-expression if-block and no then block 322 322 Statement *makeCond( Expression *cond, Expression *ifPart ) { 323 return new IfStmt( noLabels, cond, new ExprStmt( noLabels,ifPart ), 0 );323 return new IfStmt( cond, new ExprStmt( ifPart ), 0 ); 324 324 } 325 325 … … 340 340 /// adds an expression to a compound statement 341 341 void addExpr( CompoundStmt *stmts, Expression *expr ) { 342 stmts->get_kids().push_back( new ExprStmt( noLabels,expr ) );342 stmts->get_kids().push_back( new ExprStmt( expr ) ); 343 343 } 344 344 … … 629 629 ObjectDecl *Pass1::makeTemporary( Type *type ) { 630 630 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, type, 0 ); 631 stmtsToAddBefore.push_back( new DeclStmt( n oLabels, newObj ) );631 stmtsToAddBefore.push_back( new DeclStmt( newObj ) ); 632 632 return newObj; 633 633 } … … 740 740 ObjectDecl *newObj = ObjectDecl::newObject( tempNamer.newName(), newType, nullptr ); 741 741 newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right??? 742 stmtsToAddBefore.push_back( new DeclStmt( n oLabels, newObj ) );742 stmtsToAddBefore.push_back( new DeclStmt( newObj ) ); 743 743 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) ); // TODO: why doesn't this just use initialization syntax? 744 744 assign->get_args().push_back( new VariableExpr( newObj ) ); 745 745 assign->get_args().push_back( arg ); 746 stmtsToAddBefore.push_back( new ExprStmt( noLabels,assign ) );746 stmtsToAddBefore.push_back( new ExprStmt( assign ) ); 747 747 arg = new AddressExpr( new VariableExpr( newObj ) ); 748 748 } // if … … 888 888 // void return 889 889 addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars ); 890 bodyStmt = new ExprStmt( noLabels,adapteeApp );890 bodyStmt = new ExprStmt( adapteeApp ); 891 891 } else if ( isDynType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) { 892 892 // return type T … … 900 900 addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars ); 901 901 assign->get_args().push_back( adapteeApp ); 902 bodyStmt = new ExprStmt( noLabels,assign );902 bodyStmt = new ExprStmt( assign ); 903 903 } else { 904 904 // adapter for a function that returns a monomorphic value 905 905 addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars ); 906 bodyStmt = new ReturnStmt( noLabels,adapteeApp );906 bodyStmt = new ReturnStmt( adapteeApp ); 907 907 } // if 908 CompoundStmt *adapterBody = new CompoundStmt( noLabels);908 CompoundStmt *adapterBody = new CompoundStmt(); 909 909 adapterBody->get_kids().push_back( bodyStmt ); 910 910 std::string adapterName = makeAdapterName( mangleName ); … … 952 952 std::pair< AdapterIter, bool > answer = adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) ); 953 953 adapter = answer.first; 954 stmtsToAddBefore.push_back( new DeclStmt( n oLabels, newAdapter ) );954 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 955 955 } // if 956 956 assert( adapter != adapters.end() ); … … 1279 1279 retval->set_name( "_retval" ); 1280 1280 } 1281 functionDecl->get_statements()->get_kids().push_front( new DeclStmt( noLabels,retval ) );1281 functionDecl->get_statements()->get_kids().push_front( new DeclStmt( retval ) ); 1282 1282 DeclarationWithType * newRet = retval->clone(); // for ownership purposes 1283 1283 ftype->get_returnVals().front() = newRet; … … 1519 1519 // (alloca was previously used, but can't be safely used in loops) 1520 1520 ObjectDecl *newBuf = ObjectDecl::newObject( bufNamer.newName(), polyToMonoType( objectDecl->type ), nullptr ); 1521 stmtsToAddBefore.push_back( new DeclStmt( n oLabels, newBuf ) );1521 stmtsToAddBefore.push_back( new DeclStmt( newBuf ) ); 1522 1522 1523 1523 delete objectDecl->get_init(); … … 1598 1598 ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) { 1599 1599 ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, 0, type, init ); 1600 stmtsToAddBefore.push_back( new DeclStmt( n oLabels, newObj ) );1600 stmtsToAddBefore.push_back( new DeclStmt( newObj ) ); 1601 1601 return newObj; 1602 1602 } … … 1677 1677 addOtypeParamsToLayoutCall( layoutCall, otypeParams ); 1678 1678 1679 stmtsToAddBefore.push_back( new ExprStmt( noLabels,layoutCall ) );1679 stmtsToAddBefore.push_back( new ExprStmt( layoutCall ) ); 1680 1680 } 1681 1681 … … 1703 1703 addOtypeParamsToLayoutCall( layoutCall, otypeParams ); 1704 1704 1705 stmtsToAddBefore.push_back( new ExprStmt( noLabels,layoutCall ) );1705 stmtsToAddBefore.push_back( new ExprStmt( layoutCall ) ); 1706 1706 1707 1707 return true; -
src/GenPoly/InstantiateGeneric.cc
r4429b04 rba3706f 526 526 Expression * init = new CastExpr( new AddressExpr( memberExpr ), new PointerType( Type::Qualifiers(), concType->clone() ) ); 527 527 ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), new ReferenceType( Type::Qualifiers(), concType ), new SingleInit( init ) ); 528 stmtsToAddBefore.push_back( new DeclStmt( noLabels,tmp ) );528 stmtsToAddBefore.push_back( new DeclStmt( tmp ) ); 529 529 return new VariableExpr( tmp ); 530 530 } else { -
src/GenPoly/Specialize.cc
r4429b04 rba3706f 35 35 #include "SynTree/Declaration.h" // for FunctionDecl, DeclarationWit... 36 36 #include "SynTree/Expression.h" // for ApplicationExpr, Expression 37 #include "SynTree/Label.h" // for Label , noLabels37 #include "SynTree/Label.h" // for Label 38 38 #include "SynTree/Mutator.h" // for mutateAll 39 39 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, Expr... … … 234 234 } // if 235 235 // create new thunk with same signature as formal type (C linkage, empty body) 236 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), Type::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt( noLabels) );236 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), Type::StorageClasses(), LinkageSpec::C, newType, new CompoundStmt() ); 237 237 thunkFunc->fixUniqueId(); 238 238 … … 287 287 Statement *appStmt; 288 288 if ( funType->returnVals.empty() ) { 289 appStmt = new ExprStmt( noLabels,appExpr );290 } else { 291 appStmt = new ReturnStmt( noLabels,appExpr );289 appStmt = new ExprStmt( appExpr ); 290 } else { 291 appStmt = new ReturnStmt( appExpr ); 292 292 } // if 293 293 thunkFunc->statements->kids.push_back( appStmt ); 294 294 295 295 // add thunk definition to queue of statements to add 296 stmtsToAddBefore.push_back( new DeclStmt( noLabels,thunkFunc ) );296 stmtsToAddBefore.push_back( new DeclStmt( thunkFunc ) ); 297 297 // return address of thunk function as replacement expression 298 298 return new AddressExpr( new VariableExpr( thunkFunc ) ); -
src/InitTweak/FixGlobalInit.cc
r4429b04 rba3706f 29 29 #include "SynTree/Expression.h" // for ConstantExpr, Expression (ptr only) 30 30 #include "SynTree/Initializer.h" // for ConstructorInit, Initializer 31 #include "SynTree/Label.h" // for Label , noLabels31 #include "SynTree/Label.h" // for Label 32 32 #include "SynTree/Statement.h" // for CompoundStmt, Statement (ptr only) 33 33 #include "SynTree/Type.h" // for Type, Type::StorageClasses, Functi... … … 92 92 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 93 93 } 94 initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels) );94 initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 95 95 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 96 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels) );96 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 97 97 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 98 98 } -
src/InitTweak/FixInit.cc
r4429b04 rba3706f 49 49 #include "SynTree/Expression.h" // for UniqueExpr, VariableExpr, Unty... 50 50 #include "SynTree/Initializer.h" // for ConstructorInit, SingleInit 51 #include "SynTree/Label.h" // for Label, noLabels,operator<51 #include "SynTree/Label.h" // for Label, operator< 52 52 #include "SynTree/Mutator.h" // for mutateAll, Mutator, maybeMutate 53 53 #include "SynTree/Statement.h" // for ExprStmt, CompoundStmt, Branch... … … 544 544 // add all temporary declarations and their constructors 545 545 for ( ObjectDecl * obj : tempDecls ) { 546 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );546 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 547 547 } // for 548 548 for ( ObjectDecl * obj : returnDecls ) { 549 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );549 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 550 550 } // for 551 551 552 552 // add destructors after current statement 553 553 for ( Expression * dtor : dtors ) { 554 stmtsToAddAfter.push_back( new ExprStmt( noLabels,dtor ) );554 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 555 555 } // for 556 556 … … 598 598 if ( ! result->isVoid() ) { 599 599 for ( ObjectDecl * obj : stmtExpr->get_returnDecls() ) { 600 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );600 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 601 601 } // for 602 602 // add destructors after current statement 603 603 for ( Expression * dtor : stmtExpr->get_dtors() ) { 604 stmtsToAddAfter.push_back( new ExprStmt( noLabels,dtor ) );604 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 605 605 } // for 606 606 // must have a non-empty body, otherwise it wouldn't have a result 607 607 assert( ! stmts.empty() ); 608 608 assert( ! stmtExpr->get_returnDecls().empty() ); 609 stmts.push_back( new ExprStmt( n oLabels, new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );609 stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->get_returnDecls().front() ) ) ); 610 610 stmtExpr->get_returnDecls().clear(); 611 611 stmtExpr->get_dtors().clear(); … … 685 685 686 686 // generate body of if 687 CompoundStmt * initStmts = new CompoundStmt( noLabels);687 CompoundStmt * initStmts = new CompoundStmt(); 688 688 std::list< Statement * > & body = initStmts->get_kids(); 689 689 body.push_back( ctor ); 690 body.push_back( new ExprStmt( noLabels,setTrue ) );690 body.push_back( new ExprStmt( setTrue ) ); 691 691 692 692 // put it all together 693 IfStmt * ifStmt = new IfStmt( n oLabels, new VariableExpr( isUninitializedVar ), initStmts, 0 );694 stmtsToAddAfter.push_back( new DeclStmt( noLabels,isUninitializedVar ) );693 IfStmt * ifStmt = new IfStmt( new VariableExpr( isUninitializedVar ), initStmts, 0 ); 694 stmtsToAddAfter.push_back( new DeclStmt( isUninitializedVar ) ); 695 695 stmtsToAddAfter.push_back( ifStmt ); 696 696 … … 707 707 708 708 // void __objName_dtor_atexitN(...) {...} 709 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels) );709 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 710 710 dtorCaller->fixUniqueId(); 711 711 dtorCaller->get_statements()->push_back( dtorStmt ); … … 715 715 callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) ); 716 716 717 body.push_back( new ExprStmt( noLabels,callAtexit ) );717 body.push_back( new ExprStmt( callAtexit ) ); 718 718 719 719 // hoist variable and dtor caller decls to list of decls that will be added into global scope -
src/InitTweak/InitTweak.cc
r4429b04 rba3706f 19 19 #include "SynTree/Expression.h" // for Expression, UntypedExpr, Applicati... 20 20 #include "SynTree/Initializer.h" // for Initializer, ListInit, Designation 21 #include "SynTree/Label.h" // for Label , noLabels21 #include "SynTree/Label.h" // for Label 22 22 #include "SynTree/Statement.h" // for CompoundStmt, ExprStmt, BranchStmt 23 23 #include "SynTree/Type.h" // for FunctionType, ArrayType, PointerType … … 195 195 callExpr->get_args().splice( callExpr->get_args().end(), args ); 196 196 197 *out++ = new IfStmt( noLabels, cond, new ExprStmt( noLabels,callExpr ), nullptr );197 *out++ = new IfStmt( cond, new ExprStmt( callExpr ), nullptr ); 198 198 199 199 UntypedExpr * increment = new UntypedExpr( new NameExpr( "++?" ) ); 200 200 increment->get_args().push_back( index->clone() ); 201 *out++ = new ExprStmt( noLabels,increment );201 *out++ = new ExprStmt( increment ); 202 202 } 203 203 … … 244 244 std::list< Statement * > stmts; 245 245 build( callExpr, idx, idxEnd, init, back_inserter( stmts ) ); 246 stmts.push_back( new BranchStmt( noLabels,switchLabel, BranchStmt::Break ) );247 CaseStmt * caseStmt = new CaseStmt( noLabels,condition, stmts );246 stmts.push_back( new BranchStmt( switchLabel, BranchStmt::Break ) ); 247 CaseStmt * caseStmt = new CaseStmt( condition, stmts ); 248 248 branches.push_back( caseStmt ); 249 249 } 250 *out++ = new SwitchStmt( noLabels,index->clone(), branches );251 *out++ = new NullStmt( std::list<Label>{ switchLabel } );250 *out++ = new SwitchStmt( index->clone(), branches ); 251 *out++ = new NullStmt( { switchLabel } ); 252 252 } 253 253 } … … 262 262 Statement * InitImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) { 263 263 if ( ! init ) return nullptr; 264 CompoundStmt * block = new CompoundStmt( noLabels);264 CompoundStmt * block = new CompoundStmt(); 265 265 build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) ); 266 266 if ( block->get_kids().empty() ) { -
src/MakeLibCfa.cc
r4429b04 rba3706f 116 116 } // for 117 117 118 funcDecl->set_statements( new CompoundStmt( std::list< Label >()) );118 funcDecl->set_statements( new CompoundStmt() ); 119 119 newDecls.push_back( funcDecl ); 120 120 … … 130 130 case CodeGen::OT_INFIXASSIGN: 131 131 // return the recursive call 132 stmt = new ReturnStmt( n oLabels, newExpr );132 stmt = new ReturnStmt( newExpr ); 133 133 break; 134 134 case CodeGen::OT_CTOR: 135 135 case CodeGen::OT_DTOR: 136 136 // execute the recursive call 137 stmt = new ExprStmt( n oLabels, newExpr );137 stmt = new ExprStmt( newExpr ); 138 138 break; 139 139 case CodeGen::OT_CONSTANT: -
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 -
src/SymTab/AddVisit.h
r4429b04 rba3706f 24 24 // add any new declarations after the previous statement 25 25 for ( std::list< Declaration* >::iterator decl = visitor.declsToAddAfter.begin(); decl != visitor.declsToAddAfter.end(); ++decl ) { 26 DeclStmt *declStmt = new DeclStmt( noLabels,*decl );26 DeclStmt *declStmt = new DeclStmt( *decl ); 27 27 stmts.insert( stmt, declStmt ); 28 28 } … … 36 36 // add any new declarations before the statement 37 37 for ( std::list< Declaration* >::iterator decl = visitor.declsToAdd.begin(); decl != visitor.declsToAdd.end(); ++decl ) { 38 DeclStmt *declStmt = new DeclStmt( noLabels,*decl );38 DeclStmt *declStmt = new DeclStmt( *decl ); 39 39 stmts.insert( stmt, declStmt ); 40 40 } -
src/SymTab/Autogen.cc
r4429b04 rba3706f 264 264 Type::StorageClasses scs = functionNesting > 0 ? Type::StorageClasses() : Type::StorageClasses( Type::Static ); 265 265 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 266 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels),266 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt(), 267 267 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ); 268 268 decl->fixUniqueId(); … … 299 299 assert( assignType->returnVals.size() == 1 ); 300 300 ObjectDecl * dstParam = strict_dynamic_cast< ObjectDecl * >( assignType->parameters.front() ); 301 dcl->statements->push_back( new ReturnStmt( n oLabels, new VariableExpr( dstParam ) ) );301 dcl->statements->push_back( new ReturnStmt( new VariableExpr( dstParam ) ) ); 302 302 } 303 303 resolve( dcl ); … … 468 468 copy->args.push_back( new AddressExpr( new VariableExpr( srcParam ) ) ); 469 469 copy->args.push_back( new SizeofExpr( srcParam->get_type()->clone() ) ); 470 *out++ = new ExprStmt( noLabels,copy );470 *out++ = new ExprStmt( copy ); 471 471 } 472 472 … … 544 544 callExpr->get_args().push_back( new VariableExpr( dstParam ) ); 545 545 callExpr->get_args().push_back( new VariableExpr( srcParam ) ); 546 funcDecl->statements->push_back( new ExprStmt( noLabels,callExpr ) );546 funcDecl->statements->push_back( new ExprStmt( callExpr ) ); 547 547 } else { 548 548 // default ctor/dtor body is empty - add unused attribute to parameter to silence warnings … … 569 569 expr->args.push_back( new CastExpr( new VariableExpr( dst ), new ReferenceType( Type::Qualifiers(), typeDecl->base->clone() ) ) ); 570 570 if ( src ) expr->args.push_back( new CastExpr( new VariableExpr( src ), typeDecl->base->clone() ) ); 571 dcl->statements->kids.push_back( new ExprStmt( noLabels,expr ) );571 dcl->statements->kids.push_back( new ExprStmt( expr ) ); 572 572 }; 573 573 … … 664 664 untyped->get_args().push_back( new VariableExpr( ftype->get_parameters().back() ) ); 665 665 } 666 function->get_statements()->get_kids().push_back( new ExprStmt( noLabels,untyped ) );667 function->get_statements()->get_kids().push_back( new ReturnStmt( noLabels,UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) );666 function->get_statements()->get_kids().push_back( new ExprStmt( untyped ) ); 667 function->get_statements()->get_kids().push_back( new ReturnStmt( UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) ); 668 668 } 669 669 -
src/SymTab/Autogen.h
r4429b04 rba3706f 104 104 fExpr->args.splice( fExpr->args.end(), args ); 105 105 106 *out++ = new ExprStmt( noLabels,fExpr );106 *out++ = new ExprStmt( fExpr ); 107 107 108 108 srcParam.clearArrayIndices(); … … 162 162 163 163 // for stmt's body, eventually containing call 164 CompoundStmt * body = new CompoundStmt( noLabels);164 CompoundStmt * body = new CompoundStmt(); 165 165 Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->kids ), array->base, addCast, forward ); 166 166 167 167 // block containing for stmt and index variable 168 168 std::list<Statement *> initList; 169 CompoundStmt * block = new CompoundStmt( noLabels);170 block->push_back( new DeclStmt( noLabels,index ) );169 CompoundStmt * block = new CompoundStmt(); 170 block->push_back( new DeclStmt( index ) ); 171 171 if ( listInit ) block->get_kids().push_back( listInit ); 172 block->push_back( new ForStmt( noLabels,initList, cond, inc, body ) );172 block->push_back( new ForStmt( initList, cond, inc, body ) ); 173 173 174 174 *out++ = block; -
src/SynTree/CompoundStmt.cc
r4429b04 rba3706f 28 28 using std::endl; 29 29 30 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels) {30 CompoundStmt::CompoundStmt() : Statement() { 31 31 } 32 32 33 CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement( noLabels), kids( stmts ) {33 CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement(), kids( stmts ) { 34 34 } 35 35 -
src/SynTree/DeclStmt.cc
r4429b04 rba3706f 23 23 #include "SynTree/Label.h" // for Label 24 24 25 DeclStmt::DeclStmt( std::list<Label> labels, Declaration *decl ) : Statement( labels), decl( decl ) {25 DeclStmt::DeclStmt( Declaration *decl ) : Statement(), decl( decl ) { 26 26 } 27 27 -
src/SynTree/Statement.cc
r4429b04 rba3706f 32 32 using std::endl; 33 33 34 Statement::Statement( std::list<Label>labels ) : labels( labels ) {}34 Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {} 35 35 36 36 void Statement::print( std::ostream & os, Indenter ) const { … … 46 46 Statement::~Statement() {} 47 47 48 ExprStmt::ExprStmt( std::list<Label> labels, Expression *expr ) : Statement( labels), expr( expr ) {}48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} 49 49 50 50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 60 60 61 61 62 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}62 AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} 63 63 64 64 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { … … 96 96 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 97 97 98 BranchStmt::BranchStmt( std::list<Label> labels,Label target, Type type ) throw ( SemanticError ) :99 Statement( labels), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {98 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) : 99 Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 100 100 //actually this is a syntactic error signaled by the parser 101 101 if ( type == BranchStmt::Goto && target.empty() ) { … … 104 104 } 105 105 106 BranchStmt::BranchStmt( std::list<Label> labels,Expression *computedTarget, Type type ) throw ( SemanticError ) :107 Statement( labels), computedTarget( computedTarget ), type( type ) {106 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) : 107 Statement(), computedTarget( computedTarget ), type( type ) { 108 108 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { 109 109 throw SemanticError("Computed target not valid in branch statement"); … … 118 118 } 119 119 120 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *expr ) : Statement( labels), expr( expr ) {}120 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {} 121 121 122 122 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 135 135 } 136 136 137 IfStmt::IfStmt( std::list<Label> labels,Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):138 Statement( labels), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}137 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ): 138 Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} 139 139 140 140 IfStmt::IfStmt( const IfStmt & other ) : … … 176 176 } 177 177 178 SwitchStmt::SwitchStmt( std::list<Label> labels,Expression * condition, const std::list<Statement *> &statements ):179 Statement( labels), condition( condition ), statements( statements ) {178 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ): 179 Statement(), condition( condition ), statements( statements ) { 180 180 } 181 181 … … 201 201 } 202 202 203 CaseStmt::CaseStmt( std::list<Label> labels,Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :204 Statement( labels), condition( condition ), stmts( statements ), _isDefault( deflt ) {203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) : 204 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { 205 205 if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition); 206 206 } … … 216 216 } 217 217 218 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) { 219 return new CaseStmt( labels, 0, stmts, true ); 218 CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) { 219 CaseStmt * stmt = new CaseStmt( nullptr, stmts, true ); 220 stmt->labels = labels; 221 return stmt; 220 222 } 221 223 … … 233 235 } 234 236 235 WhileStmt::WhileStmt( std::list<Label> labels,Expression *condition, Statement *body, bool isDoWhile ):236 Statement( labels), condition( condition), body( body), isDoWhile( isDoWhile) {237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ): 238 Statement(), condition( condition), body( body), isDoWhile( isDoWhile) { 237 239 } 238 240 … … 255 257 } 256 258 257 ForStmt::ForStmt( std::list< Label> labels, std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):258 Statement( labels), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {259 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ): 260 Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { 259 261 } 260 262 … … 302 304 } 303 305 304 ThrowStmt::ThrowStmt( std::list<Label> labels,Kind kind, Expression * expr, Expression * target ) :305 Statement( labels), kind(kind), expr(expr), target(target) {306 ThrowStmt::ThrowStmt( Kind kind, Expression * expr, Expression * target ) : 307 Statement(), kind(kind), expr(expr), target(target) { 306 308 assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." ); 307 309 } … … 326 328 } 327 329 328 TryStmt::TryStmt( std::list<Label> labels,CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :329 Statement( labels), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) {330 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) : 331 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 330 332 } 331 333 … … 359 361 } 360 362 361 CatchStmt::CatchStmt( std::list<Label> labels,Kind kind, Declaration *decl, Expression *cond, Statement *body ) :362 Statement( labels), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {363 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) : 364 Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 363 365 assertf( decl, "Catch clause must have a declaration." ); 364 366 } … … 391 393 392 394 393 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *block ) : Statement( labels ), block( block ) { 394 assert( labels.empty() ); // finally statement cannot be labeled 395 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) { 395 396 } 396 397 … … 408 409 } 409 410 410 WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels) {411 WaitForStmt::WaitForStmt() : Statement() { 411 412 timeout.time = nullptr; 412 413 timeout.statement = nullptr; … … 455 456 } 456 457 457 NullStmt::NullStmt( std::list<Label> labels ) : Statement( labels ) {}458 NullStmt::NullStmt() : Statement( std::list<Label>() ) {}458 NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) { 459 } 459 460 460 461 void NullStmt::print( std::ostream &os, Indenter ) const { … … 462 463 } 463 464 464 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( std::list<Label>()), callStmt( callStmt ) {465 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement(), callStmt( callStmt ) { 465 466 assert( callStmt ); 466 467 } -
src/SynTree/Statement.h
r4429b04 rba3706f 37 37 std::list<Label> labels; 38 38 39 Statement( std::list<Label> labels);39 Statement( const std::list<Label> & labels = {} ); 40 40 virtual ~Statement(); 41 41 … … 53 53 std::list<Statement*> kids; 54 54 55 CompoundStmt( std::list<Label> labels);55 CompoundStmt(); 56 56 CompoundStmt( std::list<Statement *> stmts ); 57 57 CompoundStmt( const CompoundStmt &other ); … … 70 70 class NullStmt : public Statement { 71 71 public: 72 NullStmt(); 73 NullStmt( std::list<Label> labels ); 72 NullStmt( const std::list<Label> & labels = {} ); 74 73 75 74 virtual NullStmt *clone() const override { return new NullStmt( *this ); } … … 83 82 Expression *expr; 84 83 85 ExprStmt( std::list<Label> labels,Expression *expr );84 ExprStmt( Expression *expr ); 86 85 ExprStmt( const ExprStmt &other ); 87 86 virtual ~ExprStmt(); … … 104 103 std::list<Label> gotolabels; 105 104 106 AsmStmt( std::list<Label> labels,bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );105 AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 107 106 AsmStmt( const AsmStmt &other ); 108 107 virtual ~AsmStmt(); … … 134 133 std::list<Statement *> initialization; 135 134 136 IfStmt( std::list<Label> labels,Expression *condition, Statement *thenPart, Statement *elsePart,135 IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, 137 136 std::list<Statement *> initialization = std::list<Statement *>() ); 138 137 IfStmt( const IfStmt &other ); … … 158 157 std::list<Statement *> statements; 159 158 160 SwitchStmt( std::list<Label> labels,Expression *condition, const std::list<Statement *> &statements );159 SwitchStmt( Expression *condition, const std::list<Statement *> &statements ); 161 160 SwitchStmt( const SwitchStmt &other ); 162 161 virtual ~SwitchStmt(); … … 180 179 std::list<Statement *> stmts; 181 180 182 CaseStmt( std::list<Label> labels,Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);181 CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 183 182 CaseStmt( const CaseStmt &other ); 184 183 virtual ~CaseStmt(); 185 184 186 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );185 static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); 187 186 188 187 bool isDefault() const { return _isDefault; } … … 210 209 bool isDoWhile; 211 210 212 WhileStmt( std::list<Label> labels,Expression *condition,211 WhileStmt( Expression *condition, 213 212 Statement *body, bool isDoWhile = false ); 214 213 WhileStmt( const WhileStmt &other ); … … 235 234 Statement *body; 236 235 237 ForStmt( std::list< Label> labels, std::list<Statement *> initialization,236 ForStmt( std::list<Statement *> initialization, 238 237 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 239 238 ForStmt( const ForStmt &other ); … … 264 263 Type type; 265 264 266 BranchStmt( std::list<Label> labels,Label target, Type ) throw (SemanticError);267 BranchStmt( std::list<Label> labels,Expression *computedTarget, Type ) throw (SemanticError);265 BranchStmt( Label target, Type ) throw (SemanticError); 266 BranchStmt( Expression *computedTarget, Type ) throw (SemanticError); 268 267 269 268 Label get_originalTarget() { return originalTarget; } … … 289 288 Expression *expr; 290 289 291 ReturnStmt( std::list<Label> labels,Expression *expr );290 ReturnStmt( Expression *expr ); 292 291 ReturnStmt( const ReturnStmt &other ); 293 292 virtual ~ReturnStmt(); … … 310 309 Expression * target; 311 310 312 ThrowStmt( std::list<Label> labels,Kind kind, Expression * expr, Expression * target = nullptr );311 ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); 313 312 ThrowStmt( const ThrowStmt &other ); 314 313 virtual ~ThrowStmt(); … … 332 331 FinallyStmt * finallyBlock; 333 332 334 TryStmt( std::list<Label> labels,CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );333 TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 335 334 TryStmt( const TryStmt &other ); 336 335 virtual ~TryStmt(); … … 358 357 Statement *body; 359 358 360 CatchStmt( std::list<Label> labels,Kind kind, Declaration *decl,359 CatchStmt( Kind kind, Declaration *decl, 361 360 Expression *cond, Statement *body ); 362 361 CatchStmt( const CatchStmt &other ); … … 381 380 CompoundStmt *block; 382 381 383 FinallyStmt( std::list<Label> labels,CompoundStmt *block );382 FinallyStmt( CompoundStmt *block ); 384 383 FinallyStmt( const FinallyStmt &other ); 385 384 virtual ~FinallyStmt(); … … 408 407 }; 409 408 410 WaitForStmt( std::list<Label> labels = noLabels);409 WaitForStmt(); 411 410 WaitForStmt( const WaitForStmt & ); 412 411 virtual ~WaitForStmt(); … … 438 437 Declaration *decl; 439 438 440 DeclStmt( std::list<Label> labels,Declaration *decl );439 DeclStmt( Declaration *decl ); 441 440 DeclStmt( const DeclStmt &other ); 442 441 virtual ~DeclStmt(); -
src/SynTree/TupleExpr.cc
r4429b04 rba3706f 23 23 #include "Declaration.h" // for ObjectDecl 24 24 #include "Expression.h" // for Expression, TupleExpr, TupleIndexExpr 25 #include "SynTree/Label.h" // for Label , noLabels25 #include "SynTree/Label.h" // for Label 26 26 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, ExprStmt, Sta... 27 27 #include "Tuples/Tuples.h" // for makeTupleType … … 89 89 // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments 90 90 set_result( Tuples::makeTupleType( assigns ) ); 91 CompoundStmt * compoundStmt = new CompoundStmt( noLabels);91 CompoundStmt * compoundStmt = new CompoundStmt(); 92 92 std::list< Statement * > & stmts = compoundStmt->get_kids(); 93 93 for ( ObjectDecl * obj : tempDecls ) { 94 stmts.push_back( new DeclStmt( noLabels,obj ) );94 stmts.push_back( new DeclStmt( obj ) ); 95 95 } 96 96 TupleExpr * tupleExpr = new TupleExpr( assigns ); 97 97 assert( tupleExpr->get_result() ); 98 stmts.push_back( new ExprStmt( noLabels,tupleExpr ) );98 stmts.push_back( new ExprStmt( tupleExpr ) ); 99 99 stmtExpr = new StmtExpr( compoundStmt ); 100 100 }
Note: See TracChangeset
for help on using the changeset viewer.