[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 |
---|
[936e9f4] | 11 | // Last Modified By : Peter A. Buhr |
---|
[6a276a0] | 12 | // Last Modified On : Thu Mar 8 14:53:02 2018 |
---|
| 13 | // Update Count : 78 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
[6b0b624] | 16 | #pragma once |
---|
[51b7345] | 17 | |
---|
[ea6332d] | 18 | #include <iosfwd> // for ostream |
---|
| 19 | #include <list> // for list |
---|
| 20 | #include <memory> // for allocator |
---|
[135b431] | 21 | #include <vector> // for vector |
---|
[ea6332d] | 22 | |
---|
| 23 | #include "BaseSyntaxNode.h" // for BaseSyntaxNode |
---|
| 24 | #include "Common/SemanticError.h" // for SemanticError |
---|
| 25 | #include "Label.h" // for Label |
---|
| 26 | #include "Mutator.h" // for Mutator |
---|
| 27 | #include "Visitor.h" // for Visitor |
---|
| 28 | |
---|
| 29 | class CatchStmt; |
---|
| 30 | class ConstantExpr; |
---|
| 31 | class Declaration; |
---|
| 32 | class Expression; |
---|
| 33 | class FinallyStmt; |
---|
[51b7345] | 34 | |
---|
[294647b] | 35 | class Statement : public BaseSyntaxNode { |
---|
[0dd3a2f] | 36 | public: |
---|
[65cdc1e] | 37 | std::list<Label> labels; |
---|
| 38 | |
---|
[ba3706f] | 39 | Statement( const std::list<Label> & labels = {} ); |
---|
[51b7345] | 40 | |
---|
[0dd3a2f] | 41 | std::list<Label> & get_labels() { return labels; } |
---|
[de62360d] | 42 | const std::list<Label> & get_labels() const { return labels; } |
---|
[51b7345] | 43 | |
---|
[fa16264] | 44 | virtual Statement *clone() const override = 0; |
---|
[e149f77] | 45 | virtual void accept( Visitor &v ) override = 0; |
---|
[fa16264] | 46 | virtual Statement *acceptMutator( Mutator &m ) override = 0; |
---|
[50377a4] | 47 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 48 | }; |
---|
| 49 | |
---|
[0dd3a2f] | 50 | class CompoundStmt : public Statement { |
---|
| 51 | public: |
---|
[65cdc1e] | 52 | std::list<Statement*> kids; |
---|
| 53 | |
---|
[ba3706f] | 54 | CompoundStmt(); |
---|
[a2dbad10] | 55 | CompoundStmt( std::list<Statement *> stmts ); |
---|
[0dd3a2f] | 56 | CompoundStmt( const CompoundStmt &other ); |
---|
[51b7345] | 57 | |
---|
[0dd3a2f] | 58 | std::list<Statement*>& get_kids() { return kids; } |
---|
[c8dfcd3] | 59 | void push_back( Statement * stmt ) { kids.push_back( stmt ); } |
---|
| 60 | void push_front( Statement * stmt ) { kids.push_front( stmt ); } |
---|
[51b7345] | 61 | |
---|
[e149f77] | 62 | virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); } |
---|
| 63 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 64 | virtual CompoundStmt *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 65 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 66 | }; |
---|
| 67 | |
---|
[70d826cd] | 68 | class NullStmt : public Statement { |
---|
[daf1af8] | 69 | public: |
---|
[ba3706f] | 70 | NullStmt( const std::list<Label> & labels = {} ); |
---|
[daf1af8] | 71 | |
---|
[e149f77] | 72 | virtual NullStmt *clone() const override { return new NullStmt( *this ); } |
---|
| 73 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 74 | virtual NullStmt *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 75 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[daf1af8] | 76 | }; |
---|
| 77 | |
---|
[0dd3a2f] | 78 | class ExprStmt : public Statement { |
---|
| 79 | public: |
---|
[65cdc1e] | 80 | Expression *expr; |
---|
| 81 | |
---|
[ba3706f] | 82 | ExprStmt( Expression *expr ); |
---|
[3be261a] | 83 | ExprStmt( const ExprStmt &other ); |
---|
[51b7345] | 84 | |
---|
[0dd3a2f] | 85 | Expression *get_expr() { return expr; } |
---|
| 86 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
[51b7345] | 87 | |
---|
[e149f77] | 88 | virtual ExprStmt *clone() const override { return new ExprStmt( *this ); } |
---|
| 89 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 90 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 91 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[0dd3a2f] | 92 | }; |
---|
[51b7345] | 93 | |
---|
[7f5566b] | 94 | class AsmStmt : public Statement { |
---|
| 95 | public: |
---|
[65cdc1e] | 96 | bool voltile; |
---|
[e612146c] | 97 | Expression *instruction; |
---|
[65cdc1e] | 98 | std::list<Expression *> output, input; |
---|
| 99 | std::list<ConstantExpr *> clobber; |
---|
| 100 | std::list<Label> gotolabels; |
---|
| 101 | |
---|
[ba3706f] | 102 | AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); |
---|
[3be261a] | 103 | AsmStmt( const AsmStmt &other ); |
---|
[7f5566b] | 104 | |
---|
| 105 | bool get_voltile() { return voltile; } |
---|
| 106 | void set_voltile( bool newValue ) { voltile = newValue; } |
---|
[e612146c] | 107 | Expression * get_instruction() { return instruction; } |
---|
| 108 | void set_instruction( Expression * newValue ) { instruction = newValue; } |
---|
| 109 | std::list<Expression *> & get_output() { return output; } |
---|
| 110 | void set_output( const std::list<Expression *> & newValue ) { output = newValue; } |
---|
| 111 | std::list<Expression *> & get_input() { return input; } |
---|
[7f5566b] | 112 | void set_input( const std::list<Expression *> &newValue ) { input = newValue; } |
---|
[e612146c] | 113 | std::list<ConstantExpr *> & get_clobber() { return clobber; } |
---|
[7f5566b] | 114 | void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; } |
---|
[e612146c] | 115 | std::list<Label> & get_gotolabels() { return gotolabels; } |
---|
[7f5566b] | 116 | void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; } |
---|
| 117 | |
---|
[e612146c] | 118 | virtual AsmStmt * clone() const { return new AsmStmt( *this ); } |
---|
| 119 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
| 120 | virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
[50377a4] | 121 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
[7f5566b] | 122 | }; |
---|
| 123 | |
---|
[cc32d83] | 124 | class DirectiveStmt : public Statement { |
---|
| 125 | public: |
---|
| 126 | std::string directive; |
---|
| 127 | |
---|
| 128 | DirectiveStmt( const std::string & ); |
---|
| 129 | virtual ~DirectiveStmt(){} |
---|
| 130 | |
---|
| 131 | virtual DirectiveStmt * clone() const { return new DirectiveStmt( *this ); } |
---|
| 132 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
| 133 | virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
| 134 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
| 135 | }; |
---|
| 136 | |
---|
[0dd3a2f] | 137 | class IfStmt : public Statement { |
---|
| 138 | public: |
---|
[65cdc1e] | 139 | Expression *condition; |
---|
| 140 | Statement *thenPart; |
---|
| 141 | Statement *elsePart; |
---|
[6d49ea3] | 142 | std::list<Statement *> initialization; |
---|
[65cdc1e] | 143 | |
---|
[ba3706f] | 144 | IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, |
---|
[6d49ea3] | 145 | std::list<Statement *> initialization = std::list<Statement *>() ); |
---|
[3be261a] | 146 | IfStmt( const IfStmt &other ); |
---|
[0dd3a2f] | 147 | |
---|
[936e9f4] | 148 | std::list<Statement *> &get_initialization() { return initialization; } |
---|
[0dd3a2f] | 149 | Expression *get_condition() { return condition; } |
---|
| 150 | void set_condition( Expression *newValue ) { condition = newValue; } |
---|
| 151 | Statement *get_thenPart() { return thenPart; } |
---|
| 152 | void set_thenPart( Statement *newValue ) { thenPart = newValue; } |
---|
| 153 | Statement *get_elsePart() { return elsePart; } |
---|
| 154 | void set_elsePart( Statement *newValue ) { elsePart = newValue; } |
---|
[3be261a] | 155 | |
---|
[e149f77] | 156 | virtual IfStmt *clone() const override { return new IfStmt( *this ); } |
---|
| 157 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 158 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 159 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 160 | }; |
---|
| 161 | |
---|
[0dd3a2f] | 162 | class SwitchStmt : public Statement { |
---|
| 163 | public: |
---|
[65cdc1e] | 164 | Expression * condition; |
---|
[871cdb4] | 165 | std::list<Statement *> statements; |
---|
[65cdc1e] | 166 | |
---|
[ba3706f] | 167 | SwitchStmt( Expression *condition, const std::list<Statement *> &statements ); |
---|
[3be261a] | 168 | SwitchStmt( const SwitchStmt &other ); |
---|
[51b7345] | 169 | |
---|
[0dd3a2f] | 170 | Expression *get_condition() { return condition; } |
---|
| 171 | void set_condition( Expression *newValue ) { condition = newValue; } |
---|
[51b7345] | 172 | |
---|
[8688ce1] | 173 | std::list<Statement *> & get_statements() { return statements; } |
---|
[51b7345] | 174 | |
---|
[e149f77] | 175 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 176 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[51b7345] | 177 | |
---|
[e149f77] | 178 | virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); } |
---|
[50377a4] | 179 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[871cdb4] | 180 | |
---|
[51b7345] | 181 | }; |
---|
| 182 | |
---|
[0dd3a2f] | 183 | class CaseStmt : public Statement { |
---|
| 184 | public: |
---|
[65cdc1e] | 185 | Expression * condition; |
---|
| 186 | std::list<Statement *> stmts; |
---|
| 187 | |
---|
[a16764a6] | 188 | CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException); |
---|
[3be261a] | 189 | CaseStmt( const CaseStmt &other ); |
---|
[0dd3a2f] | 190 | |
---|
[ba3706f] | 191 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); |
---|
[b2152e7a] | 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 | |
---|
[e149f77] | 202 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 203 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[0dd3a2f] | 204 | |
---|
[e149f77] | 205 | virtual CaseStmt *clone() const override { return new CaseStmt( *this ); } |
---|
[50377a4] | 206 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[0dd3a2f] | 207 | private: |
---|
| 208 | bool _isDefault; |
---|
[51b7345] | 209 | }; |
---|
| 210 | |
---|
[0dd3a2f] | 211 | class WhileStmt : public Statement { |
---|
| 212 | public: |
---|
[65cdc1e] | 213 | Expression *condition; |
---|
| 214 | Statement *body; |
---|
| 215 | bool isDoWhile; |
---|
| 216 | |
---|
[ba3706f] | 217 | WhileStmt( Expression *condition, |
---|
[0dd3a2f] | 218 | Statement *body, bool isDoWhile = false ); |
---|
[3be261a] | 219 | WhileStmt( const WhileStmt &other ); |
---|
[0dd3a2f] | 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 | |
---|
[e149f77] | 228 | virtual WhileStmt *clone() const override { return new WhileStmt( *this ); } |
---|
| 229 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 230 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 231 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 232 | }; |
---|
| 233 | |
---|
[0dd3a2f] | 234 | class ForStmt : public Statement { |
---|
| 235 | public: |
---|
[65cdc1e] | 236 | std::list<Statement *> initialization; |
---|
| 237 | Expression *condition; |
---|
| 238 | Expression *increment; |
---|
| 239 | Statement *body; |
---|
| 240 | |
---|
[ba3706f] | 241 | ForStmt( std::list<Statement *> initialization, |
---|
[0dd3a2f] | 242 | Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); |
---|
[3be261a] | 243 | ForStmt( const ForStmt &other ); |
---|
[0dd3a2f] | 244 | |
---|
[145f1fc] | 245 | std::list<Statement *> &get_initialization() { return initialization; } |
---|
[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 | |
---|
[e149f77] | 253 | virtual ForStmt *clone() const override { return new ForStmt( *this ); } |
---|
| 254 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 255 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 256 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 257 | }; |
---|
| 258 | |
---|
[0dd3a2f] | 259 | class BranchStmt : public Statement { |
---|
| 260 | public: |
---|
[6a276a0] | 261 | enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault }; |
---|
[0dd3a2f] | 262 | |
---|
[65cdc1e] | 263 | // originalTarget kept for error messages. |
---|
| 264 | const Label originalTarget; |
---|
| 265 | Label target; |
---|
| 266 | Expression *computedTarget; |
---|
| 267 | Type type; |
---|
| 268 | |
---|
[a16764a6] | 269 | BranchStmt( Label target, Type ) throw (SemanticErrorException); |
---|
| 270 | BranchStmt( Expression *computedTarget, Type ) throw (SemanticErrorException); |
---|
[0dd3a2f] | 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 | |
---|
[e149f77] | 282 | virtual BranchStmt *clone() const override { return new BranchStmt( *this ); } |
---|
| 283 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 284 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 285 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[0dd3a2f] | 286 | private: |
---|
| 287 | static const char *brType[]; |
---|
[51b7345] | 288 | }; |
---|
| 289 | |
---|
[0dd3a2f] | 290 | class ReturnStmt : public Statement { |
---|
| 291 | public: |
---|
[65cdc1e] | 292 | Expression *expr; |
---|
| 293 | |
---|
[ba3706f] | 294 | ReturnStmt( Expression *expr ); |
---|
[3be261a] | 295 | ReturnStmt( const ReturnStmt &other ); |
---|
[0dd3a2f] | 296 | |
---|
| 297 | Expression *get_expr() { return expr; } |
---|
| 298 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
[3be261a] | 299 | |
---|
[e149f77] | 300 | virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); } |
---|
| 301 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 302 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 303 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 304 | }; |
---|
| 305 | |
---|
[daf1af8] | 306 | class ThrowStmt : public Statement { |
---|
[0dd3a2f] | 307 | public: |
---|
[daf1af8] | 308 | enum Kind { Terminate, Resume }; |
---|
[51b7345] | 309 | |
---|
[65cdc1e] | 310 | const Kind kind; |
---|
| 311 | Expression * expr; |
---|
| 312 | Expression * target; |
---|
| 313 | |
---|
[ba3706f] | 314 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); |
---|
[daf1af8] | 315 | ThrowStmt( const ThrowStmt &other ); |
---|
| 316 | |
---|
| 317 | Kind get_kind() { return kind; } |
---|
| 318 | Expression * get_expr() { return expr; } |
---|
| 319 | void set_expr( Expression * newExpr ) { expr = newExpr; } |
---|
| 320 | Expression * get_target() { return target; } |
---|
| 321 | void set_target( Expression * newTarget ) { target = newTarget; } |
---|
| 322 | |
---|
[e149f77] | 323 | virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); } |
---|
| 324 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 325 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 326 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 327 | }; |
---|
| 328 | |
---|
[3be261a] | 329 | class TryStmt : public Statement { |
---|
[0dd3a2f] | 330 | public: |
---|
[871cdb4] | 331 | CompoundStmt * block; |
---|
[65cdc1e] | 332 | std::list<CatchStmt *> handlers; |
---|
[871cdb4] | 333 | FinallyStmt * finallyBlock; |
---|
[65cdc1e] | 334 | |
---|
[ba3706f] | 335 | TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); |
---|
[0dd3a2f] | 336 | TryStmt( const TryStmt &other ); |
---|
| 337 | |
---|
| 338 | CompoundStmt *get_block() const { return block; } |
---|
| 339 | void set_block( CompoundStmt *newValue ) { block = newValue; } |
---|
[046e04a] | 340 | std::list<CatchStmt *>& get_catchers() { return handlers; } |
---|
[0dd3a2f] | 341 | |
---|
| 342 | FinallyStmt *get_finally() const { return finallyBlock; } |
---|
| 343 | void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; } |
---|
| 344 | |
---|
[e149f77] | 345 | virtual TryStmt *clone() const override { return new TryStmt( *this ); } |
---|
| 346 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 347 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 348 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[3be261a] | 349 | }; |
---|
[51b7345] | 350 | |
---|
[0dd3a2f] | 351 | class CatchStmt : public Statement { |
---|
| 352 | public: |
---|
[ca78437] | 353 | enum Kind { Terminate, Resume }; |
---|
| 354 | |
---|
[65cdc1e] | 355 | const Kind kind; |
---|
| 356 | Declaration *decl; |
---|
| 357 | Expression *cond; |
---|
| 358 | Statement *body; |
---|
| 359 | |
---|
[ba3706f] | 360 | CatchStmt( Kind kind, Declaration *decl, |
---|
[ca78437] | 361 | Expression *cond, Statement *body ); |
---|
[3be261a] | 362 | CatchStmt( const CatchStmt &other ); |
---|
[0dd3a2f] | 363 | |
---|
[ca78437] | 364 | Kind get_kind() { return kind; } |
---|
[0dd3a2f] | 365 | Declaration *get_decl() { return decl; } |
---|
| 366 | void set_decl( Declaration *newValue ) { decl = newValue; } |
---|
[ca78437] | 367 | Expression *get_cond() { return cond; } |
---|
| 368 | void set_cond( Expression *newCond ) { cond = newCond; } |
---|
[0dd3a2f] | 369 | Statement *get_body() { return body; } |
---|
| 370 | void set_body( Statement *newValue ) { body = newValue; } |
---|
[3be261a] | 371 | |
---|
[e149f77] | 372 | virtual CatchStmt *clone() const override { return new CatchStmt( *this ); } |
---|
| 373 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 374 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 375 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 376 | }; |
---|
| 377 | |
---|
[3be261a] | 378 | class FinallyStmt : public Statement { |
---|
[0dd3a2f] | 379 | public: |
---|
[65cdc1e] | 380 | CompoundStmt *block; |
---|
| 381 | |
---|
[ba3706f] | 382 | FinallyStmt( CompoundStmt *block ); |
---|
[3be261a] | 383 | FinallyStmt( const FinallyStmt &other ); |
---|
[0dd3a2f] | 384 | |
---|
| 385 | CompoundStmt *get_block() const { return block; } |
---|
| 386 | void set_block( CompoundStmt *newValue ) { block = newValue; } |
---|
[3be261a] | 387 | |
---|
[e149f77] | 388 | virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); } |
---|
| 389 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 390 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 391 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[3be261a] | 392 | }; |
---|
[51b7345] | 393 | |
---|
[135b431] | 394 | class WaitForStmt : public Statement { |
---|
| 395 | public: |
---|
| 396 | |
---|
| 397 | struct Target { |
---|
| 398 | Expression * function; |
---|
| 399 | std::list<Expression * > arguments; |
---|
| 400 | }; |
---|
| 401 | |
---|
| 402 | struct Clause { |
---|
| 403 | Target target; |
---|
| 404 | Statement * statement; |
---|
| 405 | Expression * condition; |
---|
| 406 | }; |
---|
| 407 | |
---|
[ba3706f] | 408 | WaitForStmt(); |
---|
[135b431] | 409 | WaitForStmt( const WaitForStmt & ); |
---|
| 410 | |
---|
| 411 | std::vector<Clause> clauses; |
---|
| 412 | |
---|
| 413 | struct { |
---|
| 414 | Expression * time; |
---|
| 415 | Statement * statement; |
---|
| 416 | Expression * condition; |
---|
| 417 | } timeout; |
---|
| 418 | |
---|
| 419 | struct { |
---|
| 420 | Statement * statement; |
---|
| 421 | Expression * condition; |
---|
| 422 | } orelse; |
---|
| 423 | |
---|
[e149f77] | 424 | virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); } |
---|
| 425 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 426 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 427 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[135b431] | 428 | |
---|
| 429 | }; |
---|
| 430 | |
---|
[61255ad] | 431 | class WithStmt : public Statement { |
---|
| 432 | public: |
---|
| 433 | std::list< Expression * > exprs; |
---|
| 434 | Statement * stmt; |
---|
| 435 | |
---|
| 436 | WithStmt( const std::list< Expression * > & exprs, Statement * stmt ); |
---|
| 437 | WithStmt( const WithStmt & other ); |
---|
| 438 | |
---|
| 439 | virtual WithStmt * clone() const override { return new WithStmt( *this ); } |
---|
| 440 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
| 441 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
| 442 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
| 443 | }; |
---|
| 444 | |
---|
[51b7345] | 445 | |
---|
| 446 | // represents a declaration that occurs as part of a compound statement |
---|
[0dd3a2f] | 447 | class DeclStmt : public Statement { |
---|
| 448 | public: |
---|
[65cdc1e] | 449 | Declaration *decl; |
---|
| 450 | |
---|
[ba3706f] | 451 | DeclStmt( Declaration *decl ); |
---|
[0dd3a2f] | 452 | DeclStmt( const DeclStmt &other ); |
---|
| 453 | |
---|
[f1b1e4c] | 454 | Declaration *get_decl() const { return decl; } |
---|
[0dd3a2f] | 455 | void set_decl( Declaration *newValue ) { decl = newValue; } |
---|
| 456 | |
---|
[e149f77] | 457 | virtual DeclStmt *clone() const override { return new DeclStmt( *this ); } |
---|
| 458 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 459 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 460 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 461 | }; |
---|
| 462 | |
---|
[f1b1e4c] | 463 | |
---|
| 464 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced |
---|
| 465 | /// immediately before and after the call so that qualified objects can be constructed |
---|
| 466 | /// with the same functions as unqualified objects. |
---|
| 467 | class ImplicitCtorDtorStmt : public Statement { |
---|
| 468 | public: |
---|
[65cdc1e] | 469 | // Non-owned pointer to the constructor/destructor statement |
---|
| 470 | Statement * callStmt; |
---|
| 471 | |
---|
[f1b1e4c] | 472 | ImplicitCtorDtorStmt( Statement * callStmt ); |
---|
| 473 | ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); |
---|
| 474 | |
---|
| 475 | Statement *get_callStmt() const { return callStmt; } |
---|
| 476 | void set_callStmt( Statement * newValue ) { callStmt = newValue; } |
---|
| 477 | |
---|
[e149f77] | 478 | virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); } |
---|
| 479 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 480 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 481 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[f1b1e4c] | 482 | }; |
---|
| 483 | |
---|
[0dd3a2f] | 484 | // Local Variables: // |
---|
| 485 | // tab-width: 4 // |
---|
| 486 | // mode: c++ // |
---|
| 487 | // compile-command: "make install" // |
---|
| 488 | // End: // |
---|