Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.h

    r8688ce1 r7f5566b  
    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 : Thu Aug  4 11:26:02 2016
    13 // Update Count     : 64
     12// Last Modified On : Sat Jul 25 18:25:37 2015
     13// Update Count     : 44
    1414//
    1515
     
    2121#include "Mutator.h"
    2222#include "Common/SemanticError.h"
    23 #include "Type.h"
    24 #include "Label.h"
    2523
    2624class Statement {
     
    5957  public:
    6058        ExprStmt( std::list<Label> labels, Expression *expr );
    61         ExprStmt( const ExprStmt &other );
    6259        virtual ~ExprStmt();
    6360
     
    7673  public:
    7774        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 );
    7975        virtual ~AsmStmt();
    8076
     
    107103  public:
    108104        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
    109         IfStmt( const IfStmt &other );
    110105        virtual ~IfStmt();
    111106
     
    116111        Statement *get_elsePart() { return elsePart; }
    117112        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    118 
     113       
    119114        virtual IfStmt *clone() const { return new IfStmt( *this ); }
    120115        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    129124class SwitchStmt : public Statement {
    130125  public:
    131         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    132         SwitchStmt( const SwitchStmt &other );
     126        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
    133127        virtual ~SwitchStmt();
    134128
     
    136130        void set_condition( Expression *newValue ) { condition = newValue; }
    137131
    138         std::list<Statement *> & get_statements() { return statements; }
     132        std::list<Statement *> & get_branches() { return branches; }
     133        void add_case( CaseStmt * );
    139134
    140135        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    145140  private:
    146141        Expression * condition;
    147         std::list<Statement *> statements;
     142        std::list<Statement *> branches; // should be list of CaseStmt
     143};
     144
     145class 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
     166class 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;
    148175};
    149176
    150177class CaseStmt : public Statement {
    151178  public:
    152         CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    153         CaseStmt( const CaseStmt &other );
     179        CaseStmt( std::list<Label> labels, Expression *conditions,
     180              std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    154181        virtual ~CaseStmt();
    155182
    156         static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );
     183        static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(),
     184                std::list<Statement *> stmts = std::list<Statement *>() );
    157185
    158186        bool isDefault() const { return _isDefault; }
     
    164192        std::list<Statement *> &get_statements() { return stmts; }
    165193        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    166 
     194       
    167195        virtual void accept( Visitor &v ) { v.visit( this ); }
    168196        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    180208        WhileStmt( std::list<Label> labels, Expression *condition,
    181209               Statement *body, bool isDoWhile = false );
    182         WhileStmt( const WhileStmt &other );
    183210        virtual ~WhileStmt();
    184211
     
    189216        bool get_isDoWhile() { return isDoWhile; }
    190217        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    191 
     218       
    192219        virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    193220        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    204231        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    205232             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
    206         ForStmt( const ForStmt &other );
    207233        virtual ~ForStmt();
    208234
     
    215241        Statement *get_body() { return body; }
    216242        void set_body( Statement *newValue ) { body = newValue; }
    217 
     243       
    218244        virtual ForStmt *clone() const { return new ForStmt( *this ); }
    219245        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    233259        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    234260        BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
     261        virtual ~BranchStmt() {}
    235262
    236263        Label get_originalTarget() { return originalTarget; }
    237264        Label get_target() { return target; }
    238265        void set_target( Label newValue ) { target = newValue; }
    239 
     266       
    240267        Expression *get_computedTarget() { return computedTarget; }
    241268        void set_target( Expression * newValue ) { computedTarget = newValue; }
     
    259286  public:
    260287        ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
    261         ReturnStmt( const ReturnStmt &other );
    262288        virtual ~ReturnStmt();
    263289
    264290        Expression *get_expr() { return expr; }
    265291        void set_expr( Expression *newValue ) { expr = newValue; }
    266 
     292       
    267293        virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    268294        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    279305        NullStmt();
    280306        NullStmt( std::list<Label> labels );
     307        virtual ~NullStmt();
    281308
    282309        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     
    284311        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    285312        virtual void print( std::ostream &os, int indent = 0 ) const;
    286 
    287   private:
    288 };
    289 
    290 class TryStmt : public Statement {
     313       
     314  private:
     315};
     316
     317class TryStmt : public Statement { 
    291318  public:
    292319        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     
    305332        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    306333        virtual void print( std::ostream &os, int indent = 0 ) const;
    307 
     334       
    308335  private:
    309336        CompoundStmt *block;
    310337        std::list<Statement *> handlers;
    311338        FinallyStmt *finallyBlock;
    312 };
     339}; 
    313340
    314341class CatchStmt : public Statement {
    315342  public:
    316343        CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
    317         CatchStmt( const CatchStmt &other );
    318344        virtual ~CatchStmt();
    319345
     
    323349        Statement *get_body() { return body; }
    324350        void set_body( Statement *newValue ) { body = newValue; }
    325 
     351       
    326352        virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    327353        virtual void accept( Visitor &v ) { v.visit( this ); }
    328354        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    329355        virtual void print( std::ostream &os, int indent = 0 ) const;
    330 
     356       
    331357  private:
    332358        Declaration *decl;
     
    335361};
    336362
    337 class FinallyStmt : public Statement {
     363class FinallyStmt : public Statement { 
    338364  public:
    339365        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
    340         FinallyStmt( const FinallyStmt &other );
    341366        virtual ~FinallyStmt();
    342367
    343368        CompoundStmt *get_block() const { return block; }
    344369        void set_block( CompoundStmt *newValue ) { block = newValue; }
    345 
     370       
    346371        virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    347372        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    350375  private:
    351376        CompoundStmt *block;
    352 };
     377}; 
    353378
    354379
     
    360385        virtual ~DeclStmt();
    361386
    362         Declaration *get_decl() const { return decl; }
     387        Declaration *get_decl() { return decl; }
    363388        void set_decl( Declaration *newValue ) { decl = newValue; }
    364389
     
    370395        Declaration *decl;
    371396};
    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.
    377 class 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 
    397 std::ostream & operator<<( std::ostream & out, Statement * statement );
    398397
    399398#endif // STATEMENT_H
Note: See TracChangeset for help on using the changeset viewer.