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