[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
|
---|
[51b73452] | 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;
|
---|
[51b73452] | 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 = {} );
|
---|
[51b73452] | 40 |
|
---|
[0dd3a2f] | 41 | std::list<Label> & get_labels() { return labels; }
|
---|
[de62360d] | 42 | const std::list<Label> & get_labels() const { return labels; }
|
---|
[51b73452] | 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;
|
---|
[51b73452] | 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 );
|
---|
[51b73452] | 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 ); }
|
---|
[51b73452] | 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;
|
---|
[51b73452] | 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 );
|
---|
[51b73452] | 84 |
|
---|
[0dd3a2f] | 85 | Expression *get_expr() { return expr; }
|
---|
| 86 | void set_expr( Expression *newValue ) { expr = newValue; }
|
---|
[51b73452] | 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 | };
|
---|
[51b73452] | 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 |
|
---|
[0dd3a2f] | 124 | class IfStmt : public Statement {
|
---|
| 125 | public:
|
---|
[65cdc1e] | 126 | Expression *condition;
|
---|
| 127 | Statement *thenPart;
|
---|
| 128 | Statement *elsePart;
|
---|
[6d49ea3] | 129 | std::list<Statement *> initialization;
|
---|
[65cdc1e] | 130 |
|
---|
[ba3706f] | 131 | IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart,
|
---|
[6d49ea3] | 132 | std::list<Statement *> initialization = std::list<Statement *>() );
|
---|
[3be261a] | 133 | IfStmt( const IfStmt &other );
|
---|
[0dd3a2f] | 134 |
|
---|
[936e9f4] | 135 | std::list<Statement *> &get_initialization() { return initialization; }
|
---|
[0dd3a2f] | 136 | Expression *get_condition() { return condition; }
|
---|
| 137 | void set_condition( Expression *newValue ) { condition = newValue; }
|
---|
| 138 | Statement *get_thenPart() { return thenPart; }
|
---|
| 139 | void set_thenPart( Statement *newValue ) { thenPart = newValue; }
|
---|
| 140 | Statement *get_elsePart() { return elsePart; }
|
---|
| 141 | void set_elsePart( Statement *newValue ) { elsePart = newValue; }
|
---|
[3be261a] | 142 |
|
---|
[e149f77] | 143 | virtual IfStmt *clone() const override { return new IfStmt( *this ); }
|
---|
| 144 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 145 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 146 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 147 | };
|
---|
| 148 |
|
---|
[0dd3a2f] | 149 | class SwitchStmt : public Statement {
|
---|
| 150 | public:
|
---|
[65cdc1e] | 151 | Expression * condition;
|
---|
[871cdb4] | 152 | std::list<Statement *> statements;
|
---|
[65cdc1e] | 153 |
|
---|
[ba3706f] | 154 | SwitchStmt( Expression *condition, const std::list<Statement *> &statements );
|
---|
[3be261a] | 155 | SwitchStmt( const SwitchStmt &other );
|
---|
[51b73452] | 156 |
|
---|
[0dd3a2f] | 157 | Expression *get_condition() { return condition; }
|
---|
| 158 | void set_condition( Expression *newValue ) { condition = newValue; }
|
---|
[51b73452] | 159 |
|
---|
[8688ce1] | 160 | std::list<Statement *> & get_statements() { return statements; }
|
---|
[51b73452] | 161 |
|
---|
[e149f77] | 162 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 163 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[51b73452] | 164 |
|
---|
[e149f77] | 165 | virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
|
---|
[50377a4] | 166 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[871cdb4] | 167 |
|
---|
[51b73452] | 168 | };
|
---|
| 169 |
|
---|
[0dd3a2f] | 170 | class CaseStmt : public Statement {
|
---|
| 171 | public:
|
---|
[65cdc1e] | 172 | Expression * condition;
|
---|
| 173 | std::list<Statement *> stmts;
|
---|
| 174 |
|
---|
[a16764a6] | 175 | CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException);
|
---|
[3be261a] | 176 | CaseStmt( const CaseStmt &other );
|
---|
[0dd3a2f] | 177 |
|
---|
[ba3706f] | 178 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() );
|
---|
[b2152e7a] | 179 |
|
---|
[de62360d] | 180 | bool isDefault() const { return _isDefault; }
|
---|
[0dd3a2f] | 181 | void set_default(bool b) { _isDefault = b; }
|
---|
| 182 |
|
---|
| 183 | Expression * &get_condition() { return condition; }
|
---|
| 184 | void set_condition( Expression *newValue ) { condition = newValue; }
|
---|
| 185 |
|
---|
| 186 | std::list<Statement *> &get_statements() { return stmts; }
|
---|
| 187 | void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
|
---|
[3be261a] | 188 |
|
---|
[e149f77] | 189 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 190 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[0dd3a2f] | 191 |
|
---|
[e149f77] | 192 | virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
|
---|
[50377a4] | 193 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[0dd3a2f] | 194 | private:
|
---|
| 195 | bool _isDefault;
|
---|
[51b73452] | 196 | };
|
---|
| 197 |
|
---|
[0dd3a2f] | 198 | class WhileStmt : public Statement {
|
---|
| 199 | public:
|
---|
[65cdc1e] | 200 | Expression *condition;
|
---|
| 201 | Statement *body;
|
---|
| 202 | bool isDoWhile;
|
---|
| 203 |
|
---|
[ba3706f] | 204 | WhileStmt( Expression *condition,
|
---|
[0dd3a2f] | 205 | Statement *body, bool isDoWhile = false );
|
---|
[3be261a] | 206 | WhileStmt( const WhileStmt &other );
|
---|
[0dd3a2f] | 207 |
|
---|
| 208 | Expression *get_condition() { return condition; }
|
---|
| 209 | void set_condition( Expression *newValue ) { condition = newValue; }
|
---|
| 210 | Statement *get_body() { return body; }
|
---|
| 211 | void set_body( Statement *newValue ) { body = newValue; }
|
---|
| 212 | bool get_isDoWhile() { return isDoWhile; }
|
---|
| 213 | void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
|
---|
[3be261a] | 214 |
|
---|
[e149f77] | 215 | virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
|
---|
| 216 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 217 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 218 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 219 | };
|
---|
| 220 |
|
---|
[0dd3a2f] | 221 | class ForStmt : public Statement {
|
---|
| 222 | public:
|
---|
[65cdc1e] | 223 | std::list<Statement *> initialization;
|
---|
| 224 | Expression *condition;
|
---|
| 225 | Expression *increment;
|
---|
| 226 | Statement *body;
|
---|
| 227 |
|
---|
[ba3706f] | 228 | ForStmt( std::list<Statement *> initialization,
|
---|
[0dd3a2f] | 229 | Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
|
---|
[3be261a] | 230 | ForStmt( const ForStmt &other );
|
---|
[0dd3a2f] | 231 |
|
---|
[145f1fc] | 232 | std::list<Statement *> &get_initialization() { return initialization; }
|
---|
[0dd3a2f] | 233 | Expression *get_condition() { return condition; }
|
---|
| 234 | void set_condition( Expression *newValue ) { condition = newValue; }
|
---|
| 235 | Expression *get_increment() { return increment; }
|
---|
| 236 | void set_increment( Expression *newValue ) { increment = newValue; }
|
---|
| 237 | Statement *get_body() { return body; }
|
---|
| 238 | void set_body( Statement *newValue ) { body = newValue; }
|
---|
[3be261a] | 239 |
|
---|
[e149f77] | 240 | virtual ForStmt *clone() const override { return new ForStmt( *this ); }
|
---|
| 241 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 242 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 243 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 244 | };
|
---|
| 245 |
|
---|
[0dd3a2f] | 246 | class BranchStmt : public Statement {
|
---|
| 247 | public:
|
---|
[6a276a0] | 248 | enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault };
|
---|
[0dd3a2f] | 249 |
|
---|
[65cdc1e] | 250 | // originalTarget kept for error messages.
|
---|
| 251 | const Label originalTarget;
|
---|
| 252 | Label target;
|
---|
| 253 | Expression *computedTarget;
|
---|
| 254 | Type type;
|
---|
| 255 |
|
---|
[a16764a6] | 256 | BranchStmt( Label target, Type ) throw (SemanticErrorException);
|
---|
| 257 | BranchStmt( Expression *computedTarget, Type ) throw (SemanticErrorException);
|
---|
[0dd3a2f] | 258 |
|
---|
[be5aa1b] | 259 | Label get_originalTarget() { return originalTarget; }
|
---|
[0dd3a2f] | 260 | Label get_target() { return target; }
|
---|
| 261 | void set_target( Label newValue ) { target = newValue; }
|
---|
[3be261a] | 262 |
|
---|
[0dd3a2f] | 263 | Expression *get_computedTarget() { return computedTarget; }
|
---|
| 264 | void set_target( Expression * newValue ) { computedTarget = newValue; }
|
---|
| 265 |
|
---|
| 266 | Type get_type() { return type; }
|
---|
| 267 | const char *get_typename() { return brType[ type ]; }
|
---|
| 268 |
|
---|
[e149f77] | 269 | virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
|
---|
| 270 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 271 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 272 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[0dd3a2f] | 273 | private:
|
---|
| 274 | static const char *brType[];
|
---|
[51b73452] | 275 | };
|
---|
| 276 |
|
---|
[0dd3a2f] | 277 | class ReturnStmt : public Statement {
|
---|
| 278 | public:
|
---|
[65cdc1e] | 279 | Expression *expr;
|
---|
| 280 |
|
---|
[ba3706f] | 281 | ReturnStmt( Expression *expr );
|
---|
[3be261a] | 282 | ReturnStmt( const ReturnStmt &other );
|
---|
[0dd3a2f] | 283 |
|
---|
| 284 | Expression *get_expr() { return expr; }
|
---|
| 285 | void set_expr( Expression *newValue ) { expr = newValue; }
|
---|
[3be261a] | 286 |
|
---|
[e149f77] | 287 | virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
|
---|
| 288 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 289 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 290 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 291 | };
|
---|
| 292 |
|
---|
[daf1af8] | 293 | class ThrowStmt : public Statement {
|
---|
[0dd3a2f] | 294 | public:
|
---|
[daf1af8] | 295 | enum Kind { Terminate, Resume };
|
---|
[51b73452] | 296 |
|
---|
[65cdc1e] | 297 | const Kind kind;
|
---|
| 298 | Expression * expr;
|
---|
| 299 | Expression * target;
|
---|
| 300 |
|
---|
[ba3706f] | 301 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr );
|
---|
[daf1af8] | 302 | ThrowStmt( const ThrowStmt &other );
|
---|
| 303 |
|
---|
| 304 | Kind get_kind() { return kind; }
|
---|
| 305 | Expression * get_expr() { return expr; }
|
---|
| 306 | void set_expr( Expression * newExpr ) { expr = newExpr; }
|
---|
| 307 | Expression * get_target() { return target; }
|
---|
| 308 | void set_target( Expression * newTarget ) { target = newTarget; }
|
---|
| 309 |
|
---|
[e149f77] | 310 | virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
|
---|
| 311 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 312 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 313 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 314 | };
|
---|
| 315 |
|
---|
[3be261a] | 316 | class TryStmt : public Statement {
|
---|
[0dd3a2f] | 317 | public:
|
---|
[871cdb4] | 318 | CompoundStmt * block;
|
---|
[65cdc1e] | 319 | std::list<CatchStmt *> handlers;
|
---|
[871cdb4] | 320 | FinallyStmt * finallyBlock;
|
---|
[65cdc1e] | 321 |
|
---|
[ba3706f] | 322 | TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
|
---|
[0dd3a2f] | 323 | TryStmt( const TryStmt &other );
|
---|
| 324 |
|
---|
| 325 | CompoundStmt *get_block() const { return block; }
|
---|
| 326 | void set_block( CompoundStmt *newValue ) { block = newValue; }
|
---|
[046e04a] | 327 | std::list<CatchStmt *>& get_catchers() { return handlers; }
|
---|
[0dd3a2f] | 328 |
|
---|
| 329 | FinallyStmt *get_finally() const { return finallyBlock; }
|
---|
| 330 | void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
|
---|
| 331 |
|
---|
[e149f77] | 332 | virtual TryStmt *clone() const override { return new TryStmt( *this ); }
|
---|
| 333 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 334 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 335 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[3be261a] | 336 | };
|
---|
[51b73452] | 337 |
|
---|
[0dd3a2f] | 338 | class CatchStmt : public Statement {
|
---|
| 339 | public:
|
---|
[ca78437] | 340 | enum Kind { Terminate, Resume };
|
---|
| 341 |
|
---|
[65cdc1e] | 342 | const Kind kind;
|
---|
| 343 | Declaration *decl;
|
---|
| 344 | Expression *cond;
|
---|
| 345 | Statement *body;
|
---|
| 346 |
|
---|
[ba3706f] | 347 | CatchStmt( Kind kind, Declaration *decl,
|
---|
[ca78437] | 348 | Expression *cond, Statement *body );
|
---|
[3be261a] | 349 | CatchStmt( const CatchStmt &other );
|
---|
[0dd3a2f] | 350 |
|
---|
[ca78437] | 351 | Kind get_kind() { return kind; }
|
---|
[0dd3a2f] | 352 | Declaration *get_decl() { return decl; }
|
---|
| 353 | void set_decl( Declaration *newValue ) { decl = newValue; }
|
---|
[ca78437] | 354 | Expression *get_cond() { return cond; }
|
---|
| 355 | void set_cond( Expression *newCond ) { cond = newCond; }
|
---|
[0dd3a2f] | 356 | Statement *get_body() { return body; }
|
---|
| 357 | void set_body( Statement *newValue ) { body = newValue; }
|
---|
[3be261a] | 358 |
|
---|
[e149f77] | 359 | virtual CatchStmt *clone() const override { return new CatchStmt( *this ); }
|
---|
| 360 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 361 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 362 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 363 | };
|
---|
| 364 |
|
---|
[3be261a] | 365 | class FinallyStmt : public Statement {
|
---|
[0dd3a2f] | 366 | public:
|
---|
[65cdc1e] | 367 | CompoundStmt *block;
|
---|
| 368 |
|
---|
[ba3706f] | 369 | FinallyStmt( CompoundStmt *block );
|
---|
[3be261a] | 370 | FinallyStmt( const FinallyStmt &other );
|
---|
[0dd3a2f] | 371 |
|
---|
| 372 | CompoundStmt *get_block() const { return block; }
|
---|
| 373 | void set_block( CompoundStmt *newValue ) { block = newValue; }
|
---|
[3be261a] | 374 |
|
---|
[e149f77] | 375 | virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
|
---|
| 376 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 377 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 378 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[3be261a] | 379 | };
|
---|
[51b73452] | 380 |
|
---|
[135b431] | 381 | class WaitForStmt : public Statement {
|
---|
| 382 | public:
|
---|
| 383 |
|
---|
| 384 | struct Target {
|
---|
| 385 | Expression * function;
|
---|
| 386 | std::list<Expression * > arguments;
|
---|
| 387 | };
|
---|
| 388 |
|
---|
| 389 | struct Clause {
|
---|
| 390 | Target target;
|
---|
| 391 | Statement * statement;
|
---|
| 392 | Expression * condition;
|
---|
| 393 | };
|
---|
| 394 |
|
---|
[ba3706f] | 395 | WaitForStmt();
|
---|
[135b431] | 396 | WaitForStmt( const WaitForStmt & );
|
---|
| 397 |
|
---|
| 398 | std::vector<Clause> clauses;
|
---|
| 399 |
|
---|
| 400 | struct {
|
---|
| 401 | Expression * time;
|
---|
| 402 | Statement * statement;
|
---|
| 403 | Expression * condition;
|
---|
| 404 | } timeout;
|
---|
| 405 |
|
---|
| 406 | struct {
|
---|
| 407 | Statement * statement;
|
---|
| 408 | Expression * condition;
|
---|
| 409 | } orelse;
|
---|
| 410 |
|
---|
[e149f77] | 411 | virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
|
---|
| 412 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 413 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 414 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[135b431] | 415 |
|
---|
| 416 | };
|
---|
| 417 |
|
---|
[61255ad] | 418 | class WithStmt : public Statement {
|
---|
| 419 | public:
|
---|
| 420 | std::list< Expression * > exprs;
|
---|
| 421 | Statement * stmt;
|
---|
| 422 |
|
---|
| 423 | WithStmt( const std::list< Expression * > & exprs, Statement * stmt );
|
---|
| 424 | WithStmt( const WithStmt & other );
|
---|
| 425 |
|
---|
| 426 | virtual WithStmt * clone() const override { return new WithStmt( *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 |
|
---|
[51b73452] | 432 |
|
---|
| 433 | // represents a declaration that occurs as part of a compound statement
|
---|
[0dd3a2f] | 434 | class DeclStmt : public Statement {
|
---|
| 435 | public:
|
---|
[65cdc1e] | 436 | Declaration *decl;
|
---|
| 437 |
|
---|
[ba3706f] | 438 | DeclStmt( Declaration *decl );
|
---|
[0dd3a2f] | 439 | DeclStmt( const DeclStmt &other );
|
---|
| 440 |
|
---|
[f1b1e4c] | 441 | Declaration *get_decl() const { return decl; }
|
---|
[0dd3a2f] | 442 | void set_decl( Declaration *newValue ) { decl = newValue; }
|
---|
| 443 |
|
---|
[e149f77] | 444 | virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
|
---|
| 445 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 446 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 447 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[51b73452] | 448 | };
|
---|
| 449 |
|
---|
[f1b1e4c] | 450 |
|
---|
| 451 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced
|
---|
| 452 | /// immediately before and after the call so that qualified objects can be constructed
|
---|
| 453 | /// with the same functions as unqualified objects.
|
---|
| 454 | class ImplicitCtorDtorStmt : public Statement {
|
---|
| 455 | public:
|
---|
[65cdc1e] | 456 | // Non-owned pointer to the constructor/destructor statement
|
---|
| 457 | Statement * callStmt;
|
---|
| 458 |
|
---|
[f1b1e4c] | 459 | ImplicitCtorDtorStmt( Statement * callStmt );
|
---|
| 460 | ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
|
---|
| 461 |
|
---|
| 462 | Statement *get_callStmt() const { return callStmt; }
|
---|
| 463 | void set_callStmt( Statement * newValue ) { callStmt = newValue; }
|
---|
| 464 |
|
---|
[e149f77] | 465 | virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
|
---|
| 466 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 467 | virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[50377a4] | 468 | virtual void print( std::ostream &os, Indenter indent = {} ) const override;
|
---|
[f1b1e4c] | 469 | };
|
---|
| 470 |
|
---|
[0dd3a2f] | 471 | // Local Variables: //
|
---|
| 472 | // tab-width: 4 //
|
---|
| 473 | // mode: c++ //
|
---|
| 474 | // compile-command: "make install" //
|
---|
| 475 | // End: //
|
---|