Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    rcc32d83 r68f9c43  
    3434Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
    3535
    36 void Statement::print( std::ostream & os, Indenter indent ) const {
     36void Statement::print( std::ostream & os, Indenter ) const {
    3737        if ( ! labels.empty() ) {
    38                 os << indent << "... Labels: {";
     38                os << "Labels: {";
    3939                for ( const Label & l : labels ) {
    4040                        os << l << ",";
     
    4444}
    4545
    46 Statement::~Statement() {}
    47 
    4846ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}
    4947
    5048ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    51 
    52 ExprStmt::~ExprStmt() {
    53         delete expr;
    54 }
    5549
    5650void ExprStmt::print( std::ostream &os, Indenter indent ) const {
     
    6660  cloneAll( other.input, input );
    6761  cloneAll( other.clobber, clobber );
    68 }
    69 
    70 AsmStmt::~AsmStmt() {
    71         delete instruction;
    72         deleteAll( output );
    73         deleteAll( input );
    74         deleteAll( clobber );
    7562}
    7663
     
    9481
    9582
    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 
    10383const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    10484
     
    129109ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    130110
    131 ReturnStmt::~ReturnStmt() {
    132         delete expr;
    133 }
    134 
    135111void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
    136112        os << "Return Statement, returning: ";
     
    148124        Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {
    149125        cloneAll( other.initialization, initialization );
    150 }
    151 
    152 IfStmt::~IfStmt() {
    153         deleteAll( initialization );
    154         delete condition;
    155         delete thenPart;
    156         delete elsePart;
    157126}
    158127
     
    192161}
    193162
    194 SwitchStmt::~SwitchStmt() {
    195         delete condition;
    196         // destroy statements
    197         deleteAll( statements );
    198 }
    199 
    200163void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
    201164        os << "Switch on condition: ";
     
    216179        Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
    217180        cloneAll( other.stmts, stmts );
    218 }
    219 
    220 CaseStmt::~CaseStmt() {
    221         delete condition;
    222         deleteAll( stmts );
    223181}
    224182
     
    230188
    231189void CaseStmt::print( std::ostream &os, Indenter indent ) const {
    232         if ( isDefault() ) os << indent << "Default ";
     190        if ( isDefault() ) os << "Default ";
    233191        else {
    234                 os << indent << "Case ";
     192                os << "Case ";
    235193                condition->print( os, indent );
    236194        } // if
     
    238196
    239197        for ( Statement * stmt : stmts ) {
    240                 os << indent+1;
    241198                stmt->print( os, indent+1 );
    242199        }
     
    249206WhileStmt::WhileStmt( const WhileStmt & other ):
    250207        Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) {
    251 }
    252 
    253 WhileStmt::~WhileStmt() {
    254         delete body;
    255         delete condition;
    256208}
    257209
     
    273225                cloneAll( other.initialization, initialization );
    274226
    275 }
    276 
    277 ForStmt::~ForStmt() {
    278         deleteAll( initialization );
    279         delete condition;
    280         delete increment;
    281         delete body;
    282227}
    283228
     
    319264ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
    320265        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    321 }
    322 
    323 ThrowStmt::~ThrowStmt() {
    324         delete expr;
    325         delete target;
    326266}
    327267
     
    344284}
    345285
    346 TryStmt::~TryStmt() {
    347         delete block;
    348         deleteAll( handlers );
    349         delete finallyBlock;
    350 }
    351 
    352286void TryStmt::print( std::ostream &os, Indenter indent ) const {
    353287        os << "Try Statement" << endl;
     
    378312}
    379313
    380 CatchStmt::~CatchStmt() {
    381         delete decl;
    382         delete body;
    383 }
    384 
    385314void CatchStmt::print( std::ostream &os, Indenter indent ) const {
    386315        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
     
    405334
    406335FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {
    407 }
    408 
    409 FinallyStmt::~FinallyStmt() {
    410         delete block;
    411336}
    412337
     
    442367}
    443368
    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 
    460369void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
    461370        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 );
    492373}
    493374
     
    496377WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) {
    497378        cloneAll( other.exprs, exprs );
    498 }
    499 WithStmt::~WithStmt() {
    500         deleteAll( exprs );
    501         delete stmt;
    502379}
    503380
     
    514391}
    515392
    516 void NullStmt::print( std::ostream &os, Indenter indent ) const {
     393void NullStmt::print( std::ostream &os, Indenter ) const {
    517394        os << "Null Statement" << endl;
    518         Statement::print( os, indent );
    519395}
    520396
     
    524400
    525401ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ) : Statement( other ), callStmt( maybeClone( other.callStmt ) ) {
    526 }
    527 
    528 ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() {
    529         delete callStmt;
    530402}
    531403
Note: See TracChangeset for help on using the changeset viewer.