| 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 | // | 
|---|
| 7 | // Statement.h -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Richard C. Bilson | 
|---|
| 10 | // Created On       : Mon May 18 07:44:20 2015 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr | 
|---|
| 12 | // Last Modified On : Thu Mar  8 14:53:02 2018 | 
|---|
| 13 | // Update Count     : 78 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #pragma once | 
|---|
| 17 |  | 
|---|
| 18 | #include <iosfwd>                  // for ostream | 
|---|
| 19 | #include <list>                    // for list | 
|---|
| 20 | #include <memory>                  // for allocator | 
|---|
| 21 | #include <vector>                        // for vector | 
|---|
| 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; | 
|---|
| 34 |  | 
|---|
| 35 | class Statement : public BaseSyntaxNode { | 
|---|
| 36 | public: | 
|---|
| 37 | std::list<Label> labels; | 
|---|
| 38 |  | 
|---|
| 39 | Statement( const std::list<Label> & labels = {} ); | 
|---|
| 40 |  | 
|---|
| 41 | std::list<Label> & get_labels() { return labels; } | 
|---|
| 42 | const std::list<Label> & get_labels() const { return labels; } | 
|---|
| 43 |  | 
|---|
| 44 | virtual Statement *clone() const override = 0; | 
|---|
| 45 | virtual void accept( Visitor &v ) override = 0; | 
|---|
| 46 | virtual Statement *acceptMutator( Mutator &m ) override = 0; | 
|---|
| 47 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 48 | }; | 
|---|
| 49 |  | 
|---|
| 50 | class CompoundStmt : public Statement { | 
|---|
| 51 | public: | 
|---|
| 52 | std::list<Statement*> kids; | 
|---|
| 53 |  | 
|---|
| 54 | CompoundStmt(); | 
|---|
| 55 | CompoundStmt( std::list<Statement *> stmts ); | 
|---|
| 56 | CompoundStmt( const CompoundStmt &other ); | 
|---|
| 57 |  | 
|---|
| 58 | std::list<Statement*>& get_kids() { return kids; } | 
|---|
| 59 | void push_back( Statement * stmt ) { kids.push_back( stmt ); } | 
|---|
| 60 | void push_front( Statement * stmt ) { kids.push_front( stmt ); } | 
|---|
| 61 |  | 
|---|
| 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 ); } | 
|---|
| 65 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 66 | }; | 
|---|
| 67 |  | 
|---|
| 68 | class NullStmt : public Statement { | 
|---|
| 69 | public: | 
|---|
| 70 | NullStmt( const std::list<Label> & labels = {} ); | 
|---|
| 71 |  | 
|---|
| 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 ); } | 
|---|
| 75 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 76 | }; | 
|---|
| 77 |  | 
|---|
| 78 | class ExprStmt : public Statement { | 
|---|
| 79 | public: | 
|---|
| 80 | Expression *expr; | 
|---|
| 81 |  | 
|---|
| 82 | ExprStmt( Expression *expr ); | 
|---|
| 83 | ExprStmt( const ExprStmt &other ); | 
|---|
| 84 |  | 
|---|
| 85 | Expression *get_expr() { return expr; } | 
|---|
| 86 | void set_expr( Expression *newValue ) { expr = newValue; } | 
|---|
| 87 |  | 
|---|
| 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 ); } | 
|---|
| 91 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 92 | }; | 
|---|
| 93 |  | 
|---|
| 94 | class AsmStmt : public Statement { | 
|---|
| 95 | public: | 
|---|
| 96 | bool voltile; | 
|---|
| 97 | Expression *instruction; | 
|---|
| 98 | std::list<Expression *> output, input; | 
|---|
| 99 | std::list<ConstantExpr *> clobber; | 
|---|
| 100 | std::list<Label> gotolabels; | 
|---|
| 101 |  | 
|---|
| 102 | AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); | 
|---|
| 103 | AsmStmt( const AsmStmt &other ); | 
|---|
| 104 |  | 
|---|
| 105 | bool get_voltile() { return voltile; } | 
|---|
| 106 | void set_voltile( bool newValue ) { voltile = newValue; } | 
|---|
| 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; } | 
|---|
| 112 | void set_input( const std::list<Expression *> &newValue ) { input = newValue; } | 
|---|
| 113 | std::list<ConstantExpr *> & get_clobber() { return clobber; } | 
|---|
| 114 | void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; } | 
|---|
| 115 | std::list<Label> & get_gotolabels() { return gotolabels; } | 
|---|
| 116 | void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; } | 
|---|
| 117 |  | 
|---|
| 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 ); } | 
|---|
| 121 | virtual void print( std::ostream & os, Indenter indent = {} ) const; | 
|---|
| 122 | }; | 
|---|
| 123 |  | 
|---|
| 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 |  | 
|---|
| 137 | class IfStmt : public Statement { | 
|---|
| 138 | public: | 
|---|
| 139 | Expression *condition; | 
|---|
| 140 | Statement *thenPart; | 
|---|
| 141 | Statement *elsePart; | 
|---|
| 142 | std::list<Statement *> initialization; | 
|---|
| 143 |  | 
|---|
| 144 | IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, | 
|---|
| 145 | std::list<Statement *> initialization = std::list<Statement *>() ); | 
|---|
| 146 | IfStmt( const IfStmt &other ); | 
|---|
| 147 |  | 
|---|
| 148 | std::list<Statement *> &get_initialization() { return initialization; } | 
|---|
| 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; } | 
|---|
| 155 |  | 
|---|
| 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 ); } | 
|---|
| 159 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 160 | }; | 
|---|
| 161 |  | 
|---|
| 162 | class SwitchStmt : public Statement { | 
|---|
| 163 | public: | 
|---|
| 164 | Expression * condition; | 
|---|
| 165 | std::list<Statement *> statements; | 
|---|
| 166 |  | 
|---|
| 167 | SwitchStmt( Expression *condition, const std::list<Statement *> &statements ); | 
|---|
| 168 | SwitchStmt( const SwitchStmt &other ); | 
|---|
| 169 |  | 
|---|
| 170 | Expression *get_condition() { return condition; } | 
|---|
| 171 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
| 172 |  | 
|---|
| 173 | std::list<Statement *> & get_statements() { return statements; } | 
|---|
| 174 |  | 
|---|
| 175 | virtual void accept( Visitor &v ) override { v.visit( this ); } | 
|---|
| 176 | virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); } | 
|---|
| 177 |  | 
|---|
| 178 | virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); } | 
|---|
| 179 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 180 |  | 
|---|
| 181 | }; | 
|---|
| 182 |  | 
|---|
| 183 | class CaseStmt : public Statement { | 
|---|
| 184 | public: | 
|---|
| 185 | Expression * condition; | 
|---|
| 186 | std::list<Statement *> stmts; | 
|---|
| 187 |  | 
|---|
| 188 | CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException); | 
|---|
| 189 | CaseStmt( const CaseStmt &other ); | 
|---|
| 190 |  | 
|---|
| 191 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); | 
|---|
| 192 |  | 
|---|
| 193 | bool isDefault() const { return _isDefault; } | 
|---|
| 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; } | 
|---|
| 201 |  | 
|---|
| 202 | virtual void accept( Visitor &v ) override { v.visit( this ); } | 
|---|
| 203 | virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); } | 
|---|
| 204 |  | 
|---|
| 205 | virtual CaseStmt *clone() const override { return new CaseStmt( *this ); } | 
|---|
| 206 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 207 | private: | 
|---|
| 208 | bool _isDefault; | 
|---|
| 209 | }; | 
|---|
| 210 |  | 
|---|
| 211 | class WhileStmt : public Statement { | 
|---|
| 212 | public: | 
|---|
| 213 | Expression *condition; | 
|---|
| 214 | Statement *body; | 
|---|
| 215 | bool isDoWhile; | 
|---|
| 216 |  | 
|---|
| 217 | WhileStmt( Expression *condition, | 
|---|
| 218 | Statement *body, bool isDoWhile = false ); | 
|---|
| 219 | WhileStmt( const WhileStmt &other ); | 
|---|
| 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; } | 
|---|
| 227 |  | 
|---|
| 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 ); } | 
|---|
| 231 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 232 | }; | 
|---|
| 233 |  | 
|---|
| 234 | class ForStmt : public Statement { | 
|---|
| 235 | public: | 
|---|
| 236 | std::list<Statement *> initialization; | 
|---|
| 237 | Expression *condition; | 
|---|
| 238 | Expression *increment; | 
|---|
| 239 | Statement *body; | 
|---|
| 240 |  | 
|---|
| 241 | ForStmt( std::list<Statement *> initialization, | 
|---|
| 242 | Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); | 
|---|
| 243 | ForStmt( const ForStmt &other ); | 
|---|
| 244 |  | 
|---|
| 245 | std::list<Statement *> &get_initialization() { return initialization; } | 
|---|
| 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; } | 
|---|
| 252 |  | 
|---|
| 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 ); } | 
|---|
| 256 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 257 | }; | 
|---|
| 258 |  | 
|---|
| 259 | class BranchStmt : public Statement { | 
|---|
| 260 | public: | 
|---|
| 261 | enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault }; | 
|---|
| 262 |  | 
|---|
| 263 | // originalTarget kept for error messages. | 
|---|
| 264 | const Label originalTarget; | 
|---|
| 265 | Label target; | 
|---|
| 266 | Expression *computedTarget; | 
|---|
| 267 | Type type; | 
|---|
| 268 |  | 
|---|
| 269 | BranchStmt( Label target, Type ) throw (SemanticErrorException); | 
|---|
| 270 | BranchStmt( Expression *computedTarget, Type ) throw (SemanticErrorException); | 
|---|
| 271 |  | 
|---|
| 272 | Label get_originalTarget() { return originalTarget; } | 
|---|
| 273 | Label get_target() { return target; } | 
|---|
| 274 | void set_target( Label newValue ) { target = newValue; } | 
|---|
| 275 |  | 
|---|
| 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 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 ); } | 
|---|
| 285 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 286 | private: | 
|---|
| 287 | static const char *brType[]; | 
|---|
| 288 | }; | 
|---|
| 289 |  | 
|---|
| 290 | class ReturnStmt : public Statement { | 
|---|
| 291 | public: | 
|---|
| 292 | Expression *expr; | 
|---|
| 293 |  | 
|---|
| 294 | ReturnStmt( Expression *expr ); | 
|---|
| 295 | ReturnStmt( const ReturnStmt &other ); | 
|---|
| 296 |  | 
|---|
| 297 | Expression *get_expr() { return expr; } | 
|---|
| 298 | void set_expr( Expression *newValue ) { expr = newValue; } | 
|---|
| 299 |  | 
|---|
| 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 ); } | 
|---|
| 303 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 304 | }; | 
|---|
| 305 |  | 
|---|
| 306 | class ThrowStmt : public Statement { | 
|---|
| 307 | public: | 
|---|
| 308 | enum Kind { Terminate, Resume }; | 
|---|
| 309 |  | 
|---|
| 310 | const Kind kind; | 
|---|
| 311 | Expression * expr; | 
|---|
| 312 | Expression * target; | 
|---|
| 313 |  | 
|---|
| 314 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); | 
|---|
| 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 |  | 
|---|
| 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 ); } | 
|---|
| 326 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 327 | }; | 
|---|
| 328 |  | 
|---|
| 329 | class TryStmt : public Statement { | 
|---|
| 330 | public: | 
|---|
| 331 | CompoundStmt * block; | 
|---|
| 332 | std::list<CatchStmt *> handlers; | 
|---|
| 333 | FinallyStmt * finallyBlock; | 
|---|
| 334 |  | 
|---|
| 335 | TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); | 
|---|
| 336 | TryStmt( const TryStmt &other ); | 
|---|
| 337 |  | 
|---|
| 338 | CompoundStmt *get_block() const { return block; } | 
|---|
| 339 | void set_block( CompoundStmt *newValue ) { block = newValue; } | 
|---|
| 340 | std::list<CatchStmt *>& get_catchers() { return handlers; } | 
|---|
| 341 |  | 
|---|
| 342 | FinallyStmt *get_finally() const { return finallyBlock; } | 
|---|
| 343 | void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; } | 
|---|
| 344 |  | 
|---|
| 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 ); } | 
|---|
| 348 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 349 | }; | 
|---|
| 350 |  | 
|---|
| 351 | class CatchStmt : public Statement { | 
|---|
| 352 | public: | 
|---|
| 353 | enum Kind { Terminate, Resume }; | 
|---|
| 354 |  | 
|---|
| 355 | const Kind kind; | 
|---|
| 356 | Declaration *decl; | 
|---|
| 357 | Expression *cond; | 
|---|
| 358 | Statement *body; | 
|---|
| 359 |  | 
|---|
| 360 | CatchStmt( Kind kind, Declaration *decl, | 
|---|
| 361 | Expression *cond, Statement *body ); | 
|---|
| 362 | CatchStmt( const CatchStmt &other ); | 
|---|
| 363 |  | 
|---|
| 364 | Kind get_kind() { return kind; } | 
|---|
| 365 | Declaration *get_decl() { return decl; } | 
|---|
| 366 | void set_decl( Declaration *newValue ) { decl = newValue; } | 
|---|
| 367 | Expression *get_cond() { return cond; } | 
|---|
| 368 | void set_cond( Expression *newCond ) { cond = newCond; } | 
|---|
| 369 | Statement *get_body() { return body; } | 
|---|
| 370 | void set_body( Statement *newValue ) { body = newValue; } | 
|---|
| 371 |  | 
|---|
| 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 ); } | 
|---|
| 375 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 376 | }; | 
|---|
| 377 |  | 
|---|
| 378 | class FinallyStmt : public Statement { | 
|---|
| 379 | public: | 
|---|
| 380 | CompoundStmt *block; | 
|---|
| 381 |  | 
|---|
| 382 | FinallyStmt( CompoundStmt *block ); | 
|---|
| 383 | FinallyStmt( const FinallyStmt &other ); | 
|---|
| 384 |  | 
|---|
| 385 | CompoundStmt *get_block() const { return block; } | 
|---|
| 386 | void set_block( CompoundStmt *newValue ) { block = newValue; } | 
|---|
| 387 |  | 
|---|
| 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 ); } | 
|---|
| 391 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 392 | }; | 
|---|
| 393 |  | 
|---|
| 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 |  | 
|---|
| 408 | WaitForStmt(); | 
|---|
| 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 |  | 
|---|
| 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 ); } | 
|---|
| 427 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 428 |  | 
|---|
| 429 | }; | 
|---|
| 430 |  | 
|---|
| 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 |  | 
|---|
| 445 |  | 
|---|
| 446 | // represents a declaration that occurs as part of a compound statement | 
|---|
| 447 | class DeclStmt : public Statement { | 
|---|
| 448 | public: | 
|---|
| 449 | Declaration *decl; | 
|---|
| 450 |  | 
|---|
| 451 | DeclStmt( Declaration *decl ); | 
|---|
| 452 | DeclStmt( const DeclStmt &other ); | 
|---|
| 453 |  | 
|---|
| 454 | Declaration *get_decl() const { return decl; } | 
|---|
| 455 | void set_decl( Declaration *newValue ) { decl = newValue; } | 
|---|
| 456 |  | 
|---|
| 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 ); } | 
|---|
| 460 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 461 | }; | 
|---|
| 462 |  | 
|---|
| 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: | 
|---|
| 469 | // Non-owned pointer to the constructor/destructor statement | 
|---|
| 470 | Statement * callStmt; | 
|---|
| 471 |  | 
|---|
| 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 |  | 
|---|
| 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 ); } | 
|---|
| 481 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| 482 | }; | 
|---|
| 483 |  | 
|---|
| 484 | // Local Variables: // | 
|---|
| 485 | // tab-width: 4 // | 
|---|
| 486 | // mode: c++ // | 
|---|
| 487 | // compile-command: "make install" // | 
|---|
| 488 | // End: // | 
|---|