| 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 | virtual ~Statement();
|
|---|
| 41 |
|
|---|
| 42 | std::list<Label> & get_labels() { return labels; }
|
|---|
| 43 | const std::list<Label> & get_labels() const { return labels; }
|
|---|
| 44 |
|
|---|
| 45 | virtual Statement *clone() const override = 0;
|
|---|
| 46 | virtual void accept( Visitor &v ) override = 0;
|
|---|
| 47 | virtual Statement *acceptMutator( Mutator &m ) override = 0;
|
|---|
| 48 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | class CompoundStmt : public Statement {
|
|---|
| 52 | public:
|
|---|
| 53 | std::list<Statement*> kids;
|
|---|
| 54 |
|
|---|
| 55 | CompoundStmt();
|
|---|
| 56 | CompoundStmt( std::list<Statement *> stmts );
|
|---|
| 57 | CompoundStmt( const CompoundStmt &other );
|
|---|
| 58 | virtual ~CompoundStmt();
|
|---|
| 59 |
|
|---|
| 60 | std::list<Statement*>& get_kids() { return kids; }
|
|---|
| 61 | void push_back( Statement * stmt ) { kids.push_back( stmt ); }
|
|---|
| 62 | void push_front( Statement * stmt ) { kids.push_front( stmt ); }
|
|---|
| 63 |
|
|---|
| 64 | virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); }
|
|---|
| 65 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 66 | virtual CompoundStmt *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 67 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 | class NullStmt : public Statement {
|
|---|
| 71 | public:
|
|---|
| 72 | NullStmt( const std::list<Label> & labels = {} );
|
|---|
| 73 |
|
|---|
| 74 | virtual NullStmt *clone() const override { return new NullStmt( *this ); }
|
|---|
| 75 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 76 | virtual NullStmt *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 77 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 78 | };
|
|---|
| 79 |
|
|---|
| 80 | class ExprStmt : public Statement {
|
|---|
| 81 | public:
|
|---|
| 82 | Expression *expr;
|
|---|
| 83 |
|
|---|
| 84 | ExprStmt( Expression *expr );
|
|---|
| 85 | ExprStmt( const ExprStmt &other );
|
|---|
| 86 | virtual ~ExprStmt();
|
|---|
| 87 |
|
|---|
| 88 | Expression *get_expr() { return expr; }
|
|---|
| 89 | void set_expr( Expression *newValue ) { expr = newValue; }
|
|---|
| 90 |
|
|---|
| 91 | virtual ExprStmt *clone() const override { return new ExprStmt( *this ); }
|
|---|
| 92 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 93 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 94 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 95 | };
|
|---|
| 96 |
|
|---|
| 97 | class AsmStmt : public Statement {
|
|---|
| 98 | public:
|
|---|
| 99 | bool voltile;
|
|---|
| 100 | Expression *instruction;
|
|---|
| 101 | std::list<Expression *> output, input;
|
|---|
| 102 | std::list<ConstantExpr *> clobber;
|
|---|
| 103 | std::list<Label> gotolabels;
|
|---|
| 104 |
|
|---|
| 105 | AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
|
|---|
| 106 | AsmStmt( const AsmStmt &other );
|
|---|
| 107 | virtual ~AsmStmt();
|
|---|
| 108 |
|
|---|
| 109 | bool get_voltile() { return voltile; }
|
|---|
| 110 | void set_voltile( bool newValue ) { voltile = newValue; }
|
|---|
| 111 | Expression * get_instruction() { return instruction; }
|
|---|
| 112 | void set_instruction( Expression * newValue ) { instruction = newValue; }
|
|---|
| 113 | std::list<Expression *> & get_output() { return output; }
|
|---|
| 114 | void set_output( const std::list<Expression *> & newValue ) { output = newValue; }
|
|---|
| 115 | std::list<Expression *> & get_input() { return input; }
|
|---|
| 116 | void set_input( const std::list<Expression *> &newValue ) { input = newValue; }
|
|---|
| 117 | std::list<ConstantExpr *> & get_clobber() { return clobber; }
|
|---|
| 118 | void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; }
|
|---|
| 119 | std::list<Label> & get_gotolabels() { return gotolabels; }
|
|---|
| 120 | void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; }
|
|---|
| 121 |
|
|---|
| 122 | virtual AsmStmt * clone() const { return new AsmStmt( *this ); }
|
|---|
| 123 | virtual void accept( Visitor & v ) { v.visit( this ); }
|
|---|
| 124 | virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); }
|
|---|
| 125 | virtual void print( std::ostream & os, Indenter indent = {} ) const;
|
|---|
| 126 | };
|
|---|
| 127 |
|
|---|
| 128 | class IfStmt : public Statement {
|
|---|
| 129 | public:
|
|---|
| 130 | Expression *condition;
|
|---|
| 131 | Statement *thenPart;
|
|---|
| 132 | Statement *elsePart;
|
|---|
| 133 | std::list<Statement *> initialization;
|
|---|
| 134 |
|
|---|
| 135 | IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart,
|
|---|
| 136 | std::list<Statement *> initialization = std::list<Statement *>() );
|
|---|
| 137 | IfStmt( const IfStmt &other );
|
|---|
| 138 | virtual ~IfStmt();
|
|---|
| 139 |
|
|---|
| 140 | std::list<Statement *> &get_initialization() { return initialization; }
|
|---|
| 141 | Expression *get_condition() { return condition; }
|
|---|
| 142 | void set_condition( Expression *newValue ) { condition = newValue; }
|
|---|
| 143 | Statement *get_thenPart() { return thenPart; }
|
|---|
| 144 | void set_thenPart( Statement *newValue ) { thenPart = newValue; }
|
|---|
| 145 | Statement *get_elsePart() { return elsePart; }
|
|---|
| 146 | void set_elsePart( Statement *newValue ) { elsePart = newValue; }
|
|---|
| 147 |
|
|---|
| 148 | virtual IfStmt *clone() const override { return new IfStmt( *this ); }
|
|---|
| 149 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 150 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 151 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 152 | };
|
|---|
| 153 |
|
|---|
| 154 | class SwitchStmt : public Statement {
|
|---|
| 155 | public:
|
|---|
| 156 | Expression * condition;
|
|---|
| 157 | std::list<Statement *> statements;
|
|---|
| 158 |
|
|---|
| 159 | SwitchStmt( Expression *condition, const std::list<Statement *> &statements );
|
|---|
| 160 | SwitchStmt( const SwitchStmt &other );
|
|---|
| 161 | virtual ~SwitchStmt();
|
|---|
| 162 |
|
|---|
| 163 | Expression *get_condition() { return condition; }
|
|---|
| 164 | void set_condition( Expression *newValue ) { condition = newValue; }
|
|---|
| 165 |
|
|---|
| 166 | std::list<Statement *> & get_statements() { return statements; }
|
|---|
| 167 |
|
|---|
| 168 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 169 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 170 |
|
|---|
| 171 | virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
|
|---|
| 172 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 173 |
|
|---|
| 174 | };
|
|---|
| 175 |
|
|---|
| 176 | class CaseStmt : public Statement {
|
|---|
| 177 | public:
|
|---|
| 178 | Expression * condition;
|
|---|
| 179 | std::list<Statement *> stmts;
|
|---|
| 180 |
|
|---|
| 181 | CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException);
|
|---|
| 182 | CaseStmt( const CaseStmt &other );
|
|---|
| 183 | virtual ~CaseStmt();
|
|---|
| 184 |
|
|---|
| 185 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() );
|
|---|
| 186 |
|
|---|
| 187 | bool isDefault() const { return _isDefault; }
|
|---|
| 188 | void set_default(bool b) { _isDefault = b; }
|
|---|
| 189 |
|
|---|
| 190 | Expression * &get_condition() { return condition; }
|
|---|
| 191 | void set_condition( Expression *newValue ) { condition = newValue; }
|
|---|
| 192 |
|
|---|
| 193 | std::list<Statement *> &get_statements() { return stmts; }
|
|---|
| 194 | void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
|
|---|
| 195 |
|
|---|
| 196 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 197 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 198 |
|
|---|
| 199 | virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
|
|---|
| 200 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 201 | private:
|
|---|
| 202 | bool _isDefault;
|
|---|
| 203 | };
|
|---|
| 204 |
|
|---|
| 205 | class WhileStmt : public Statement {
|
|---|
| 206 | public:
|
|---|
| 207 | Expression *condition;
|
|---|
| 208 | Statement *body;
|
|---|
| 209 | bool isDoWhile;
|
|---|
| 210 |
|
|---|
| 211 | WhileStmt( Expression *condition,
|
|---|
| 212 | Statement *body, bool isDoWhile = false );
|
|---|
| 213 | WhileStmt( const WhileStmt &other );
|
|---|
| 214 | virtual ~WhileStmt();
|
|---|
| 215 |
|
|---|
| 216 | Expression *get_condition() { return condition; }
|
|---|
| 217 | void set_condition( Expression *newValue ) { condition = newValue; }
|
|---|
| 218 | Statement *get_body() { return body; }
|
|---|
| 219 | void set_body( Statement *newValue ) { body = newValue; }
|
|---|
| 220 | bool get_isDoWhile() { return isDoWhile; }
|
|---|
| 221 | void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
|
|---|
| 222 |
|
|---|
| 223 | virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
|
|---|
| 224 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 225 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 226 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 227 | };
|
|---|
| 228 |
|
|---|
| 229 | class ForStmt : public Statement {
|
|---|
| 230 | public:
|
|---|
| 231 | std::list<Statement *> initialization;
|
|---|
| 232 | Expression *condition;
|
|---|
| 233 | Expression *increment;
|
|---|
| 234 | Statement *body;
|
|---|
| 235 |
|
|---|
| 236 | ForStmt( std::list<Statement *> initialization,
|
|---|
| 237 | Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
|
|---|
| 238 | ForStmt( const ForStmt &other );
|
|---|
| 239 | virtual ~ForStmt();
|
|---|
| 240 |
|
|---|
| 241 | std::list<Statement *> &get_initialization() { return initialization; }
|
|---|
| 242 | Expression *get_condition() { return condition; }
|
|---|
| 243 | void set_condition( Expression *newValue ) { condition = newValue; }
|
|---|
| 244 | Expression *get_increment() { return increment; }
|
|---|
| 245 | void set_increment( Expression *newValue ) { increment = newValue; }
|
|---|
| 246 | Statement *get_body() { return body; }
|
|---|
| 247 | void set_body( Statement *newValue ) { body = newValue; }
|
|---|
| 248 |
|
|---|
| 249 | virtual ForStmt *clone() const override { return new ForStmt( *this ); }
|
|---|
| 250 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 251 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 252 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 253 | };
|
|---|
| 254 |
|
|---|
| 255 | class BranchStmt : public Statement {
|
|---|
| 256 | public:
|
|---|
| 257 | enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault };
|
|---|
| 258 |
|
|---|
| 259 | // originalTarget kept for error messages.
|
|---|
| 260 | const Label originalTarget;
|
|---|
| 261 | Label target;
|
|---|
| 262 | Expression *computedTarget;
|
|---|
| 263 | Type type;
|
|---|
| 264 |
|
|---|
| 265 | BranchStmt( Label target, Type ) throw (SemanticErrorException);
|
|---|
| 266 | BranchStmt( Expression *computedTarget, Type ) throw (SemanticErrorException);
|
|---|
| 267 |
|
|---|
| 268 | Label get_originalTarget() { return originalTarget; }
|
|---|
| 269 | Label get_target() { return target; }
|
|---|
| 270 | void set_target( Label newValue ) { target = newValue; }
|
|---|
| 271 |
|
|---|
| 272 | Expression *get_computedTarget() { return computedTarget; }
|
|---|
| 273 | void set_target( Expression * newValue ) { computedTarget = newValue; }
|
|---|
| 274 |
|
|---|
| 275 | Type get_type() { return type; }
|
|---|
| 276 | const char *get_typename() { return brType[ type ]; }
|
|---|
| 277 |
|
|---|
| 278 | virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
|
|---|
| 279 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 280 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 281 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 282 | private:
|
|---|
| 283 | static const char *brType[];
|
|---|
| 284 | };
|
|---|
| 285 |
|
|---|
| 286 | class ReturnStmt : public Statement {
|
|---|
| 287 | public:
|
|---|
| 288 | Expression *expr;
|
|---|
| 289 |
|
|---|
| 290 | ReturnStmt( Expression *expr );
|
|---|
| 291 | ReturnStmt( const ReturnStmt &other );
|
|---|
| 292 | virtual ~ReturnStmt();
|
|---|
| 293 |
|
|---|
| 294 | Expression *get_expr() { return expr; }
|
|---|
| 295 | void set_expr( Expression *newValue ) { expr = newValue; }
|
|---|
| 296 |
|
|---|
| 297 | virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
|
|---|
| 298 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 299 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 300 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 301 | };
|
|---|
| 302 |
|
|---|
| 303 | class ThrowStmt : public Statement {
|
|---|
| 304 | public:
|
|---|
| 305 | enum Kind { Terminate, Resume };
|
|---|
| 306 |
|
|---|
| 307 | const Kind kind;
|
|---|
| 308 | Expression * expr;
|
|---|
| 309 | Expression * target;
|
|---|
| 310 |
|
|---|
| 311 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr );
|
|---|
| 312 | ThrowStmt( const ThrowStmt &other );
|
|---|
| 313 | virtual ~ThrowStmt();
|
|---|
| 314 |
|
|---|
| 315 | Kind get_kind() { return kind; }
|
|---|
| 316 | Expression * get_expr() { return expr; }
|
|---|
| 317 | void set_expr( Expression * newExpr ) { expr = newExpr; }
|
|---|
| 318 | Expression * get_target() { return target; }
|
|---|
| 319 | void set_target( Expression * newTarget ) { target = newTarget; }
|
|---|
| 320 |
|
|---|
| 321 | virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
|
|---|
| 322 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 323 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 324 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 325 | };
|
|---|
| 326 |
|
|---|
| 327 | class TryStmt : public Statement {
|
|---|
| 328 | public:
|
|---|
| 329 | CompoundStmt * block;
|
|---|
| 330 | std::list<CatchStmt *> handlers;
|
|---|
| 331 | FinallyStmt * finallyBlock;
|
|---|
| 332 |
|
|---|
| 333 | TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
|
|---|
| 334 | TryStmt( const TryStmt &other );
|
|---|
| 335 | virtual ~TryStmt();
|
|---|
| 336 |
|
|---|
| 337 | CompoundStmt *get_block() const { return block; }
|
|---|
| 338 | void set_block( CompoundStmt *newValue ) { block = newValue; }
|
|---|
| 339 | std::list<CatchStmt *>& get_catchers() { return handlers; }
|
|---|
| 340 |
|
|---|
| 341 | FinallyStmt *get_finally() const { return finallyBlock; }
|
|---|
| 342 | void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
|
|---|
| 343 |
|
|---|
| 344 | virtual TryStmt *clone() const override { return new TryStmt( *this ); }
|
|---|
| 345 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 346 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 347 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 348 | };
|
|---|
| 349 |
|
|---|
| 350 | class CatchStmt : public Statement {
|
|---|
| 351 | public:
|
|---|
| 352 | enum Kind { Terminate, Resume };
|
|---|
| 353 |
|
|---|
| 354 | const Kind kind;
|
|---|
| 355 | Declaration *decl;
|
|---|
| 356 | Expression *cond;
|
|---|
| 357 | Statement *body;
|
|---|
| 358 |
|
|---|
| 359 | CatchStmt( Kind kind, Declaration *decl,
|
|---|
| 360 | Expression *cond, Statement *body );
|
|---|
| 361 | CatchStmt( const CatchStmt &other );
|
|---|
| 362 | virtual ~CatchStmt();
|
|---|
| 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 | virtual ~FinallyStmt();
|
|---|
| 385 |
|
|---|
| 386 | CompoundStmt *get_block() const { return block; }
|
|---|
| 387 | void set_block( CompoundStmt *newValue ) { block = newValue; }
|
|---|
| 388 |
|
|---|
| 389 | virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
|
|---|
| 390 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 391 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 392 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 393 | };
|
|---|
| 394 |
|
|---|
| 395 | class WaitForStmt : public Statement {
|
|---|
| 396 | public:
|
|---|
| 397 |
|
|---|
| 398 | struct Target {
|
|---|
| 399 | Expression * function;
|
|---|
| 400 | std::list<Expression * > arguments;
|
|---|
| 401 | };
|
|---|
| 402 |
|
|---|
| 403 | struct Clause {
|
|---|
| 404 | Target target;
|
|---|
| 405 | Statement * statement;
|
|---|
| 406 | Expression * condition;
|
|---|
| 407 | };
|
|---|
| 408 |
|
|---|
| 409 | WaitForStmt();
|
|---|
| 410 | WaitForStmt( const WaitForStmt & );
|
|---|
| 411 | virtual ~WaitForStmt();
|
|---|
| 412 |
|
|---|
| 413 | std::vector<Clause> clauses;
|
|---|
| 414 |
|
|---|
| 415 | struct {
|
|---|
| 416 | Expression * time;
|
|---|
| 417 | Statement * statement;
|
|---|
| 418 | Expression * condition;
|
|---|
| 419 | } timeout;
|
|---|
| 420 |
|
|---|
| 421 | struct {
|
|---|
| 422 | Statement * statement;
|
|---|
| 423 | Expression * condition;
|
|---|
| 424 | } orelse;
|
|---|
| 425 |
|
|---|
| 426 | virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
|
|---|
| 427 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 428 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 429 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 430 |
|
|---|
| 431 | };
|
|---|
| 432 |
|
|---|
| 433 | class WithStmt : public Statement {
|
|---|
| 434 | public:
|
|---|
| 435 | std::list< Expression * > exprs;
|
|---|
| 436 | Statement * stmt;
|
|---|
| 437 |
|
|---|
| 438 | WithStmt( const std::list< Expression * > & exprs, Statement * stmt );
|
|---|
| 439 | WithStmt( const WithStmt & other );
|
|---|
| 440 | virtual ~WithStmt();
|
|---|
| 441 |
|
|---|
| 442 | virtual WithStmt * clone() const override { return new WithStmt( *this ); }
|
|---|
| 443 | virtual void accept( Visitor & v ) override { v.visit( this ); }
|
|---|
| 444 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
|
|---|
| 445 | virtual void print( std::ostream & os, Indenter indent = {} ) const override;
|
|---|
| 446 | };
|
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 | // represents a declaration that occurs as part of a compound statement
|
|---|
| 450 | class DeclStmt : public Statement {
|
|---|
| 451 | public:
|
|---|
| 452 | Declaration *decl;
|
|---|
| 453 |
|
|---|
| 454 | DeclStmt( Declaration *decl );
|
|---|
| 455 | DeclStmt( const DeclStmt &other );
|
|---|
| 456 | virtual ~DeclStmt();
|
|---|
| 457 |
|
|---|
| 458 | Declaration *get_decl() const { return decl; }
|
|---|
| 459 | void set_decl( Declaration *newValue ) { decl = newValue; }
|
|---|
| 460 |
|
|---|
| 461 | virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
|
|---|
| 462 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 463 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 464 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 465 | };
|
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced
|
|---|
| 469 | /// immediately before and after the call so that qualified objects can be constructed
|
|---|
| 470 | /// with the same functions as unqualified objects.
|
|---|
| 471 | class ImplicitCtorDtorStmt : public Statement {
|
|---|
| 472 | public:
|
|---|
| 473 | // Non-owned pointer to the constructor/destructor statement
|
|---|
| 474 | Statement * callStmt;
|
|---|
| 475 |
|
|---|
| 476 | ImplicitCtorDtorStmt( Statement * callStmt );
|
|---|
| 477 | ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
|
|---|
| 478 | virtual ~ImplicitCtorDtorStmt();
|
|---|
| 479 |
|
|---|
| 480 | Statement *get_callStmt() const { return callStmt; }
|
|---|
| 481 | void set_callStmt( Statement * newValue ) { callStmt = newValue; }
|
|---|
| 482 |
|
|---|
| 483 | virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
|
|---|
| 484 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
|---|
| 485 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
|---|
| 486 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
|---|
| 487 | };
|
|---|
| 488 |
|
|---|
| 489 | // Local Variables: //
|
|---|
| 490 | // tab-width: 4 //
|
|---|
| 491 | // mode: c++ //
|
|---|
| 492 | // compile-command: "make install" //
|
|---|
| 493 | // End: //
|
|---|