Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.h

    r7f5566b r8688ce1  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Statement.h -- 
     7// Statement.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 25 18:25:37 2015
    13 // Update Count     : 44
     12// Last Modified On : Thu Aug  4 11:26:02 2016
     13// Update Count     : 64
    1414//
    1515
     
    2121#include "Mutator.h"
    2222#include "Common/SemanticError.h"
     23#include "Type.h"
     24#include "Label.h"
    2325
    2426class Statement {
     
    5759  public:
    5860        ExprStmt( std::list<Label> labels, Expression *expr );
     61        ExprStmt( const ExprStmt &other );
    5962        virtual ~ExprStmt();
    6063
     
    7376  public:
    7477        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 );
     78        AsmStmt( const AsmStmt &other );
    7579        virtual ~AsmStmt();
    7680
     
    103107  public:
    104108        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
     109        IfStmt( const IfStmt &other );
    105110        virtual ~IfStmt();
    106111
     
    111116        Statement *get_elsePart() { return elsePart; }
    112117        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    113        
     118
    114119        virtual IfStmt *clone() const { return new IfStmt( *this ); }
    115120        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    124129class SwitchStmt : public Statement {
    125130  public:
    126         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     131        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
     132        SwitchStmt( const SwitchStmt &other );
    127133        virtual ~SwitchStmt();
    128134
     
    130136        void set_condition( Expression *newValue ) { condition = newValue; }
    131137
    132         std::list<Statement *> & get_branches() { return branches; }
    133         void add_case( CaseStmt * );
     138        std::list<Statement *> & get_statements() { return statements; }
    134139
    135140        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    140145  private:
    141146        Expression * condition;
    142         std::list<Statement *> branches; // should be list of CaseStmt
    143 };
    144 
    145 class ChooseStmt : public Statement {
    146   public:
    147         ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
    148         virtual ~ChooseStmt();
    149 
    150         Expression *get_condition() { return condition; }
    151         void set_condition( Expression *newValue ) { condition = newValue; }
    152 
    153         std::list<Statement *>& get_branches() { return branches; }
    154         void add_case( CaseStmt * );
    155 
    156         virtual void accept( Visitor &v ) { v.visit( this ); }
    157         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    158 
    159         virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); }
    160         virtual void print( std::ostream &os, int indent = 0 ) const;
    161   private:
    162         Expression *condition;
    163         std::list<Statement *> branches; // should be list of CaseStmt
    164 };
    165 
    166 class FallthruStmt : public Statement {
    167   public:
    168         FallthruStmt( std::list<Label> labels ) : Statement( labels ) { }
    169 
    170         virtual void accept( Visitor &v ) { v.visit( this ); }
    171         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    172 
    173         virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); }
    174         virtual void print( std::ostream &os, int indent = 0 ) const;
     147        std::list<Statement *> statements;
    175148};
    176149
    177150class CaseStmt : public Statement {
    178151  public:
    179         CaseStmt( std::list<Label> labels, Expression *conditions,
    180               std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     152        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     153        CaseStmt( const CaseStmt &other );
    181154        virtual ~CaseStmt();
    182155
    183         static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(),
    184                 std::list<Statement *> stmts = std::list<Statement *>() );
     156        static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );
    185157
    186158        bool isDefault() const { return _isDefault; }
     
    192164        std::list<Statement *> &get_statements() { return stmts; }
    193165        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    194        
     166
    195167        virtual void accept( Visitor &v ) { v.visit( this ); }
    196168        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    208180        WhileStmt( std::list<Label> labels, Expression *condition,
    209181               Statement *body, bool isDoWhile = false );
     182        WhileStmt( const WhileStmt &other );
    210183        virtual ~WhileStmt();
    211184
     
    216189        bool get_isDoWhile() { return isDoWhile; }
    217190        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    218        
     191
    219192        virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    220193        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    231204        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    232205             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     206        ForStmt( const ForStmt &other );
    233207        virtual ~ForStmt();
    234208
     
    241215        Statement *get_body() { return body; }
    242216        void set_body( Statement *newValue ) { body = newValue; }
    243        
     217
    244218        virtual ForStmt *clone() const { return new ForStmt( *this ); }
    245219        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    259233        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    260234        BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
    261         virtual ~BranchStmt() {}
    262235
    263236        Label get_originalTarget() { return originalTarget; }
    264237        Label get_target() { return target; }
    265238        void set_target( Label newValue ) { target = newValue; }
    266        
     239
    267240        Expression *get_computedTarget() { return computedTarget; }
    268241        void set_target( Expression * newValue ) { computedTarget = newValue; }
     
    286259  public:
    287260        ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
     261        ReturnStmt( const ReturnStmt &other );
    288262        virtual ~ReturnStmt();
    289263
    290264        Expression *get_expr() { return expr; }
    291265        void set_expr( Expression *newValue ) { expr = newValue; }
    292        
     266
    293267        virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    294268        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    305279        NullStmt();
    306280        NullStmt( std::list<Label> labels );
    307         virtual ~NullStmt();
    308281
    309282        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     
    311284        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    312285        virtual void print( std::ostream &os, int indent = 0 ) const;
    313        
    314   private:
    315 };
    316 
    317 class TryStmt : public Statement { 
     286
     287  private:
     288};
     289
     290class TryStmt : public Statement {
    318291  public:
    319292        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     
    332305        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    333306        virtual void print( std::ostream &os, int indent = 0 ) const;
    334        
     307
    335308  private:
    336309        CompoundStmt *block;
    337310        std::list<Statement *> handlers;
    338311        FinallyStmt *finallyBlock;
    339 }; 
     312};
    340313
    341314class CatchStmt : public Statement {
    342315  public:
    343316        CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
     317        CatchStmt( const CatchStmt &other );
    344318        virtual ~CatchStmt();
    345319
     
    349323        Statement *get_body() { return body; }
    350324        void set_body( Statement *newValue ) { body = newValue; }
    351        
     325
    352326        virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    353327        virtual void accept( Visitor &v ) { v.visit( this ); }
    354328        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    355329        virtual void print( std::ostream &os, int indent = 0 ) const;
    356        
     330
    357331  private:
    358332        Declaration *decl;
     
    361335};
    362336
    363 class FinallyStmt : public Statement { 
     337class FinallyStmt : public Statement {
    364338  public:
    365339        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
     340        FinallyStmt( const FinallyStmt &other );
    366341        virtual ~FinallyStmt();
    367342
    368343        CompoundStmt *get_block() const { return block; }
    369344        void set_block( CompoundStmt *newValue ) { block = newValue; }
    370        
     345
    371346        virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    372347        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    375350  private:
    376351        CompoundStmt *block;
    377 }; 
     352};
    378353
    379354
     
    385360        virtual ~DeclStmt();
    386361
    387         Declaration *get_decl() { return decl; }
     362        Declaration *get_decl() const { return decl; }
    388363        void set_decl( Declaration *newValue ) { decl = newValue; }
    389364
     
    395370        Declaration *decl;
    396371};
     372
     373
     374/// represents an implicit application of a constructor or destructor. Qualifiers are replaced
     375/// immediately before and after the call so that qualified objects can be constructed
     376/// with the same functions as unqualified objects.
     377class ImplicitCtorDtorStmt : public Statement {
     378  public:
     379        ImplicitCtorDtorStmt( Statement * callStmt );
     380        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
     381        virtual ~ImplicitCtorDtorStmt();
     382
     383        Statement *get_callStmt() const { return callStmt; }
     384        void set_callStmt( Statement * newValue ) { callStmt = newValue; }
     385
     386        virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); }
     387        virtual void accept( Visitor &v ) { v.visit( this ); }
     388        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     389        virtual void print( std::ostream &os, int indent = 0 ) const;
     390
     391  private:
     392        // Non-owned pointer to the constructor/destructor statement
     393        Statement * callStmt;
     394};
     395
     396
     397std::ostream & operator<<( std::ostream & out, Statement * statement );
    397398
    398399#endif // STATEMENT_H
Note: See TracChangeset for help on using the changeset viewer.