Changes in src/SynTree/Statement.cc [68f9c43:cc32d83]
- File:
-
- 1 edited
-
src/SynTree/Statement.cc (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
r68f9c43 rcc32d83 34 34 Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {} 35 35 36 void Statement::print( std::ostream & os, Indenter ) const {36 void Statement::print( std::ostream & os, Indenter indent ) const { 37 37 if ( ! labels.empty() ) { 38 os << "Labels: {";38 os << indent << "... Labels: {"; 39 39 for ( const Label & l : labels ) { 40 40 os << l << ","; … … 44 44 } 45 45 46 Statement::~Statement() {} 47 46 48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} 47 49 48 50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 51 52 ExprStmt::~ExprStmt() { 53 delete expr; 54 } 49 55 50 56 void ExprStmt::print( std::ostream &os, Indenter indent ) const { … … 60 66 cloneAll( other.input, input ); 61 67 cloneAll( other.clobber, clobber ); 68 } 69 70 AsmStmt::~AsmStmt() { 71 delete instruction; 72 deleteAll( output ); 73 deleteAll( input ); 74 deleteAll( clobber ); 62 75 } 63 76 … … 81 94 82 95 96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} 97 98 void DirectiveStmt::print( std::ostream &os, Indenter ) const { 99 os << "GCC Directive:" << directive << endl; 100 } 101 102 83 103 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 84 104 … … 109 129 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 110 130 131 ReturnStmt::~ReturnStmt() { 132 delete expr; 133 } 134 111 135 void ReturnStmt::print( std::ostream &os, Indenter indent ) const { 112 136 os << "Return Statement, returning: "; … … 124 148 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) { 125 149 cloneAll( other.initialization, initialization ); 150 } 151 152 IfStmt::~IfStmt() { 153 deleteAll( initialization ); 154 delete condition; 155 delete thenPart; 156 delete elsePart; 126 157 } 127 158 … … 161 192 } 162 193 194 SwitchStmt::~SwitchStmt() { 195 delete condition; 196 // destroy statements 197 deleteAll( statements ); 198 } 199 163 200 void SwitchStmt::print( std::ostream &os, Indenter indent ) const { 164 201 os << "Switch on condition: "; … … 181 218 } 182 219 220 CaseStmt::~CaseStmt() { 221 delete condition; 222 deleteAll( stmts ); 223 } 224 183 225 CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) { 184 226 CaseStmt * stmt = new CaseStmt( nullptr, stmts, true ); … … 188 230 189 231 void CaseStmt::print( std::ostream &os, Indenter indent ) const { 190 if ( isDefault() ) os << "Default ";232 if ( isDefault() ) os << indent << "Default "; 191 233 else { 192 os << "Case ";234 os << indent << "Case "; 193 235 condition->print( os, indent ); 194 236 } // if … … 196 238 197 239 for ( Statement * stmt : stmts ) { 240 os << indent+1; 198 241 stmt->print( os, indent+1 ); 199 242 } … … 206 249 WhileStmt::WhileStmt( const WhileStmt & other ): 207 250 Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) { 251 } 252 253 WhileStmt::~WhileStmt() { 254 delete body; 255 delete condition; 208 256 } 209 257 … … 225 273 cloneAll( other.initialization, initialization ); 226 274 275 } 276 277 ForStmt::~ForStmt() { 278 deleteAll( initialization ); 279 delete condition; 280 delete increment; 281 delete body; 227 282 } 228 283 … … 264 319 ThrowStmt::ThrowStmt( const ThrowStmt &other ) : 265 320 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 321 } 322 323 ThrowStmt::~ThrowStmt() { 324 delete expr; 325 delete target; 266 326 } 267 327 … … 284 344 } 285 345 346 TryStmt::~TryStmt() { 347 delete block; 348 deleteAll( handlers ); 349 delete finallyBlock; 350 } 351 286 352 void TryStmt::print( std::ostream &os, Indenter indent ) const { 287 353 os << "Try Statement" << endl; … … 312 378 } 313 379 380 CatchStmt::~CatchStmt() { 381 delete decl; 382 delete body; 383 } 384 314 385 void CatchStmt::print( std::ostream &os, Indenter indent ) const { 315 386 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; … … 334 405 335 406 FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) { 407 } 408 409 FinallyStmt::~FinallyStmt() { 410 delete block; 336 411 } 337 412 … … 367 442 } 368 443 444 WaitForStmt::~WaitForStmt() { 445 for( auto & clause : clauses ) { 446 delete clause.target.function; 447 deleteAll( clause.target.arguments ); 448 delete clause.statement; 449 delete clause.condition; 450 } 451 452 delete timeout.time; 453 delete timeout.statement; 454 delete timeout.condition; 455 456 delete orelse.statement; 457 delete orelse.condition; 458 } 459 369 460 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 370 461 os << "Waitfor Statement" << endl; 371 os << indent << "... with block:" << endl << indent+1; 372 // block->print( os, indent + 4 ); 462 indent += 1; 463 for( auto & clause : clauses ) { 464 os << indent << "target function :"; 465 if(clause.target.function) { clause.target.function->print(os, indent + 1); } 466 os << endl << indent << "with arguments :" << endl; 467 for( auto & thing : clause.target.arguments) { 468 if(thing) { thing->print(os, indent + 1); } 469 } 470 os << indent << " with statment :" << endl; 471 if(clause.statement) { clause.statement->print(os, indent + 1); } 472 473 os << indent << " with condition :" << endl; 474 if(clause.condition) { clause.condition->print(os, indent + 1); } 475 } 476 477 os << indent << " timeout of :" << endl; 478 if(timeout.time) { timeout.time->print(os, indent + 1); } 479 480 os << indent << " with statment :" << endl; 481 if(timeout.statement) { timeout.statement->print(os, indent + 1); } 482 483 os << indent << " with condition :" << endl; 484 if(timeout.condition) { timeout.condition->print(os, indent + 1); } 485 486 487 os << indent << " else :" << endl; 488 if(orelse.statement) { orelse.statement->print(os, indent + 1); } 489 490 os << indent << " with condition :" << endl; 491 if(orelse.condition) { orelse.condition->print(os, indent + 1); } 373 492 } 374 493 … … 377 496 WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) { 378 497 cloneAll( other.exprs, exprs ); 498 } 499 WithStmt::~WithStmt() { 500 deleteAll( exprs ); 501 delete stmt; 379 502 } 380 503 … … 391 514 } 392 515 393 void NullStmt::print( std::ostream &os, Indenter ) const {516 void NullStmt::print( std::ostream &os, Indenter indent ) const { 394 517 os << "Null Statement" << endl; 518 Statement::print( os, indent ); 395 519 } 396 520 … … 400 524 401 525 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ) : Statement( other ), callStmt( maybeClone( other.callStmt ) ) { 526 } 527 528 ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() { 529 delete callStmt; 402 530 } 403 531
Note:
See TracChangeset
for help on using the changeset viewer.