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