Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    r3be261a rbaf7fee  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Statement.cc --
     7// Statement.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    3636ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ) : Statement( _labels ), expr( _expr ) {}
    3737
    38 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    39 
    40 ExprStmt::~ExprStmt() {
    41         delete expr;
    42 }
     38ExprStmt::~ExprStmt() {}
    4339
    4440void ExprStmt::print( std::ostream &os, int indent ) const {
    4541        os << string( indent, ' ' ) << "Expression Statement:" << endl;
    4642        expr->print( os, indent + 2 );
    47 }
     43} 
    4844
    4945
    5046AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *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 ) {}
    51 
    52 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) {
    53   cloneAll( other.output, output );
    54   cloneAll( other.input, input );
    55   cloneAll( other.clobber, clobber );
    56 }
    5747
    5848AsmStmt::~AsmStmt() {
     
    7060                os << endl << std::string( indent, ' ' ) << "output: " << endl;
    7161                printAll( output, os, indent + 2 );
    72         } // if
     62        } // if 
    7363        if ( ! input.empty() ) {
    7464                os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' );
     
    7969                printAll( clobber, os, indent + 2 );
    8070        } // if
    81 }
     71} 
    8272
    8373
     
    10393ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {}
    10494
    105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}
    106 
    10795ReturnStmt::~ReturnStmt() {
    10896        delete expr;
     
    118106        Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {}
    119107
    120 IfStmt::IfStmt( const IfStmt & other ) :
    121         Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {}
    122 
    123108IfStmt::~IfStmt() {}
    124109
     
    138123SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ):
    139124        Statement( _labels ), condition( _condition ), branches( _branches ) {
    140 }
    141 
    142 SwitchStmt::SwitchStmt( const SwitchStmt & other ):
    143         Statement( other ), condition( maybeClone( other.condition ) ) {
    144         cloneAll( other.branches, branches );
    145125}
    146126
     
    165145}
    166146
    167 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) :
     147CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 
    168148        Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) {
    169149        if ( isDefault() && condition != 0 )
    170150                throw SemanticError("default with conditions");
    171 }
    172 
    173 CaseStmt::CaseStmt( const CaseStmt & other ) :
    174         Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
    175         cloneAll( other.stmts, stmts );
    176151}
    177152
     
    206181}
    207182
    208 ChooseStmt::ChooseStmt( const ChooseStmt & other ):
    209         Statement( other ), condition( maybeClone( other.condition ) ) {
    210                 cloneAll( other.branches, branches );
    211 }
    212 
    213183ChooseStmt::~ChooseStmt() {
    214184        delete condition;
     
    238208}
    239209
    240 WhileStmt::WhileStmt( const WhileStmt & other ):
    241         Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) {
    242 }
    243 
    244210WhileStmt::~WhileStmt() {
    245211        delete body;
     
    257223ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ):
    258224        Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) {
    259 }
    260 
    261 ForStmt::ForStmt( const ForStmt & other ):
    262         Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ) {
    263                 cloneAll( other.initialization, initialization );
    264 
    265225}
    266226
     
    281241        os << string( indent, ' ' ) << "For Statement" << endl ;
    282242
    283         os << string( indent + 2, ' ' ) << "initialization: \n";
     243        os << string( indent + 2, ' ' ) << "initialization: \n"; 
    284244        for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) {
    285245                (*it)->print( os, indent + 4 );
    286246        }
    287247
    288         os << "\n" << string( indent + 2, ' ' ) << "condition: \n";
     248        os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 
    289249        if ( condition != 0 )
    290250                condition->print( os, indent + 4 );
    291251
    292         os << "\n" << string( indent + 2, ' ' ) << "increment: \n";
     252        os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 
    293253        if ( increment != 0 )
    294254                increment->print( os, indent + 4 );
    295255
    296         os << "\n" << string( indent + 2, ' ' ) << "statement block: \n";
     256        os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 
    297257        if ( body != 0 )
    298258                body->print( os, indent + 4 );
     
    305265}
    306266
    307 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
    308         cloneAll( other.handlers, handlers );
     267TryStmt::TryStmt( const TryStmt &other ) : Statement( other.labels ) {
     268        block = other.block;
     269        std::copy( other.handlers.begin(), other.handlers.end(), back_inserter( handlers ) );
     270        finallyBlock = other.finallyBlock;
    309271}
    310272
     
    332294CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) :
    333295        Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest ) {
    334 }
    335 
    336 CatchStmt::CatchStmt( const CatchStmt & other ) :
    337         Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
    338296}
    339297
     
    361319}
    362320
    363 FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {
    364 }
    365 
    366321FinallyStmt::~FinallyStmt() {
    367322        delete block;
     
    376331NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
    377332NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
     333NullStmt::~NullStmt() {}
    378334
    379335void NullStmt::print( std::ostream &os, int indent ) const {
Note: See TracChangeset for help on using the changeset viewer.