Ignore:
Timestamp:
Feb 25, 2016, 5:16:15 PM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
071a31a
Parents:
a9a259c (diff), ac1ed49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ctor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    ra9a259c rc14cff1  
    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() {}
     38ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     39
     40ExprStmt::~ExprStmt() {
     41        delete expr;
     42}
    3943
    4044void ExprStmt::print( std::ostream &os, int indent ) const {
    4145        os << string( indent, ' ' ) << "Expression Statement:" << endl;
    4246        expr->print( os, indent + 2 );
    43 } 
     47}
    4448
    4549
    4650AsmStmt::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
     52AsmStmt::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}
    4757
    4858AsmStmt::~AsmStmt() {
     
    6070                os << endl << std::string( indent, ' ' ) << "output: " << endl;
    6171                printAll( output, os, indent + 2 );
    62         } // if 
     72        } // if
    6373        if ( ! input.empty() ) {
    6474                os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' );
     
    6979                printAll( clobber, os, indent + 2 );
    7080        } // if
    71 } 
     81}
    7282
    7383
     
    93103ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {}
    94104
     105ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}
     106
    95107ReturnStmt::~ReturnStmt() {
    96108        delete expr;
     
    106118        Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {}
    107119
     120IfStmt::IfStmt( const IfStmt & other ) :
     121        Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {}
     122
    108123IfStmt::~IfStmt() {}
    109124
     
    123138SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ):
    124139        Statement( _labels ), condition( _condition ), branches( _branches ) {
     140}
     141
     142SwitchStmt::SwitchStmt( const SwitchStmt & other ):
     143        Statement( other ), condition( maybeClone( other.condition ) ) {
     144        cloneAll( other.branches, branches );
    125145}
    126146
     
    145165}
    146166
    147 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 
     167CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) :
    148168        Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) {
    149169        if ( isDefault() && condition != 0 )
    150170                throw SemanticError("default with conditions");
     171}
     172
     173CaseStmt::CaseStmt( const CaseStmt & other ) :
     174        Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
     175        cloneAll( other.stmts, stmts );
    151176}
    152177
     
    181206}
    182207
     208ChooseStmt::ChooseStmt( const ChooseStmt & other ):
     209        Statement( other ), condition( maybeClone( other.condition ) ) {
     210                cloneAll( other.branches, branches );
     211}
     212
    183213ChooseStmt::~ChooseStmt() {
    184214        delete condition;
     
    208238}
    209239
     240WhileStmt::WhileStmt( const WhileStmt & other ):
     241        Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) {
     242}
     243
    210244WhileStmt::~WhileStmt() {
    211245        delete body;
     
    223257ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ):
    224258        Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) {
     259}
     260
     261ForStmt::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
    225265}
    226266
     
    241281        os << string( indent, ' ' ) << "For Statement" << endl ;
    242282
    243         os << string( indent + 2, ' ' ) << "initialization: \n"; 
     283        os << string( indent + 2, ' ' ) << "initialization: \n";
    244284        for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) {
    245285                (*it)->print( os, indent + 4 );
    246286        }
    247287
    248         os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 
     288        os << "\n" << string( indent + 2, ' ' ) << "condition: \n";
    249289        if ( condition != 0 )
    250290                condition->print( os, indent + 4 );
    251291
    252         os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 
     292        os << "\n" << string( indent + 2, ' ' ) << "increment: \n";
    253293        if ( increment != 0 )
    254294                increment->print( os, indent + 4 );
    255295
    256         os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 
     296        os << "\n" << string( indent + 2, ' ' ) << "statement block: \n";
    257297        if ( body != 0 )
    258298                body->print( os, indent + 4 );
     
    265305}
    266306
    267 TryStmt::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;
     307TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
     308        cloneAll( other.handlers, handlers );
    271309}
    272310
     
    294332CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) :
    295333        Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest ) {
     334}
     335
     336CatchStmt::CatchStmt( const CatchStmt & other ) :
     337        Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
    296338}
    297339
     
    319361}
    320362
     363FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {
     364}
     365
    321366FinallyStmt::~FinallyStmt() {
    322367        delete block;
     
    331376NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
    332377NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
    333 NullStmt::~NullStmt() {}
    334378
    335379void NullStmt::print( std::ostream &os, int indent ) const {
Note: See TracChangeset for help on using the changeset viewer.