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