Ignore:
Timestamp:
May 18, 2015, 11:20:23 AM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
51587aa
Parents:
a32b204
Message:

licencing: third groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/Statement.h

    ra32b204 r0dd3a2f  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// Statement.h --
     8//
     9// Author           : Richard C. Bilson
     10// Created On       : Mon May 18 07:44:20 2015
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon May 18 10:57:40 2015
     13// Update Count     : 2
     14//
     15
    116#ifndef STATEMENT_H
    217#define STATEMENT_H
     
    722#include "Common/SemanticError.h"
    823
    9 
    10 class Statement
    11 {
    12 public:
    13     Statement( std::list<Label> labels );
    14     virtual ~Statement();
    15 
    16     std::list<Label> & get_labels() { return labels; }
    17 
    18     virtual Statement *clone() const = 0;
    19     virtual void accept( Visitor &v ) = 0;
    20     virtual Statement *acceptMutator( Mutator &m ) = 0;
    21     virtual void print( std::ostream &os, int indent = 0 );
    22    
    23 protected:
    24     std::list<Label> labels;
    25 };
    26 
    27 class CompoundStmt : public Statement
    28 {
    29 public:
    30     CompoundStmt( std::list<Label> labels );
    31     CompoundStmt( const CompoundStmt &other );
    32     virtual ~CompoundStmt();
    33 
    34     std::list<Statement*>& get_kids() { return kids; }
    35 
    36     virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
    37     virtual void accept( Visitor &v ) { v.visit( this ); }
    38     virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    39     virtual void print( std::ostream &os, int indent = 0 );
    40    
    41 private:
    42     std::list<Statement*> kids;
    43 };
    44 
    45 class ExprStmt : public Statement
    46 {
    47 public:
    48     ExprStmt( std::list<Label> labels, Expression *expr );
    49     virtual ~ExprStmt();
    50 
    51     Expression *get_expr() { return expr; }
    52     void set_expr( Expression *newValue ) { expr = newValue; }
    53 
    54     virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
    55     virtual void accept( Visitor &v ) { v.visit( this ); }
    56     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    57     virtual void print( std::ostream &os, int indent = 0 );
    58    
    59 private:
    60     Expression *expr;
    61 };
    62 
    63 class IfStmt : public Statement
    64 {
    65 public:
    66     IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
    67     virtual ~IfStmt();
    68 
    69     Expression *get_condition() { return condition; }
    70     void set_condition( Expression *newValue ) { condition = newValue; }
    71     Statement *get_thenPart() { return thenPart; }
    72     void set_thenPart( Statement *newValue ) { thenPart = newValue; }
    73     Statement *get_elsePart() { return elsePart; }
    74     void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    75    
    76     virtual IfStmt *clone() const { return new IfStmt( *this ); }
    77     virtual void accept( Visitor &v ) { v.visit( this ); }
    78     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    79     virtual void print( std::ostream &os, int indent = 0 );
    80    
    81 private:
    82     Expression *condition;
    83     Statement *thenPart;
    84     Statement *elsePart;
    85 };
    86 
    87 class SwitchStmt : public Statement
    88 {
    89 public:
    90     SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
    91     virtual ~SwitchStmt();
    92 
    93     Expression *get_condition() { return condition; }
    94     void set_condition( Expression *newValue ) { condition = newValue; }
    95 
    96     std::list<Statement *>& get_branches() { return branches; }
    97     void add_case( CaseStmt * );
    98 
    99     virtual void accept( Visitor &v ) { v.visit( this ); }
    100     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    101 
    102     virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
    103     virtual void print( std::ostream &os, int indent = 0 );
    104    
    105 private:
    106     Expression * condition;
    107     std::list<Statement *> branches; // should be list of CaseStmt
    108 };
    109 
    110 class ChooseStmt : public Statement
    111 {
    112 public:
    113     ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
    114     virtual ~ChooseStmt();
    115 
    116     Expression *get_condition() { return condition; }
    117     void set_condition( Expression *newValue ) { condition = newValue; }
    118 
    119     std::list<Statement *>& get_branches() { return branches; }
    120     void add_case( CaseStmt * );
    121    
    122 
    123     virtual void accept( Visitor &v ) { v.visit( this ); }
    124     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    125 
    126     virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); }
    127     virtual void print( std::ostream &os, int indent = 0 );
    128    
    129 private:
    130     Expression *condition;
    131     std::list<Statement *> branches; // should be list of CaseStmt
     24class Statement {
     25  public:
     26        Statement( std::list<Label> labels );
     27        virtual ~Statement();
     28
     29        std::list<Label> & get_labels() { return labels; }
     30
     31        virtual Statement *clone() const = 0;
     32        virtual void accept( Visitor &v ) = 0;
     33        virtual Statement *acceptMutator( Mutator &m ) = 0;
     34        virtual void print( std::ostream &os, int indent = 0 );
     35  protected:
     36        std::list<Label> labels;
     37};
     38
     39class CompoundStmt : public Statement {
     40  public:
     41        CompoundStmt( std::list<Label> labels );
     42        CompoundStmt( const CompoundStmt &other );
     43        virtual ~CompoundStmt();
     44
     45        std::list<Statement*>& get_kids() { return kids; }
     46
     47        virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
     48        virtual void accept( Visitor &v ) { v.visit( this ); }
     49        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     50        virtual void print( std::ostream &os, int indent = 0 );
     51  private:
     52        std::list<Statement*> kids;
     53};
     54
     55class ExprStmt : public Statement {
     56  public:
     57        ExprStmt( std::list<Label> labels, Expression *expr );
     58        virtual ~ExprStmt();
     59
     60        Expression *get_expr() { return expr; }
     61        void set_expr( Expression *newValue ) { expr = newValue; }
     62
     63        virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
     64        virtual void accept( Visitor &v ) { v.visit( this ); }
     65        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     66        virtual void print( std::ostream &os, int indent = 0 );
     67  private:
     68        Expression *expr;
     69};
     70
     71class IfStmt : public Statement {
     72  public:
     73        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
     74        virtual ~IfStmt();
     75
     76        Expression *get_condition() { return condition; }
     77        void set_condition( Expression *newValue ) { condition = newValue; }
     78        Statement *get_thenPart() { return thenPart; }
     79        void set_thenPart( Statement *newValue ) { thenPart = newValue; }
     80        Statement *get_elsePart() { return elsePart; }
     81        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
     82       
     83        virtual IfStmt *clone() const { return new IfStmt( *this ); }
     84        virtual void accept( Visitor &v ) { v.visit( this ); }
     85        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     86        virtual void print( std::ostream &os, int indent = 0 );
     87  private:
     88        Expression *condition;
     89        Statement *thenPart;
     90        Statement *elsePart;
     91};
     92
     93class SwitchStmt : public Statement {
     94  public:
     95        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     96        virtual ~SwitchStmt();
     97
     98        Expression *get_condition() { return condition; }
     99        void set_condition( Expression *newValue ) { condition = newValue; }
     100
     101        std::list<Statement *>& get_branches() { return branches; }
     102        void add_case( CaseStmt * );
     103
     104        virtual void accept( Visitor &v ) { v.visit( this ); }
     105        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     106
     107        virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
     108        virtual void print( std::ostream &os, int indent = 0 );
     109  private:
     110        Expression * condition;
     111        std::list<Statement *> branches; // should be list of CaseStmt
     112};
     113
     114class ChooseStmt : public Statement {
     115  public:
     116        ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     117        virtual ~ChooseStmt();
     118
     119        Expression *get_condition() { return condition; }
     120        void set_condition( Expression *newValue ) { condition = newValue; }
     121
     122        std::list<Statement *>& get_branches() { return branches; }
     123        void add_case( CaseStmt * );
     124
     125        virtual void accept( Visitor &v ) { v.visit( this ); }
     126        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     127
     128        virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); }
     129        virtual void print( std::ostream &os, int indent = 0 );
     130  private:
     131        Expression *condition;
     132        std::list<Statement *> branches; // should be list of CaseStmt
    132133};
    133134
    134135class FallthruStmt : public Statement {
    135 public:
    136     FallthruStmt( std::list<Label> labels ) : Statement( labels ) { }
    137 
    138     virtual void accept( Visitor &v ) { v.visit( this ); }
    139     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    140 
    141     virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); }
    142     virtual void print( std::ostream &os, int indent = 0 );
    143 };
    144 
    145 class CaseStmt : public Statement
    146 {
    147 public:
    148     CaseStmt( std::list<Label> labels, Expression *conditions,
    149             std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    150     virtual ~CaseStmt();
    151 
    152     bool isDefault() { return _isDefault; }
    153     void set_default(bool b) { _isDefault = b; }
    154 
    155     Expression * &get_condition() { return condition; }
    156     void set_condition( Expression *newValue ) { condition = newValue; }
    157 
    158     std::list<Statement *> &get_statements() { return stmts; }
    159     void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    160    
    161     virtual void accept( Visitor &v ) { v.visit( this ); }
    162     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    163 
    164     virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
    165     virtual void print( std::ostream &os, int indent = 0 );
    166 
    167 private:
    168     Expression * condition;
    169     std::list<Statement *> stmts;
    170     bool _isDefault;
    171 };
    172 
    173 class WhileStmt : public Statement
    174 {
    175 public:
    176     WhileStmt( std::list<Label> labels, Expression *condition,
    177                                     Statement *body, bool isDoWhile = false );
    178     virtual ~WhileStmt();
    179 
    180     Expression *get_condition() { return condition; }
    181     void set_condition( Expression *newValue ) { condition = newValue; }
    182     Statement *get_body() { return body; }
    183     void set_body( Statement *newValue ) { body = newValue; }
    184     bool get_isDoWhile() { return isDoWhile; }
    185     void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    186    
    187     virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    188     virtual void accept( Visitor &v ) { v.visit( this ); }
    189     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    190     virtual void print( std::ostream &os, int indent = 0 );
    191    
    192 private:
    193     Expression *condition;
    194     Statement *body;
    195     bool isDoWhile;
    196 };
    197 
    198 class ForStmt : public Statement
    199 {
    200 public:
    201     ForStmt( std::list<Label> labels, Statement *initialization = 0,
    202          Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
    203     virtual ~ForStmt();
    204 
    205     Statement *get_initialization() { return initialization; }
    206     void set_initialization( Statement *newValue ) { initialization = newValue; }
    207     Expression *get_condition() { return condition; }
    208     void set_condition( Expression *newValue ) { condition = newValue; }
    209     Expression *get_increment() { return increment; }
    210     void set_increment( Expression *newValue ) { increment = newValue; }
    211     Statement *get_body() { return body; }
    212     void set_body( Statement *newValue ) { body = newValue; }
    213    
    214     virtual ForStmt *clone() const { return new ForStmt( *this ); }
    215     virtual void accept( Visitor &v ) { v.visit( this ); }
    216     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    217     virtual void print( std::ostream &os, int indent = 0 );
    218    
    219 private:
    220     Statement *initialization;
    221     Expression *condition;
    222     Expression *increment;
    223     Statement *body;
    224 };
    225 
    226 class BranchStmt : public Statement
    227 {
    228 public:
    229 
    230     enum Type { Goto = 0 , Break, Continue };
    231 
    232     BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    233     BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
    234     virtual ~BranchStmt() {}
    235 
    236     Label get_target() { return target; }
    237     void set_target( Label newValue ) { target = newValue; }
    238    
    239     Expression *get_computedTarget() { return computedTarget; }
    240     void set_target( Expression * newValue ) { computedTarget = newValue; }
    241 
    242     Type get_type() { return type; }
    243     const char *get_typename() { return brType[ type ]; }
    244 
    245     virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
    246     virtual void accept( Visitor &v ) { v.visit( this ); }
    247     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    248     virtual void print( std::ostream &os, int indent = 0 );
    249    
    250 private:
    251     static const char *brType[];
    252     Label target;
    253     Expression *computedTarget;
    254     Type type;
    255 };
    256 
    257 class ReturnStmt : public Statement
    258 {
    259 public:
    260     ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
    261     virtual ~ReturnStmt();
    262 
    263     Expression *get_expr() { return expr; }
    264     void set_expr( Expression *newValue ) { expr = newValue; }
    265    
    266     virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    267     virtual void accept( Visitor &v ) { v.visit( this ); }
    268     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    269     virtual void print( std::ostream &os, int indent = 0 );
    270    
    271 private:
    272     Expression *expr;
    273     bool isThrow;
    274 };
    275 
    276 
    277 class NullStmt : public CompoundStmt
    278 {
    279 public:
    280     NullStmt();
    281     NullStmt( std::list<Label> labels );
    282     virtual ~NullStmt();
    283 
    284     virtual NullStmt *clone() const { return new NullStmt( *this ); }
    285     virtual void accept( Visitor &v ) { v.visit( this ); }
    286     virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    287     virtual void print( std::ostream &os, int indent = 0 );
    288    
    289 private:
    290 };
    291 
    292 class TryStmt : public Statement
    293 {
    294 public:
    295     TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
    296     TryStmt( const TryStmt &other );
    297     virtual ~TryStmt();
    298 
    299     CompoundStmt *get_block() const { return block; }
    300     void set_block( CompoundStmt *newValue ) { block = newValue; }
    301     std::list<Statement *>& get_catchers() { return handlers; }
    302 
    303     FinallyStmt *get_finally() const { return finallyBlock; }
    304     void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
    305 
    306     virtual TryStmt *clone() const { return new TryStmt( *this ); }
    307     virtual void accept( Visitor &v ) { v.visit( this ); }
    308     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    309     virtual void print( std::ostream &os, int indent = 0 );
    310    
    311 private:
    312     CompoundStmt *block;
    313     std::list<Statement *> handlers;
    314     FinallyStmt *finallyBlock;
     136  public:
     137        FallthruStmt( std::list<Label> labels ) : Statement( labels ) { }
     138
     139        virtual void accept( Visitor &v ) { v.visit( this ); }
     140        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     141
     142        virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); }
     143        virtual void print( std::ostream &os, int indent = 0 );
     144};
     145
     146class CaseStmt : public Statement {
     147  public:
     148        CaseStmt( std::list<Label> labels, Expression *conditions,
     149              std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     150        virtual ~CaseStmt();
     151
     152        bool isDefault() { return _isDefault; }
     153        void set_default(bool b) { _isDefault = b; }
     154
     155        Expression * &get_condition() { return condition; }
     156        void set_condition( Expression *newValue ) { condition = newValue; }
     157
     158        std::list<Statement *> &get_statements() { return stmts; }
     159        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
     160       
     161        virtual void accept( Visitor &v ) { v.visit( this ); }
     162        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     163
     164        virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
     165        virtual void print( std::ostream &os, int indent = 0 );
     166  private:
     167        Expression * condition;
     168        std::list<Statement *> stmts;
     169        bool _isDefault;
     170};
     171
     172class WhileStmt : public Statement {
     173  public:
     174        WhileStmt( std::list<Label> labels, Expression *condition,
     175               Statement *body, bool isDoWhile = false );
     176        virtual ~WhileStmt();
     177
     178        Expression *get_condition() { return condition; }
     179        void set_condition( Expression *newValue ) { condition = newValue; }
     180        Statement *get_body() { return body; }
     181        void set_body( Statement *newValue ) { body = newValue; }
     182        bool get_isDoWhile() { return isDoWhile; }
     183        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
     184       
     185        virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
     186        virtual void accept( Visitor &v ) { v.visit( this ); }
     187        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     188        virtual void print( std::ostream &os, int indent = 0 );
     189  private:
     190        Expression *condition;
     191        Statement *body;
     192        bool isDoWhile;
     193};
     194
     195class ForStmt : public Statement {
     196  public:
     197        ForStmt( std::list<Label> labels, Statement *initialization = 0,
     198             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     199        virtual ~ForStmt();
     200
     201        Statement *get_initialization() { return initialization; }
     202        void set_initialization( Statement *newValue ) { initialization = newValue; }
     203        Expression *get_condition() { return condition; }
     204        void set_condition( Expression *newValue ) { condition = newValue; }
     205        Expression *get_increment() { return increment; }
     206        void set_increment( Expression *newValue ) { increment = newValue; }
     207        Statement *get_body() { return body; }
     208        void set_body( Statement *newValue ) { body = newValue; }
     209       
     210        virtual ForStmt *clone() const { return new ForStmt( *this ); }
     211        virtual void accept( Visitor &v ) { v.visit( this ); }
     212        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     213        virtual void print( std::ostream &os, int indent = 0 );
     214  private:
     215        Statement *initialization;
     216        Expression *condition;
     217        Expression *increment;
     218        Statement *body;
     219};
     220
     221class BranchStmt : public Statement {
     222  public:
     223        enum Type { Goto = 0 , Break, Continue };
     224
     225        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
     226        BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
     227        virtual ~BranchStmt() {}
     228
     229        Label get_target() { return target; }
     230        void set_target( Label newValue ) { target = newValue; }
     231       
     232        Expression *get_computedTarget() { return computedTarget; }
     233        void set_target( Expression * newValue ) { computedTarget = newValue; }
     234
     235        Type get_type() { return type; }
     236        const char *get_typename() { return brType[ type ]; }
     237
     238        virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
     239        virtual void accept( Visitor &v ) { v.visit( this ); }
     240        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     241        virtual void print( std::ostream &os, int indent = 0 );
     242  private:
     243        static const char *brType[];
     244        Label target;
     245        Expression *computedTarget;
     246        Type type;
     247};
     248
     249class ReturnStmt : public Statement {
     250  public:
     251        ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
     252        virtual ~ReturnStmt();
     253
     254        Expression *get_expr() { return expr; }
     255        void set_expr( Expression *newValue ) { expr = newValue; }
     256       
     257        virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
     258        virtual void accept( Visitor &v ) { v.visit( this ); }
     259        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     260        virtual void print( std::ostream &os, int indent = 0 );
     261  private:
     262        Expression *expr;
     263        bool isThrow;
     264};
     265
     266
     267class NullStmt : public CompoundStmt {
     268  public:
     269        NullStmt();
     270        NullStmt( std::list<Label> labels );
     271        virtual ~NullStmt();
     272
     273        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     274        virtual void accept( Visitor &v ) { v.visit( this ); }
     275        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     276        virtual void print( std::ostream &os, int indent = 0 );
     277       
     278  private:
     279};
     280
     281class TryStmt : public Statement {
     282  public:
     283        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     284        TryStmt( const TryStmt &other );
     285        virtual ~TryStmt();
     286
     287        CompoundStmt *get_block() const { return block; }
     288        void set_block( CompoundStmt *newValue ) { block = newValue; }
     289        std::list<Statement *>& get_catchers() { return handlers; }
     290
     291        FinallyStmt *get_finally() const { return finallyBlock; }
     292        void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
     293
     294        virtual TryStmt *clone() const { return new TryStmt( *this ); }
     295        virtual void accept( Visitor &v ) { v.visit( this ); }
     296        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     297        virtual void print( std::ostream &os, int indent = 0 );
     298       
     299  private:
     300        CompoundStmt *block;
     301        std::list<Statement *> handlers;
     302        FinallyStmt *finallyBlock;
    315303};
    316304
    317 class CatchStmt : public Statement
    318 {
    319 public:
    320     CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
    321     virtual ~CatchStmt();
    322 
    323     Declaration *get_decl() { return decl; }
    324     void set_decl( Declaration *newValue ) { decl = newValue; }
    325 
    326     Statement *get_body() { return body; }
    327     void set_body( Statement *newValue ) { body = newValue; }
    328    
    329     virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    330     virtual void accept( Visitor &v ) { v.visit( this ); }
    331     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    332     virtual void print( std::ostream &os, int indent = 0 );
    333    
    334 private:
    335     Declaration *decl;
    336     Statement *body;
    337     bool catchRest;
    338 };
    339 
    340 class FinallyStmt : public Statement
    341 {
    342 public:
    343     FinallyStmt( std::list<Label> labels, CompoundStmt *block );
    344     virtual ~FinallyStmt();
    345 
    346     CompoundStmt *get_block() const { return block; }
    347     void set_block( CompoundStmt *newValue ) { block = newValue; }
    348    
    349     virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    350     virtual void accept( Visitor &v ) { v.visit( this ); }
    351     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    352     virtual void print( std::ostream &os, int indent = 0 );
    353    
    354 private:
    355     CompoundStmt *block;
     305class CatchStmt : public Statement {
     306  public:
     307        CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
     308        virtual ~CatchStmt();
     309
     310        Declaration *get_decl() { return decl; }
     311        void set_decl( Declaration *newValue ) { decl = newValue; }
     312
     313        Statement *get_body() { return body; }
     314        void set_body( Statement *newValue ) { body = newValue; }
     315       
     316        virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
     317        virtual void accept( Visitor &v ) { v.visit( this ); }
     318        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     319        virtual void print( std::ostream &os, int indent = 0 );
     320       
     321  private:
     322        Declaration *decl;
     323        Statement *body;
     324        bool catchRest;
     325};
     326
     327class FinallyStmt : public Statement {
     328  public:
     329        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
     330        virtual ~FinallyStmt();
     331
     332        CompoundStmt *get_block() const { return block; }
     333        void set_block( CompoundStmt *newValue ) { block = newValue; }
     334       
     335        virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
     336        virtual void accept( Visitor &v ) { v.visit( this ); }
     337        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     338        virtual void print( std::ostream &os, int indent = 0 );
     339  private:
     340        CompoundStmt *block;
    356341};
    357342
    358343
    359344// represents a declaration that occurs as part of a compound statement
    360 class DeclStmt : public Statement
    361 {
    362 public:
    363     DeclStmt( std::list<Label> labels, Declaration *decl );
    364     DeclStmt( const DeclStmt &other );
    365     virtual ~DeclStmt();
    366 
    367     Declaration *get_decl() { return decl; }
    368     void set_decl( Declaration *newValue ) { decl = newValue; }
    369 
    370     virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
    371     virtual void accept( Visitor &v ) { v.visit( this ); }
    372     virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    373     virtual void print( std::ostream &os, int indent = 0 );
    374    
    375 private:
    376     Declaration *decl;
    377 };
    378 
    379 
    380 
    381 #endif /* #ifndef STATEMENT_H */
    382 
    383 /*
    384     Local Variables:
    385     mode: c++
    386     End:
    387 */
     345class DeclStmt : public Statement {
     346  public:
     347        DeclStmt( std::list<Label> labels, Declaration *decl );
     348        DeclStmt( const DeclStmt &other );
     349        virtual ~DeclStmt();
     350
     351        Declaration *get_decl() { return decl; }
     352        void set_decl( Declaration *newValue ) { decl = newValue; }
     353
     354        virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
     355        virtual void accept( Visitor &v ) { v.visit( this ); }
     356        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     357        virtual void print( std::ostream &os, int indent = 0 );
     358  private:
     359        Declaration *decl;
     360};
     361
     362#endif // STATEMENT_H
     363
     364// Local Variables: //
     365// tab-width: 4 //
     366// mode: c++ //
     367// compile-command: "make install" //
     368// End: //
Note: See TracChangeset for help on using the changeset viewer.