Changeset 3be261a


Ignore:
Timestamp:
Feb 25, 2016, 4:45:19 PM (8 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, string, with_gc
Children:
41a2620
Parents:
6ce67ce
Message:

added copy constructors and destructors to many types that were missing them

Location:
src/SynTree
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r6ce67ce r3be261a  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Expression.cc -- 
     7// Expression.cc --
    88//
    99// Author           : Richard C. Bilson
     
    422422}
    423423
     424AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     425
     426
    424427void AsmExpr::print( std::ostream &os, int indent ) const {
    425428        os << "Asm Expression: " << std::endl;
     
    429432}
    430433
     434UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
     435
     436UntypedValofExpr::~UntypedValofExpr() { delete body; }
     437
    431438void UntypedValofExpr::print( std::ostream &os, int indent ) const {
    432439        os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
     
    434441                get_body()->print( os, indent + 2 );
    435442}
     443
     444
    436445
    437446std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    r6ce67ce r3be261a  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Expression.h -- 
     7// Expression.h --
    88//
    99// Author           : Richard C. Bilson
     
    155155};
    156156
     157// xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack
    157158class LabelAddressExpr : public Expression {
    158159  public:
    159160        LabelAddressExpr( Expression *arg );
    160         LabelAddressExpr( const AddressExpr &other );
     161        LabelAddressExpr( const LabelAddressExpr &other );
    161162        virtual ~LabelAddressExpr();
    162163
     
    251252};
    252253
    253 /// ConstantExpr represents an expression that simply refers to the value of a constant 
     254/// ConstantExpr represents an expression that simply refers to the value of a constant
    254255class ConstantExpr : public Expression {
    255256  public:
     
    515516  public:
    516517        AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
     518        AsmExpr( const AsmExpr & other );
    517519        virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    518520
     
    541543  public:
    542544        UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {}
    543         virtual ~UntypedValofExpr() {}
     545        UntypedValofExpr( const UntypedValofExpr & other );
     546        virtual ~UntypedValofExpr();
    544547
    545548        Expression *get_value();
  • src/SynTree/Statement.cc

    r6ce67ce r3be261a  
    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 {
  • src/SynTree/Statement.h

    r6ce67ce r3be261a  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Statement.h -- 
     7// Statement.h --
    88//
    99// Author           : Richard C. Bilson
     
    5757  public:
    5858        ExprStmt( std::list<Label> labels, Expression *expr );
     59        ExprStmt( const ExprStmt &other );
    5960        virtual ~ExprStmt();
    6061
     
    7374  public:
    7475        AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
     76        AsmStmt( const AsmStmt &other );
    7577        virtual ~AsmStmt();
    7678
     
    103105  public:
    104106        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
     107        IfStmt( const IfStmt &other );
    105108        virtual ~IfStmt();
    106109
     
    111114        Statement *get_elsePart() { return elsePart; }
    112115        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    113        
     116
    114117        virtual IfStmt *clone() const { return new IfStmt( *this ); }
    115118        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    125128  public:
    126129        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     130        SwitchStmt( const SwitchStmt &other );
    127131        virtual ~SwitchStmt();
    128132
     
    146150  public:
    147151        ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     152        ChooseStmt( const ChooseStmt &other );
    148153        virtual ~ChooseStmt();
    149154
     
    177182class CaseStmt : public Statement {
    178183  public:
    179         CaseStmt( std::list<Label> labels, Expression *conditions, 
     184        CaseStmt( std::list<Label> labels, Expression *conditions,
    180185              std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     186        CaseStmt( const CaseStmt &other );
    181187        virtual ~CaseStmt();
    182188
     
    192198        std::list<Statement *> &get_statements() { return stmts; }
    193199        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    194        
     200
    195201        virtual void accept( Visitor &v ) { v.visit( this ); }
    196202        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    208214        WhileStmt( std::list<Label> labels, Expression *condition,
    209215               Statement *body, bool isDoWhile = false );
     216        WhileStmt( const WhileStmt &other );
    210217        virtual ~WhileStmt();
    211218
     
    216223        bool get_isDoWhile() { return isDoWhile; }
    217224        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    218        
     225
    219226        virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    220227        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    231238        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    232239             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     240        ForStmt( const ForStmt &other );
    233241        virtual ~ForStmt();
    234242
     
    241249        Statement *get_body() { return body; }
    242250        void set_body( Statement *newValue ) { body = newValue; }
    243        
     251
    244252        virtual ForStmt *clone() const { return new ForStmt( *this ); }
    245253        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    259267        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    260268        BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
    261         virtual ~BranchStmt() {}
    262269
    263270        Label get_originalTarget() { return originalTarget; }
    264271        Label get_target() { return target; }
    265272        void set_target( Label newValue ) { target = newValue; }
    266        
     273
    267274        Expression *get_computedTarget() { return computedTarget; }
    268275        void set_target( Expression * newValue ) { computedTarget = newValue; }
     
    286293  public:
    287294        ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
     295        ReturnStmt( const ReturnStmt &other );
    288296        virtual ~ReturnStmt();
    289297
    290298        Expression *get_expr() { return expr; }
    291299        void set_expr( Expression *newValue ) { expr = newValue; }
    292        
     300
    293301        virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    294302        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    305313        NullStmt();
    306314        NullStmt( std::list<Label> labels );
    307         virtual ~NullStmt();
    308315
    309316        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     
    311318        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    312319        virtual void print( std::ostream &os, int indent = 0 ) const;
    313        
    314   private:
    315 };
    316 
    317 class TryStmt : public Statement { 
     320
     321  private:
     322};
     323
     324class TryStmt : public Statement {
    318325  public:
    319326        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     
    332339        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    333340        virtual void print( std::ostream &os, int indent = 0 ) const;
    334        
     341
    335342  private:
    336343        CompoundStmt *block;
    337344        std::list<Statement *> handlers;
    338345        FinallyStmt *finallyBlock;
    339 }; 
     346};
    340347
    341348class CatchStmt : public Statement {
    342349  public:
    343350        CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
     351        CatchStmt( const CatchStmt &other );
    344352        virtual ~CatchStmt();
    345353
     
    349357        Statement *get_body() { return body; }
    350358        void set_body( Statement *newValue ) { body = newValue; }
    351        
     359
    352360        virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    353361        virtual void accept( Visitor &v ) { v.visit( this ); }
    354362        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    355363        virtual void print( std::ostream &os, int indent = 0 ) const;
    356        
     364
    357365  private:
    358366        Declaration *decl;
     
    361369};
    362370
    363 class FinallyStmt : public Statement { 
     371class FinallyStmt : public Statement {
    364372  public:
    365373        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
     374        FinallyStmt( const FinallyStmt &other );
    366375        virtual ~FinallyStmt();
    367376
    368377        CompoundStmt *get_block() const { return block; }
    369378        void set_block( CompoundStmt *newValue ) { block = newValue; }
    370        
     379
    371380        virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    372381        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    375384  private:
    376385        CompoundStmt *block;
    377 }; 
     386};
    378387
    379388
Note: See TracChangeset for help on using the changeset viewer.