| [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 = {} ); | 
|---|
| [0dd3a2f] | 40 | virtual ~Statement(); | 
|---|
| [51b73452] | 41 |  | 
|---|
| [0dd3a2f] | 42 | std::list<Label> & get_labels() { return labels; } | 
|---|
| [de62360d] | 43 | const std::list<Label> & get_labels() const { return labels; } | 
|---|
| [51b73452] | 44 |  | 
|---|
| [fa16264] | 45 | virtual Statement *clone() const override = 0; | 
|---|
| [e149f77] | 46 | virtual void accept( Visitor &v ) override = 0; | 
|---|
| [fa16264] | 47 | virtual Statement *acceptMutator( Mutator &m ) override = 0; | 
|---|
| [50377a4] | 48 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 49 | }; | 
|---|
|  | 50 |  | 
|---|
| [0dd3a2f] | 51 | class CompoundStmt : public Statement { | 
|---|
|  | 52 | public: | 
|---|
| [65cdc1e] | 53 | std::list<Statement*> kids; | 
|---|
|  | 54 |  | 
|---|
| [ba3706f] | 55 | CompoundStmt(); | 
|---|
| [a2dbad10] | 56 | CompoundStmt( std::list<Statement *> stmts ); | 
|---|
| [0dd3a2f] | 57 | CompoundStmt( const CompoundStmt &other ); | 
|---|
|  | 58 | virtual ~CompoundStmt(); | 
|---|
| [51b73452] | 59 |  | 
|---|
| [0dd3a2f] | 60 | std::list<Statement*>& get_kids() { return kids; } | 
|---|
| [c8dfcd3] | 61 | void push_back( Statement * stmt ) { kids.push_back( stmt ); } | 
|---|
|  | 62 | void push_front( Statement * stmt ) { kids.push_front( stmt ); } | 
|---|
| [51b73452] | 63 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 67 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 68 | }; | 
|---|
|  | 69 |  | 
|---|
| [70d826cd] | 70 | class NullStmt : public Statement { | 
|---|
| [daf1af8] | 71 | public: | 
|---|
| [ba3706f] | 72 | NullStmt( const std::list<Label> & labels = {} ); | 
|---|
| [daf1af8] | 73 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 77 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [daf1af8] | 78 | }; | 
|---|
|  | 79 |  | 
|---|
| [0dd3a2f] | 80 | class ExprStmt : public Statement { | 
|---|
|  | 81 | public: | 
|---|
| [65cdc1e] | 82 | Expression *expr; | 
|---|
|  | 83 |  | 
|---|
| [ba3706f] | 84 | ExprStmt( Expression *expr ); | 
|---|
| [3be261a] | 85 | ExprStmt( const ExprStmt &other ); | 
|---|
| [0dd3a2f] | 86 | virtual ~ExprStmt(); | 
|---|
| [51b73452] | 87 |  | 
|---|
| [0dd3a2f] | 88 | Expression *get_expr() { return expr; } | 
|---|
|  | 89 | void set_expr( Expression *newValue ) { expr = newValue; } | 
|---|
| [51b73452] | 90 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 94 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [0dd3a2f] | 95 | }; | 
|---|
| [51b73452] | 96 |  | 
|---|
| [7f5566b] | 97 | class AsmStmt : public Statement { | 
|---|
|  | 98 | public: | 
|---|
| [65cdc1e] | 99 | bool voltile; | 
|---|
| [e612146c] | 100 | Expression *instruction; | 
|---|
| [65cdc1e] | 101 | std::list<Expression *> output, input; | 
|---|
|  | 102 | std::list<ConstantExpr *> clobber; | 
|---|
|  | 103 | std::list<Label> gotolabels; | 
|---|
|  | 104 |  | 
|---|
| [ba3706f] | 105 | AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); | 
|---|
| [3be261a] | 106 | AsmStmt( const AsmStmt &other ); | 
|---|
| [7f5566b] | 107 | virtual ~AsmStmt(); | 
|---|
|  | 108 |  | 
|---|
|  | 109 | bool get_voltile() { return voltile; } | 
|---|
|  | 110 | void set_voltile( bool newValue ) { voltile = newValue; } | 
|---|
| [e612146c] | 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; } | 
|---|
| [7f5566b] | 116 | void set_input( const std::list<Expression *> &newValue ) { input = newValue; } | 
|---|
| [e612146c] | 117 | std::list<ConstantExpr *> & get_clobber() { return clobber; } | 
|---|
| [7f5566b] | 118 | void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; } | 
|---|
| [e612146c] | 119 | std::list<Label> & get_gotolabels() { return gotolabels; } | 
|---|
| [7f5566b] | 120 | void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; } | 
|---|
|  | 121 |  | 
|---|
| [e612146c] | 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 ); } | 
|---|
| [50377a4] | 125 | virtual void print( std::ostream & os, Indenter indent = {} ) const; | 
|---|
| [7f5566b] | 126 | }; | 
|---|
|  | 127 |  | 
|---|
| [0dd3a2f] | 128 | class IfStmt : public Statement { | 
|---|
|  | 129 | public: | 
|---|
| [65cdc1e] | 130 | Expression *condition; | 
|---|
|  | 131 | Statement *thenPart; | 
|---|
|  | 132 | Statement *elsePart; | 
|---|
| [6d49ea3] | 133 | std::list<Statement *> initialization; | 
|---|
| [65cdc1e] | 134 |  | 
|---|
| [ba3706f] | 135 | IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, | 
|---|
| [6d49ea3] | 136 | std::list<Statement *> initialization = std::list<Statement *>() ); | 
|---|
| [3be261a] | 137 | IfStmt( const IfStmt &other ); | 
|---|
| [0dd3a2f] | 138 | virtual ~IfStmt(); | 
|---|
|  | 139 |  | 
|---|
| [936e9f4] | 140 | std::list<Statement *> &get_initialization() { return initialization; } | 
|---|
| [0dd3a2f] | 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; } | 
|---|
| [3be261a] | 147 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 151 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 152 | }; | 
|---|
|  | 153 |  | 
|---|
| [0dd3a2f] | 154 | class SwitchStmt : public Statement { | 
|---|
|  | 155 | public: | 
|---|
| [65cdc1e] | 156 | Expression * condition; | 
|---|
| [871cdb4] | 157 | std::list<Statement *> statements; | 
|---|
| [65cdc1e] | 158 |  | 
|---|
| [ba3706f] | 159 | SwitchStmt( Expression *condition, const std::list<Statement *> &statements ); | 
|---|
| [3be261a] | 160 | SwitchStmt( const SwitchStmt &other ); | 
|---|
| [0dd3a2f] | 161 | virtual ~SwitchStmt(); | 
|---|
| [51b73452] | 162 |  | 
|---|
| [0dd3a2f] | 163 | Expression *get_condition() { return condition; } | 
|---|
|  | 164 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
| [51b73452] | 165 |  | 
|---|
| [8688ce1] | 166 | std::list<Statement *> & get_statements() { return statements; } | 
|---|
| [51b73452] | 167 |  | 
|---|
| [e149f77] | 168 | virtual void accept( Visitor &v ) override { v.visit( this ); } | 
|---|
|  | 169 | virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); } | 
|---|
| [51b73452] | 170 |  | 
|---|
| [e149f77] | 171 | virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); } | 
|---|
| [50377a4] | 172 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [871cdb4] | 173 |  | 
|---|
| [51b73452] | 174 | }; | 
|---|
|  | 175 |  | 
|---|
| [0dd3a2f] | 176 | class CaseStmt : public Statement { | 
|---|
|  | 177 | public: | 
|---|
| [65cdc1e] | 178 | Expression * condition; | 
|---|
|  | 179 | std::list<Statement *> stmts; | 
|---|
|  | 180 |  | 
|---|
| [a16764a6] | 181 | CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException); | 
|---|
| [3be261a] | 182 | CaseStmt( const CaseStmt &other ); | 
|---|
| [0dd3a2f] | 183 | virtual ~CaseStmt(); | 
|---|
|  | 184 |  | 
|---|
| [ba3706f] | 185 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); | 
|---|
| [b2152e7a] | 186 |  | 
|---|
| [de62360d] | 187 | bool isDefault() const { return _isDefault; } | 
|---|
| [0dd3a2f] | 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; } | 
|---|
| [3be261a] | 195 |  | 
|---|
| [e149f77] | 196 | virtual void accept( Visitor &v ) override { v.visit( this ); } | 
|---|
|  | 197 | virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); } | 
|---|
| [0dd3a2f] | 198 |  | 
|---|
| [e149f77] | 199 | virtual CaseStmt *clone() const override { return new CaseStmt( *this ); } | 
|---|
| [50377a4] | 200 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [0dd3a2f] | 201 | private: | 
|---|
|  | 202 | bool _isDefault; | 
|---|
| [51b73452] | 203 | }; | 
|---|
|  | 204 |  | 
|---|
| [0dd3a2f] | 205 | class WhileStmt : public Statement { | 
|---|
|  | 206 | public: | 
|---|
| [65cdc1e] | 207 | Expression *condition; | 
|---|
|  | 208 | Statement *body; | 
|---|
|  | 209 | bool isDoWhile; | 
|---|
|  | 210 |  | 
|---|
| [ba3706f] | 211 | WhileStmt( Expression *condition, | 
|---|
| [0dd3a2f] | 212 | Statement *body, bool isDoWhile = false ); | 
|---|
| [3be261a] | 213 | WhileStmt( const WhileStmt &other ); | 
|---|
| [0dd3a2f] | 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; } | 
|---|
| [3be261a] | 222 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 226 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 227 | }; | 
|---|
|  | 228 |  | 
|---|
| [0dd3a2f] | 229 | class ForStmt : public Statement { | 
|---|
|  | 230 | public: | 
|---|
| [65cdc1e] | 231 | std::list<Statement *> initialization; | 
|---|
|  | 232 | Expression *condition; | 
|---|
|  | 233 | Expression *increment; | 
|---|
|  | 234 | Statement *body; | 
|---|
|  | 235 |  | 
|---|
| [ba3706f] | 236 | ForStmt( std::list<Statement *> initialization, | 
|---|
| [0dd3a2f] | 237 | Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); | 
|---|
| [3be261a] | 238 | ForStmt( const ForStmt &other ); | 
|---|
| [0dd3a2f] | 239 | virtual ~ForStmt(); | 
|---|
|  | 240 |  | 
|---|
| [145f1fc] | 241 | std::list<Statement *> &get_initialization() { return initialization; } | 
|---|
| [0dd3a2f] | 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; } | 
|---|
| [3be261a] | 248 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 252 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 253 | }; | 
|---|
|  | 254 |  | 
|---|
| [0dd3a2f] | 255 | class BranchStmt : public Statement { | 
|---|
|  | 256 | public: | 
|---|
| [6a276a0] | 257 | enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault }; | 
|---|
| [0dd3a2f] | 258 |  | 
|---|
| [65cdc1e] | 259 | // originalTarget kept for error messages. | 
|---|
|  | 260 | const Label originalTarget; | 
|---|
|  | 261 | Label target; | 
|---|
|  | 262 | Expression *computedTarget; | 
|---|
|  | 263 | Type type; | 
|---|
|  | 264 |  | 
|---|
| [a16764a6] | 265 | BranchStmt( Label target, Type ) throw (SemanticErrorException); | 
|---|
|  | 266 | BranchStmt( Expression *computedTarget, Type ) throw (SemanticErrorException); | 
|---|
| [0dd3a2f] | 267 |  | 
|---|
| [be5aa1b] | 268 | Label get_originalTarget() { return originalTarget; } | 
|---|
| [0dd3a2f] | 269 | Label get_target() { return target; } | 
|---|
|  | 270 | void set_target( Label newValue ) { target = newValue; } | 
|---|
| [3be261a] | 271 |  | 
|---|
| [0dd3a2f] | 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 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 281 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [0dd3a2f] | 282 | private: | 
|---|
|  | 283 | static const char *brType[]; | 
|---|
| [51b73452] | 284 | }; | 
|---|
|  | 285 |  | 
|---|
| [0dd3a2f] | 286 | class ReturnStmt : public Statement { | 
|---|
|  | 287 | public: | 
|---|
| [65cdc1e] | 288 | Expression *expr; | 
|---|
|  | 289 |  | 
|---|
| [ba3706f] | 290 | ReturnStmt( Expression *expr ); | 
|---|
| [3be261a] | 291 | ReturnStmt( const ReturnStmt &other ); | 
|---|
| [0dd3a2f] | 292 | virtual ~ReturnStmt(); | 
|---|
|  | 293 |  | 
|---|
|  | 294 | Expression *get_expr() { return expr; } | 
|---|
|  | 295 | void set_expr( Expression *newValue ) { expr = newValue; } | 
|---|
| [3be261a] | 296 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 300 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 301 | }; | 
|---|
|  | 302 |  | 
|---|
| [daf1af8] | 303 | class ThrowStmt : public Statement { | 
|---|
| [0dd3a2f] | 304 | public: | 
|---|
| [daf1af8] | 305 | enum Kind { Terminate, Resume }; | 
|---|
| [51b73452] | 306 |  | 
|---|
| [65cdc1e] | 307 | const Kind kind; | 
|---|
|  | 308 | Expression * expr; | 
|---|
|  | 309 | Expression * target; | 
|---|
|  | 310 |  | 
|---|
| [ba3706f] | 311 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); | 
|---|
| [daf1af8] | 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 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 324 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 325 | }; | 
|---|
|  | 326 |  | 
|---|
| [3be261a] | 327 | class TryStmt : public Statement { | 
|---|
| [0dd3a2f] | 328 | public: | 
|---|
| [871cdb4] | 329 | CompoundStmt * block; | 
|---|
| [65cdc1e] | 330 | std::list<CatchStmt *> handlers; | 
|---|
| [871cdb4] | 331 | FinallyStmt * finallyBlock; | 
|---|
| [65cdc1e] | 332 |  | 
|---|
| [ba3706f] | 333 | TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); | 
|---|
| [0dd3a2f] | 334 | TryStmt( const TryStmt &other ); | 
|---|
|  | 335 | virtual ~TryStmt(); | 
|---|
|  | 336 |  | 
|---|
|  | 337 | CompoundStmt *get_block() const { return block; } | 
|---|
|  | 338 | void set_block( CompoundStmt *newValue ) { block = newValue; } | 
|---|
| [046e04a] | 339 | std::list<CatchStmt *>& get_catchers() { return handlers; } | 
|---|
| [0dd3a2f] | 340 |  | 
|---|
|  | 341 | FinallyStmt *get_finally() const { return finallyBlock; } | 
|---|
|  | 342 | void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; } | 
|---|
|  | 343 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 347 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [3be261a] | 348 | }; | 
|---|
| [51b73452] | 349 |  | 
|---|
| [0dd3a2f] | 350 | class CatchStmt : public Statement { | 
|---|
|  | 351 | public: | 
|---|
| [ca78437] | 352 | enum Kind { Terminate, Resume }; | 
|---|
|  | 353 |  | 
|---|
| [65cdc1e] | 354 | const Kind kind; | 
|---|
|  | 355 | Declaration *decl; | 
|---|
|  | 356 | Expression *cond; | 
|---|
|  | 357 | Statement *body; | 
|---|
|  | 358 |  | 
|---|
| [ba3706f] | 359 | CatchStmt( Kind kind, Declaration *decl, | 
|---|
| [ca78437] | 360 | Expression *cond, Statement *body ); | 
|---|
| [3be261a] | 361 | CatchStmt( const CatchStmt &other ); | 
|---|
| [0dd3a2f] | 362 | virtual ~CatchStmt(); | 
|---|
|  | 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; | 
|---|
| [51b73452] | 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 | virtual ~FinallyStmt(); | 
|---|
|  | 385 |  | 
|---|
|  | 386 | CompoundStmt *get_block() const { return block; } | 
|---|
|  | 387 | void set_block( CompoundStmt *newValue ) { block = newValue; } | 
|---|
| [3be261a] | 388 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 392 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [3be261a] | 393 | }; | 
|---|
| [51b73452] | 394 |  | 
|---|
| [135b431] | 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 |  | 
|---|
| [ba3706f] | 409 | WaitForStmt(); | 
|---|
| [135b431] | 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 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 429 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [135b431] | 430 |  | 
|---|
|  | 431 | }; | 
|---|
|  | 432 |  | 
|---|
| [61255ad] | 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 |  | 
|---|
| [51b73452] | 448 |  | 
|---|
|  | 449 | // represents a declaration that occurs as part of a compound statement | 
|---|
| [0dd3a2f] | 450 | class DeclStmt : public Statement { | 
|---|
|  | 451 | public: | 
|---|
| [65cdc1e] | 452 | Declaration *decl; | 
|---|
|  | 453 |  | 
|---|
| [ba3706f] | 454 | DeclStmt( Declaration *decl ); | 
|---|
| [0dd3a2f] | 455 | DeclStmt( const DeclStmt &other ); | 
|---|
|  | 456 | virtual ~DeclStmt(); | 
|---|
|  | 457 |  | 
|---|
| [f1b1e4c] | 458 | Declaration *get_decl() const { return decl; } | 
|---|
| [0dd3a2f] | 459 | void set_decl( Declaration *newValue ) { decl = newValue; } | 
|---|
|  | 460 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 464 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 465 | }; | 
|---|
|  | 466 |  | 
|---|
| [f1b1e4c] | 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: | 
|---|
| [65cdc1e] | 473 | // Non-owned pointer to the constructor/destructor statement | 
|---|
|  | 474 | Statement * callStmt; | 
|---|
|  | 475 |  | 
|---|
| [f1b1e4c] | 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 |  | 
|---|
| [e149f77] | 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 ); } | 
|---|
| [50377a4] | 486 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; | 
|---|
| [f1b1e4c] | 487 | }; | 
|---|
|  | 488 |  | 
|---|
| [0dd3a2f] | 489 | // Local Variables: // | 
|---|
|  | 490 | // tab-width: 4 // | 
|---|
|  | 491 | // mode: c++ // | 
|---|
|  | 492 | // compile-command: "make install" // | 
|---|
|  | 493 | // End: // | 
|---|