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