Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.h

    r70d826cd r50377a4  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 17 15:37:53 2017
    13 // Update Count     : 72
     12// Last Modified On : Sun Sep  3 20:46:46 2017
     13// Update Count     : 77
    1414//
    1515
     
    4343        const std::list<Label> & get_labels() const { return labels; }
    4444
    45         virtual Statement *clone() const = 0;
    46         virtual void accept( Visitor &v ) = 0;
    47         virtual Statement *acceptMutator( Mutator &m ) = 0;
    48         virtual void print( std::ostream &os, int indent = 0 ) const;
     45        virtual Statement *clone() const override = 0;
     46        virtual void accept( Visitor &v ) override = 0;
     47        virtual Statement *acceptMutator( Mutator &m ) override = 0;
     48        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    4949};
    5050
     
    5454
    5555        CompoundStmt( std::list<Label> labels );
     56        CompoundStmt( std::list<Statement *> stmts );
    5657        CompoundStmt( const CompoundStmt &other );
    5758        virtual ~CompoundStmt();
     
    6162        void push_front( Statement * stmt ) { kids.push_front( stmt ); }
    6263
    63         virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
    64         virtual void accept( Visitor &v ) { v.visit( this ); }
    65         virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    66         virtual void print( std::ostream &os, int indent = 0 ) const;
     64        virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); }
     65        virtual void accept( Visitor &v ) override { v.visit( this ); }
     66        virtual CompoundStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     67        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    6768};
    6869
     
    7273        NullStmt( std::list<Label> labels );
    7374
    74         virtual NullStmt *clone() const { return new NullStmt( *this ); }
    75         virtual void accept( Visitor &v ) { v.visit( this ); }
    76         virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    77         virtual void print( std::ostream &os, int indent = 0 ) const;
     75        virtual NullStmt *clone() const override { return new NullStmt( *this ); }
     76        virtual void accept( Visitor &v ) override { v.visit( this ); }
     77        virtual NullStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     78        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    7879};
    7980
     
    8990        void set_expr( Expression *newValue ) { expr = newValue; }
    9091
    91         virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
    92         virtual void accept( Visitor &v ) { v.visit( this ); }
    93         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    94         virtual void print( std::ostream &os, int indent = 0 ) const;
     92        virtual ExprStmt *clone() const override { return new ExprStmt( *this ); }
     93        virtual void accept( Visitor &v ) override { v.visit( this ); }
     94        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     95        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    9596};
    9697
     
    9899  public:
    99100        bool voltile;
    100         ConstantExpr *instruction;
     101        Expression *instruction;
    101102        std::list<Expression *> output, input;
    102103        std::list<ConstantExpr *> clobber;
    103104        std::list<Label> gotolabels;
    104105
    105         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 );
     106        AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    106107        AsmStmt( const AsmStmt &other );
    107108        virtual ~AsmStmt();
     
    109110        bool get_voltile() { return voltile; }
    110111        void set_voltile( bool newValue ) { voltile = newValue; }
    111         ConstantExpr *get_instruction() { return instruction; }
    112         void set_instruction( ConstantExpr *newValue ) { instruction = newValue; }
    113         std::list<Expression *> &get_output() { return output; }
    114         void set_output( const std::list<Expression *> &newValue ) { output = newValue; }
    115         std::list<Expression *> &get_input() { return input; }
     112        Expression * get_instruction() { return instruction; }
     113        void set_instruction( Expression * newValue ) { instruction = newValue; }
     114        std::list<Expression *> & get_output() { return output; }
     115        void set_output( const std::list<Expression *> & newValue ) { output = newValue; }
     116        std::list<Expression *> & get_input() { return input; }
    116117        void set_input( const std::list<Expression *> &newValue ) { input = newValue; }
    117         std::list<ConstantExpr *> &get_clobber() { return clobber; }
     118        std::list<ConstantExpr *> & get_clobber() { return clobber; }
    118119        void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; }
    119         std::list<Label> &get_gotolabels() { return gotolabels; }
     120        std::list<Label> & get_gotolabels() { return gotolabels; }
    120121        void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; }
    121122
    122         virtual AsmStmt *clone() const { return new AsmStmt( *this ); }
    123         virtual void accept( Visitor &v ) { v.visit( this ); }
    124         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    125         virtual void print( std::ostream &os, int indent = 0 ) const;
     123        virtual AsmStmt * clone() const { return new AsmStmt( *this ); }
     124        virtual void accept( Visitor & v ) { v.visit( this ); }
     125        virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     126        virtual void print( std::ostream & os, Indenter indent = {} ) const;
    126127};
    127128
     
    146147        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    147148
    148         virtual IfStmt *clone() const { return new IfStmt( *this ); }
    149         virtual void accept( Visitor &v ) { v.visit( this ); }
    150         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    151         virtual void print( std::ostream &os, int indent = 0 ) const;
     149        virtual IfStmt *clone() const override { return new IfStmt( *this ); }
     150        virtual void accept( Visitor &v ) override { v.visit( this ); }
     151        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     152        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    152153};
    153154
     
    155156  public:
    156157        Expression * condition;
    157 
    158         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
     158        std::list<Statement *> statements;
     159
     160        SwitchStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements );
    159161        SwitchStmt( const SwitchStmt &other );
    160162        virtual ~SwitchStmt();
     
    165167        std::list<Statement *> & get_statements() { return statements; }
    166168
    167         virtual void accept( Visitor &v ) { v.visit( this ); }
    168         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    169 
    170         virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
    171         virtual void print( std::ostream &os, int indent = 0 ) const;
    172   private:
    173         std::list<Statement *> statements;
     169        virtual void accept( Visitor &v ) override { v.visit( this ); }
     170        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     171
     172        virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
     173        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
     174
    174175};
    175176
     
    179180        std::list<Statement *> stmts;
    180181
    181         CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     182        CaseStmt( std::list<Label> labels, Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    182183        CaseStmt( const CaseStmt &other );
    183184        virtual ~CaseStmt();
     
    194195        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    195196
    196         virtual void accept( Visitor &v ) { v.visit( this ); }
    197         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    198 
    199         virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
    200         virtual void print( std::ostream &os, int indent = 0 ) const;
     197        virtual void accept( Visitor &v ) override { v.visit( this ); }
     198        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     199
     200        virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
     201        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    201202  private:
    202203        bool _isDefault;
     
    221222        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    222223
    223         virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    224         virtual void accept( Visitor &v ) { v.visit( this ); }
    225         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    226         virtual void print( std::ostream &os, int indent = 0 ) const;
     224        virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
     225        virtual void accept( Visitor &v ) override { v.visit( this ); }
     226        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     227        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    227228};
    228229
     
    247248        void set_body( Statement *newValue ) { body = newValue; }
    248249
    249         virtual ForStmt *clone() const { return new ForStmt( *this ); }
    250         virtual void accept( Visitor &v ) { v.visit( this ); }
    251         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    252         virtual void print( std::ostream &os, int indent = 0 ) const;
     250        virtual ForStmt *clone() const override { return new ForStmt( *this ); }
     251        virtual void accept( Visitor &v ) override { v.visit( this ); }
     252        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     253        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    253254};
    254255
     
    276277        const char *get_typename() { return brType[ type ]; }
    277278
    278         virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
    279         virtual void accept( Visitor &v ) { v.visit( this ); }
    280         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    281         virtual void print( std::ostream &os, int indent = 0 ) const;
     279        virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
     280        virtual void accept( Visitor &v ) override { v.visit( this ); }
     281        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     282        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    282283  private:
    283284        static const char *brType[];
     
    295296        void set_expr( Expression *newValue ) { expr = newValue; }
    296297
    297         virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    298         virtual void accept( Visitor &v ) { v.visit( this ); }
    299         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    300         virtual void print( std::ostream &os, int indent = 0 ) const;
     298        virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
     299        virtual void accept( Visitor &v ) override { v.visit( this ); }
     300        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     301        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    301302};
    302303
     
    319320        void set_target( Expression * newTarget ) { target = newTarget; }
    320321
    321         virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); }
    322         virtual void accept( Visitor &v ) { v.visit( this ); }
    323         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    324         virtual void print( std::ostream &os, int indent = 0 ) const;
     322        virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
     323        virtual void accept( Visitor &v ) override { v.visit( this ); }
     324        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     325        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    325326};
    326327
    327328class TryStmt : public Statement {
    328329  public:
    329         CompoundStmt *block;
     330        CompoundStmt * block;
    330331        std::list<CatchStmt *> handlers;
    331         FinallyStmt *finallyBlock;
     332        FinallyStmt * finallyBlock;
    332333
    333334        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
     
    342343        void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
    343344
    344         virtual TryStmt *clone() const { return new TryStmt( *this ); }
    345         virtual void accept( Visitor &v ) { v.visit( this ); }
    346         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    347         virtual void print( std::ostream &os, int indent = 0 ) const;
     345        virtual TryStmt *clone() const override { return new TryStmt( *this ); }
     346        virtual void accept( Visitor &v ) override { v.visit( this ); }
     347        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     348        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    348349};
    349350
     
    370371        void set_body( Statement *newValue ) { body = newValue; }
    371372
    372         virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    373         virtual void accept( Visitor &v ) { v.visit( this ); }
    374         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    375         virtual void print( std::ostream &os, int indent = 0 ) const;
     373        virtual CatchStmt *clone() const override { return new CatchStmt( *this ); }
     374        virtual void accept( Visitor &v ) override { v.visit( this ); }
     375        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     376        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    376377};
    377378
     
    387388        void set_block( CompoundStmt *newValue ) { block = newValue; }
    388389
    389         virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    390         virtual void accept( Visitor &v ) { v.visit( this ); }
    391         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    392         virtual void print( std::ostream &os, int indent = 0 ) const;
     390        virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
     391        virtual void accept( Visitor &v ) override { v.visit( this ); }
     392        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     393        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    393394};
    394395
     
    424425        } orelse;
    425426
    426         virtual WaitForStmt *clone() const { return new WaitForStmt( *this ); }
    427         virtual void accept( Visitor &v ) { v.visit( this ); }
    428         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    429         virtual void print( std::ostream &os, int indent = 0 ) const;
     427        virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
     428        virtual void accept( Visitor &v ) override { v.visit( this ); }
     429        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     430        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    430431
    431432};
     
    444445        void set_decl( Declaration *newValue ) { decl = newValue; }
    445446
    446         virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
    447         virtual void accept( Visitor &v ) { v.visit( this ); }
    448         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    449         virtual void print( std::ostream &os, int indent = 0 ) const;
     447        virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
     448        virtual void accept( Visitor &v ) override { v.visit( this ); }
     449        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     450        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    450451};
    451452
     
    466467        void set_callStmt( Statement * newValue ) { callStmt = newValue; }
    467468
    468         virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); }
    469         virtual void accept( Visitor &v ) { v.visit( this ); }
    470         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    471         virtual void print( std::ostream &os, int indent = 0 ) const;
    472 };
    473 
    474 
    475 std::ostream & operator<<( std::ostream & out, const Statement * statement );
     469        virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
     470        virtual void accept( Visitor &v ) override { v.visit( this ); }
     471        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     472        virtual void print( std::ostream &os, Indenter indent = {} ) const override;
     473};
    476474
    477475// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.