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