| [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 | 
|---|
| [6180274] | 12 | // Last Modified On : Wed Feb  2 20:15:30 2022 | 
|---|
|  | 13 | // Update Count     : 98 | 
|---|
| [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 | 
|---|
| [35a2d47] | 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 |  | 
|---|
| [35a2d47] | 45 | virtual Statement * clone() const override = 0; | 
|---|
|  | 46 | virtual void accept( Visitor & v ) override = 0; | 
|---|
| [7870799] | 47 | virtual void accept( Visitor & v ) const override = 0; | 
|---|
| [35a2d47] | 48 | virtual Statement * acceptMutator( Mutator & m ) override = 0; | 
|---|
|  | 49 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 50 | }; | 
|---|
|  | 51 |  | 
|---|
| [0dd3a2f] | 52 | class CompoundStmt : public Statement { | 
|---|
|  | 53 | public: | 
|---|
| [65cdc1e] | 54 | std::list<Statement*> kids; | 
|---|
|  | 55 |  | 
|---|
| [ba3706f] | 56 | CompoundStmt(); | 
|---|
| [a2dbad10] | 57 | CompoundStmt( std::list<Statement *> stmts ); | 
|---|
| [35a2d47] | 58 | CompoundStmt( const CompoundStmt & other ); | 
|---|
| [0dd3a2f] | 59 | virtual ~CompoundStmt(); | 
|---|
| [51b73452] | 60 |  | 
|---|
| [0dd3a2f] | 61 | std::list<Statement*>& get_kids() { return kids; } | 
|---|
| [c8dfcd3] | 62 | void push_back( Statement * stmt ) { kids.push_back( stmt ); } | 
|---|
|  | 63 | void push_front( Statement * stmt ) { kids.push_front( stmt ); } | 
|---|
| [51b73452] | 64 |  | 
|---|
| [35a2d47] | 65 | virtual CompoundStmt * clone() const override { return new CompoundStmt( *this ); } | 
|---|
|  | 66 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 67 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 68 | virtual CompoundStmt * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 69 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 70 | }; | 
|---|
|  | 71 |  | 
|---|
| [70d826cd] | 72 | class NullStmt : public Statement { | 
|---|
| [daf1af8] | 73 | public: | 
|---|
| [ba3706f] | 74 | NullStmt( const std::list<Label> & labels = {} ); | 
|---|
| [daf1af8] | 75 |  | 
|---|
| [35a2d47] | 76 | virtual NullStmt * clone() const override { return new NullStmt( *this ); } | 
|---|
|  | 77 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 78 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 79 | virtual NullStmt * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 80 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [daf1af8] | 81 | }; | 
|---|
|  | 82 |  | 
|---|
| [0dd3a2f] | 83 | class ExprStmt : public Statement { | 
|---|
|  | 84 | public: | 
|---|
| [35a2d47] | 85 | Expression * expr; | 
|---|
| [65cdc1e] | 86 |  | 
|---|
| [35a2d47] | 87 | ExprStmt( Expression * expr ); | 
|---|
|  | 88 | ExprStmt( const ExprStmt & other ); | 
|---|
| [0dd3a2f] | 89 | virtual ~ExprStmt(); | 
|---|
| [51b73452] | 90 |  | 
|---|
| [35a2d47] | 91 | Expression * get_expr() { return expr; } | 
|---|
|  | 92 | void set_expr( Expression * newValue ) { expr = newValue; } | 
|---|
| [51b73452] | 93 |  | 
|---|
| [35a2d47] | 94 | virtual ExprStmt * clone() const override { return new ExprStmt( *this ); } | 
|---|
|  | 95 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 96 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 97 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 98 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [0dd3a2f] | 99 | }; | 
|---|
| [51b73452] | 100 |  | 
|---|
| [7f5566b] | 101 | class AsmStmt : public Statement { | 
|---|
|  | 102 | public: | 
|---|
| [65cdc1e] | 103 | bool voltile; | 
|---|
| [35a2d47] | 104 | Expression * instruction; | 
|---|
| [65cdc1e] | 105 | std::list<Expression *> output, input; | 
|---|
|  | 106 | std::list<ConstantExpr *> clobber; | 
|---|
|  | 107 | std::list<Label> gotolabels; | 
|---|
|  | 108 |  | 
|---|
| [6180274] | 109 | AsmStmt( bool voltile, Expression * instruction, const std::list<Expression *> output, const std::list<Expression *> input, const std::list<ConstantExpr *> clobber, const std::list<Label> gotolabels ); | 
|---|
| [35a2d47] | 110 | AsmStmt( const AsmStmt & other ); | 
|---|
| [7f5566b] | 111 | virtual ~AsmStmt(); | 
|---|
|  | 112 |  | 
|---|
|  | 113 | bool get_voltile() { return voltile; } | 
|---|
|  | 114 | void set_voltile( bool newValue ) { voltile = newValue; } | 
|---|
| [e612146c] | 115 | Expression * get_instruction() { return instruction; } | 
|---|
|  | 116 | void set_instruction( Expression * newValue ) { instruction = newValue; } | 
|---|
|  | 117 | std::list<Expression *> & get_output() { return output; } | 
|---|
|  | 118 | void set_output( const std::list<Expression *> & newValue ) { output = newValue; } | 
|---|
|  | 119 | std::list<Expression *> & get_input() { return input; } | 
|---|
| [35a2d47] | 120 | void set_input( const std::list<Expression *> & newValue ) { input = newValue; } | 
|---|
| [e612146c] | 121 | std::list<ConstantExpr *> & get_clobber() { return clobber; } | 
|---|
| [35a2d47] | 122 | void set_clobber( const std::list<ConstantExpr *> & newValue ) { clobber = newValue; } | 
|---|
| [e612146c] | 123 | std::list<Label> & get_gotolabels() { return gotolabels; } | 
|---|
| [35a2d47] | 124 | void set_gotolabels( const std::list<Label> & newValue ) { gotolabels = newValue; } | 
|---|
| [7f5566b] | 125 |  | 
|---|
| [7870799] | 126 | virtual AsmStmt * clone() const override { return new AsmStmt( *this ); } | 
|---|
|  | 127 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 128 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 129 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 130 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [7f5566b] | 131 | }; | 
|---|
|  | 132 |  | 
|---|
| [cc32d83] | 133 | class DirectiveStmt : public Statement { | 
|---|
|  | 134 | public: | 
|---|
|  | 135 | std::string directive; | 
|---|
|  | 136 |  | 
|---|
|  | 137 | DirectiveStmt( const std::string & ); | 
|---|
|  | 138 | virtual ~DirectiveStmt(){} | 
|---|
|  | 139 |  | 
|---|
| [7870799] | 140 | virtual DirectiveStmt * clone() const override { return new DirectiveStmt( *this ); } | 
|---|
|  | 141 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 142 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 143 | virtual Statement * acceptMutator( Mutator & m ) override { return m.mutate( this ); } | 
|---|
|  | 144 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [cc32d83] | 145 | }; | 
|---|
|  | 146 |  | 
|---|
| [0dd3a2f] | 147 | class IfStmt : public Statement { | 
|---|
|  | 148 | public: | 
|---|
| [35a2d47] | 149 | Expression * condition; | 
|---|
| [3b0bc16] | 150 | Statement * then; | 
|---|
|  | 151 | Statement * else_; | 
|---|
| [6d49ea3] | 152 | std::list<Statement *> initialization; | 
|---|
| [65cdc1e] | 153 |  | 
|---|
| [3b0bc16] | 154 | IfStmt( Expression * condition, Statement * then, Statement * else_, | 
|---|
| [6180274] | 155 | const std::list<Statement *> initialization = std::list<Statement *>() ); | 
|---|
| [35a2d47] | 156 | IfStmt( const IfStmt & other ); | 
|---|
| [0dd3a2f] | 157 | virtual ~IfStmt(); | 
|---|
|  | 158 |  | 
|---|
| [35a2d47] | 159 | std::list<Statement *> & get_initialization() { return initialization; } | 
|---|
|  | 160 | Expression * get_condition() { return condition; } | 
|---|
|  | 161 | void set_condition( Expression * newValue ) { condition = newValue; } | 
|---|
| [3b0bc16] | 162 | Statement * get_then() { return then; } | 
|---|
|  | 163 | void set_then( Statement * newValue ) { then = newValue; } | 
|---|
|  | 164 | Statement * get_else() { return else_; } | 
|---|
|  | 165 | void set_else( Statement * newValue ) { else_ = newValue; } | 
|---|
| [35a2d47] | 166 |  | 
|---|
|  | 167 | virtual IfStmt * clone() const override { return new IfStmt( *this ); } | 
|---|
|  | 168 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 169 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 170 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 171 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 172 | }; | 
|---|
|  | 173 |  | 
|---|
| [0dd3a2f] | 174 | class SwitchStmt : public Statement { | 
|---|
|  | 175 | public: | 
|---|
| [65cdc1e] | 176 | Expression * condition; | 
|---|
| [871cdb4] | 177 | std::list<Statement *> statements; | 
|---|
| [65cdc1e] | 178 |  | 
|---|
| [35a2d47] | 179 | SwitchStmt( Expression * condition, const std::list<Statement *> & statements ); | 
|---|
|  | 180 | SwitchStmt( const SwitchStmt & other ); | 
|---|
| [0dd3a2f] | 181 | virtual ~SwitchStmt(); | 
|---|
| [51b73452] | 182 |  | 
|---|
| [35a2d47] | 183 | Expression * get_condition() { return condition; } | 
|---|
|  | 184 | void set_condition( Expression * newValue ) { condition = newValue; } | 
|---|
| [51b73452] | 185 |  | 
|---|
| [8688ce1] | 186 | std::list<Statement *> & get_statements() { return statements; } | 
|---|
| [51b73452] | 187 |  | 
|---|
| [35a2d47] | 188 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 189 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 190 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
| [51b73452] | 191 |  | 
|---|
| [35a2d47] | 192 | virtual SwitchStmt * clone() const override { return new SwitchStmt( *this ); } | 
|---|
|  | 193 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [871cdb4] | 194 |  | 
|---|
| [51b73452] | 195 | }; | 
|---|
|  | 196 |  | 
|---|
| [0dd3a2f] | 197 | class CaseStmt : public Statement { | 
|---|
|  | 198 | public: | 
|---|
| [65cdc1e] | 199 | Expression * condition; | 
|---|
|  | 200 | std::list<Statement *> stmts; | 
|---|
|  | 201 |  | 
|---|
| [35a2d47] | 202 | CaseStmt( Expression * conditions, const std::list<Statement *> & stmts, bool isdef = false ) throw (SemanticErrorException); | 
|---|
|  | 203 | CaseStmt( const CaseStmt & other ); | 
|---|
| [0dd3a2f] | 204 | virtual ~CaseStmt(); | 
|---|
|  | 205 |  | 
|---|
| [ba3706f] | 206 | static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); | 
|---|
| [b2152e7a] | 207 |  | 
|---|
| [de62360d] | 208 | bool isDefault() const { return _isDefault; } | 
|---|
| [0dd3a2f] | 209 | void set_default(bool b) { _isDefault = b; } | 
|---|
|  | 210 |  | 
|---|
| [35a2d47] | 211 | Expression * & get_condition() { return condition; } | 
|---|
|  | 212 | void set_condition( Expression * newValue ) { condition = newValue; } | 
|---|
| [0dd3a2f] | 213 |  | 
|---|
| [35a2d47] | 214 | std::list<Statement *> & get_statements() { return stmts; } | 
|---|
|  | 215 | void set_statements( std::list<Statement *> & newValue ) { stmts = newValue; } | 
|---|
| [3be261a] | 216 |  | 
|---|
| [35a2d47] | 217 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 218 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 219 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
| [0dd3a2f] | 220 |  | 
|---|
| [35a2d47] | 221 | virtual CaseStmt * clone() const override { return new CaseStmt( *this ); } | 
|---|
|  | 222 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [0dd3a2f] | 223 | private: | 
|---|
|  | 224 | bool _isDefault; | 
|---|
| [51b73452] | 225 | }; | 
|---|
|  | 226 |  | 
|---|
| [3b0bc16] | 227 | class WhileDoStmt : public Statement { | 
|---|
| [0dd3a2f] | 228 | public: | 
|---|
| [35a2d47] | 229 | Expression * condition; | 
|---|
|  | 230 | Statement * body; | 
|---|
| [3b0bc16] | 231 | Statement * else_; | 
|---|
| [ee3c93d] | 232 | std::list<Statement *> initialization; | 
|---|
| [65cdc1e] | 233 | bool isDoWhile; | 
|---|
|  | 234 |  | 
|---|
| [4e7171f] | 235 | WhileDoStmt( Expression * condition, Statement * body, const std::list<Statement *> & initialization, bool isDoWhile = false ); | 
|---|
|  | 236 | WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list<Statement *> & initialization, bool isDoWhile = false ); | 
|---|
| [3b0bc16] | 237 | WhileDoStmt( const WhileDoStmt & other ); | 
|---|
|  | 238 | virtual ~WhileDoStmt(); | 
|---|
| [0dd3a2f] | 239 |  | 
|---|
| [35a2d47] | 240 | Expression * get_condition() { return condition; } | 
|---|
|  | 241 | void set_condition( Expression * newValue ) { condition = newValue; } | 
|---|
|  | 242 | Statement * get_body() { return body; } | 
|---|
|  | 243 | void set_body( Statement * newValue ) { body = newValue; } | 
|---|
| [0dd3a2f] | 244 | bool get_isDoWhile() { return isDoWhile; } | 
|---|
|  | 245 | void set_isDoWhile( bool newValue ) { isDoWhile = newValue; } | 
|---|
| [3be261a] | 246 |  | 
|---|
| [3b0bc16] | 247 | virtual WhileDoStmt * clone() const override { return new WhileDoStmt( *this ); } | 
|---|
| [35a2d47] | 248 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 249 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 250 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 251 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 252 | }; | 
|---|
|  | 253 |  | 
|---|
| [0dd3a2f] | 254 | class ForStmt : public Statement { | 
|---|
|  | 255 | public: | 
|---|
| [65cdc1e] | 256 | std::list<Statement *> initialization; | 
|---|
| [35a2d47] | 257 | Expression * condition; | 
|---|
|  | 258 | Expression * increment; | 
|---|
|  | 259 | Statement * body; | 
|---|
| [3b0bc16] | 260 | Statement * else_; | 
|---|
| [65cdc1e] | 261 |  | 
|---|
| [6180274] | 262 | ForStmt( const std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr ); | 
|---|
| [35a2d47] | 263 | ForStmt( const ForStmt & other ); | 
|---|
| [0dd3a2f] | 264 | virtual ~ForStmt(); | 
|---|
|  | 265 |  | 
|---|
| [35a2d47] | 266 | std::list<Statement *> & get_initialization() { return initialization; } | 
|---|
|  | 267 | Expression * get_condition() { return condition; } | 
|---|
|  | 268 | void set_condition( Expression * newValue ) { condition = newValue; } | 
|---|
|  | 269 | Expression * get_increment() { return increment; } | 
|---|
|  | 270 | void set_increment( Expression * newValue ) { increment = newValue; } | 
|---|
|  | 271 | Statement * get_body() { return body; } | 
|---|
|  | 272 | void set_body( Statement * newValue ) { body = newValue; } | 
|---|
|  | 273 |  | 
|---|
|  | 274 | virtual ForStmt * clone() const override { return new ForStmt( *this ); } | 
|---|
|  | 275 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 276 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 277 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 278 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 279 | }; | 
|---|
|  | 280 |  | 
|---|
| [0dd3a2f] | 281 | class BranchStmt : public Statement { | 
|---|
|  | 282 | public: | 
|---|
| [6180274] | 283 | enum Type { Goto, Break, Continue, FallThrough, FallThroughDefault, BranchStmts }; | 
|---|
| [0dd3a2f] | 284 |  | 
|---|
| [65cdc1e] | 285 | // originalTarget kept for error messages. | 
|---|
|  | 286 | const Label originalTarget; | 
|---|
|  | 287 | Label target; | 
|---|
| [35a2d47] | 288 | Expression * computedTarget; | 
|---|
| [65cdc1e] | 289 | Type type; | 
|---|
|  | 290 |  | 
|---|
| [a16764a6] | 291 | BranchStmt( Label target, Type ) throw (SemanticErrorException); | 
|---|
| [35a2d47] | 292 | BranchStmt( Expression * computedTarget, Type ) throw (SemanticErrorException); | 
|---|
| [0dd3a2f] | 293 |  | 
|---|
| [be5aa1b] | 294 | Label get_originalTarget() { return originalTarget; } | 
|---|
| [0dd3a2f] | 295 | Label get_target() { return target; } | 
|---|
|  | 296 | void set_target( Label newValue ) { target = newValue; } | 
|---|
| [3be261a] | 297 |  | 
|---|
| [35a2d47] | 298 | Expression * get_computedTarget() { return computedTarget; } | 
|---|
| [0dd3a2f] | 299 | void set_target( Expression * newValue ) { computedTarget = newValue; } | 
|---|
|  | 300 |  | 
|---|
|  | 301 | Type get_type() { return type; } | 
|---|
| [35a2d47] | 302 | const char * get_typename() { return brType[ type ]; } | 
|---|
| [0dd3a2f] | 303 |  | 
|---|
| [35a2d47] | 304 | virtual BranchStmt * clone() const override { return new BranchStmt( *this ); } | 
|---|
|  | 305 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 306 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 307 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 308 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [0dd3a2f] | 309 | private: | 
|---|
| [35a2d47] | 310 | static const char * brType[]; | 
|---|
| [51b73452] | 311 | }; | 
|---|
|  | 312 |  | 
|---|
| [0dd3a2f] | 313 | class ReturnStmt : public Statement { | 
|---|
|  | 314 | public: | 
|---|
| [35a2d47] | 315 | Expression * expr; | 
|---|
| [65cdc1e] | 316 |  | 
|---|
| [35a2d47] | 317 | ReturnStmt( Expression * expr ); | 
|---|
|  | 318 | ReturnStmt( const ReturnStmt & other ); | 
|---|
| [0dd3a2f] | 319 | virtual ~ReturnStmt(); | 
|---|
|  | 320 |  | 
|---|
| [35a2d47] | 321 | Expression * get_expr() { return expr; } | 
|---|
|  | 322 | void set_expr( Expression * newValue ) { expr = newValue; } | 
|---|
| [3be261a] | 323 |  | 
|---|
| [35a2d47] | 324 | virtual ReturnStmt * clone() const override { return new ReturnStmt( *this ); } | 
|---|
|  | 325 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 326 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 327 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 328 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 329 | }; | 
|---|
|  | 330 |  | 
|---|
| [daf1af8] | 331 | class ThrowStmt : public Statement { | 
|---|
| [0dd3a2f] | 332 | public: | 
|---|
| [daf1af8] | 333 | enum Kind { Terminate, Resume }; | 
|---|
| [51b73452] | 334 |  | 
|---|
| [65cdc1e] | 335 | const Kind kind; | 
|---|
|  | 336 | Expression * expr; | 
|---|
|  | 337 | Expression * target; | 
|---|
|  | 338 |  | 
|---|
| [ba3706f] | 339 | ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); | 
|---|
| [35a2d47] | 340 | ThrowStmt( const ThrowStmt & other ); | 
|---|
| [daf1af8] | 341 | virtual ~ThrowStmt(); | 
|---|
|  | 342 |  | 
|---|
|  | 343 | Kind get_kind() { return kind; } | 
|---|
|  | 344 | Expression * get_expr() { return expr; } | 
|---|
|  | 345 | void set_expr( Expression * newExpr ) { expr = newExpr; } | 
|---|
|  | 346 | Expression * get_target() { return target; } | 
|---|
|  | 347 | void set_target( Expression * newTarget ) { target = newTarget; } | 
|---|
|  | 348 |  | 
|---|
| [35a2d47] | 349 | virtual ThrowStmt * clone() const override { return new ThrowStmt( *this ); } | 
|---|
|  | 350 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 351 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 352 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 353 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 354 | }; | 
|---|
|  | 355 |  | 
|---|
| [3be261a] | 356 | class TryStmt : public Statement { | 
|---|
| [0dd3a2f] | 357 | public: | 
|---|
| [871cdb4] | 358 | CompoundStmt * block; | 
|---|
| [65cdc1e] | 359 | std::list<CatchStmt *> handlers; | 
|---|
| [871cdb4] | 360 | FinallyStmt * finallyBlock; | 
|---|
| [65cdc1e] | 361 |  | 
|---|
| [6180274] | 362 | TryStmt( CompoundStmt * tryBlock, const std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr ); | 
|---|
| [35a2d47] | 363 | TryStmt( const TryStmt & other ); | 
|---|
| [0dd3a2f] | 364 | virtual ~TryStmt(); | 
|---|
|  | 365 |  | 
|---|
| [35a2d47] | 366 | CompoundStmt * get_block() const { return block; } | 
|---|
|  | 367 | void set_block( CompoundStmt * newValue ) { block = newValue; } | 
|---|
| [046e04a] | 368 | std::list<CatchStmt *>& get_catchers() { return handlers; } | 
|---|
| [0dd3a2f] | 369 |  | 
|---|
| [35a2d47] | 370 | FinallyStmt * get_finally() const { return finallyBlock; } | 
|---|
|  | 371 | void set_finally( FinallyStmt * newValue ) { finallyBlock = newValue; } | 
|---|
| [0dd3a2f] | 372 |  | 
|---|
| [35a2d47] | 373 | virtual TryStmt * clone() const override { return new TryStmt( *this ); } | 
|---|
|  | 374 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 375 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 376 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 377 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [3be261a] | 378 | }; | 
|---|
| [51b73452] | 379 |  | 
|---|
| [0dd3a2f] | 380 | class CatchStmt : public Statement { | 
|---|
|  | 381 | public: | 
|---|
| [ca78437] | 382 | enum Kind { Terminate, Resume }; | 
|---|
|  | 383 |  | 
|---|
| [65cdc1e] | 384 | const Kind kind; | 
|---|
| [35a2d47] | 385 | Declaration * decl; | 
|---|
|  | 386 | Expression * cond; | 
|---|
|  | 387 | Statement * body; | 
|---|
| [65cdc1e] | 388 |  | 
|---|
| [35a2d47] | 389 | CatchStmt( Kind kind, Declaration * decl, | 
|---|
|  | 390 | Expression * cond, Statement * body ); | 
|---|
|  | 391 | CatchStmt( const CatchStmt & other ); | 
|---|
| [0dd3a2f] | 392 | virtual ~CatchStmt(); | 
|---|
|  | 393 |  | 
|---|
| [ca78437] | 394 | Kind get_kind() { return kind; } | 
|---|
| [35a2d47] | 395 | Declaration * get_decl() { return decl; } | 
|---|
|  | 396 | void set_decl( Declaration * newValue ) { decl = newValue; } | 
|---|
|  | 397 | Expression * get_cond() { return cond; } | 
|---|
|  | 398 | void set_cond( Expression * newCond ) { cond = newCond; } | 
|---|
|  | 399 | Statement * get_body() { return body; } | 
|---|
|  | 400 | void set_body( Statement * newValue ) { body = newValue; } | 
|---|
|  | 401 |  | 
|---|
|  | 402 | virtual CatchStmt * clone() const override { return new CatchStmt( *this ); } | 
|---|
|  | 403 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 404 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 405 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 406 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 407 | }; | 
|---|
|  | 408 |  | 
|---|
| [3be261a] | 409 | class FinallyStmt : public Statement { | 
|---|
| [0dd3a2f] | 410 | public: | 
|---|
| [35a2d47] | 411 | CompoundStmt * block; | 
|---|
| [65cdc1e] | 412 |  | 
|---|
| [35a2d47] | 413 | FinallyStmt( CompoundStmt * block ); | 
|---|
|  | 414 | FinallyStmt( const FinallyStmt & other ); | 
|---|
| [0dd3a2f] | 415 | virtual ~FinallyStmt(); | 
|---|
|  | 416 |  | 
|---|
| [35a2d47] | 417 | CompoundStmt * get_block() const { return block; } | 
|---|
|  | 418 | void set_block( CompoundStmt * newValue ) { block = newValue; } | 
|---|
| [3be261a] | 419 |  | 
|---|
| [35a2d47] | 420 | virtual FinallyStmt * clone() const override { return new FinallyStmt( *this ); } | 
|---|
|  | 421 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 422 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 423 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 424 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [3be261a] | 425 | }; | 
|---|
| [51b73452] | 426 |  | 
|---|
| [37cdd97] | 427 | class SuspendStmt : public Statement { | 
|---|
|  | 428 | public: | 
|---|
|  | 429 | CompoundStmt * then = nullptr; | 
|---|
| [427854b] | 430 | enum Type { None, Coroutine, Generator } type = None; | 
|---|
| [37cdd97] | 431 |  | 
|---|
|  | 432 | SuspendStmt() = default; | 
|---|
|  | 433 | SuspendStmt( const SuspendStmt & ); | 
|---|
|  | 434 | virtual ~SuspendStmt(); | 
|---|
|  | 435 |  | 
|---|
|  | 436 | virtual SuspendStmt * clone() const override { return new SuspendStmt( *this ); } | 
|---|
|  | 437 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 438 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 439 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 440 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
|  | 441 | }; | 
|---|
|  | 442 |  | 
|---|
| [135b431] | 443 | class WaitForStmt : public Statement { | 
|---|
|  | 444 | public: | 
|---|
|  | 445 |  | 
|---|
|  | 446 | struct Target { | 
|---|
|  | 447 | Expression * function; | 
|---|
|  | 448 | std::list<Expression * > arguments; | 
|---|
|  | 449 | }; | 
|---|
|  | 450 |  | 
|---|
|  | 451 | struct Clause { | 
|---|
|  | 452 | Target       target; | 
|---|
|  | 453 | Statement  * statement; | 
|---|
|  | 454 | Expression * condition; | 
|---|
|  | 455 | }; | 
|---|
|  | 456 |  | 
|---|
| [ba3706f] | 457 | WaitForStmt(); | 
|---|
| [135b431] | 458 | WaitForStmt( const WaitForStmt & ); | 
|---|
|  | 459 | virtual ~WaitForStmt(); | 
|---|
|  | 460 |  | 
|---|
|  | 461 | std::vector<Clause> clauses; | 
|---|
|  | 462 |  | 
|---|
|  | 463 | struct { | 
|---|
|  | 464 | Expression * time; | 
|---|
|  | 465 | Statement  * statement; | 
|---|
|  | 466 | Expression * condition; | 
|---|
|  | 467 | } timeout; | 
|---|
|  | 468 |  | 
|---|
|  | 469 | struct { | 
|---|
|  | 470 | Statement  * statement; | 
|---|
|  | 471 | Expression * condition; | 
|---|
|  | 472 | } orelse; | 
|---|
|  | 473 |  | 
|---|
| [35a2d47] | 474 | virtual WaitForStmt * clone() const override { return new WaitForStmt( *this ); } | 
|---|
|  | 475 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 476 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 477 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 478 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [135b431] | 479 |  | 
|---|
|  | 480 | }; | 
|---|
|  | 481 |  | 
|---|
| [e67991f] | 482 | // class WithStmt : public Statement { | 
|---|
|  | 483 | // public: | 
|---|
|  | 484 | //      std::list< Expression * > exprs; | 
|---|
|  | 485 | //      Statement * stmt; | 
|---|
|  | 486 |  | 
|---|
|  | 487 | //      WithStmt( const std::list< Expression * > & exprs, Statement * stmt ); | 
|---|
|  | 488 | //      WithStmt( const WithStmt & other ); | 
|---|
|  | 489 | //      virtual ~WithStmt(); | 
|---|
|  | 490 |  | 
|---|
|  | 491 | //      virtual WithStmt * clone() const override { return new WithStmt( *this ); } | 
|---|
|  | 492 | //      virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 493 | //      virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 494 | //      virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 495 | //      virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
|  | 496 | // }; | 
|---|
| [61255ad] | 497 |  | 
|---|
| [51b73452] | 498 |  | 
|---|
|  | 499 | // represents a declaration that occurs as part of a compound statement | 
|---|
| [0dd3a2f] | 500 | class DeclStmt : public Statement { | 
|---|
|  | 501 | public: | 
|---|
| [35a2d47] | 502 | Declaration * decl; | 
|---|
| [65cdc1e] | 503 |  | 
|---|
| [35a2d47] | 504 | DeclStmt( Declaration * decl ); | 
|---|
|  | 505 | DeclStmt( const DeclStmt & other ); | 
|---|
| [0dd3a2f] | 506 | virtual ~DeclStmt(); | 
|---|
|  | 507 |  | 
|---|
| [35a2d47] | 508 | Declaration * get_decl() const { return decl; } | 
|---|
|  | 509 | void set_decl( Declaration * newValue ) { decl = newValue; } | 
|---|
| [0dd3a2f] | 510 |  | 
|---|
| [35a2d47] | 511 | virtual DeclStmt * clone() const override { return new DeclStmt( *this ); } | 
|---|
|  | 512 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 513 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 514 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 515 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [51b73452] | 516 | }; | 
|---|
|  | 517 |  | 
|---|
| [f1b1e4c] | 518 |  | 
|---|
| [35a2d47] | 519 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced immediately before and | 
|---|
|  | 520 | /// after the call so that qualified objects can be constructed with the same functions as unqualified objects. | 
|---|
| [f1b1e4c] | 521 | class ImplicitCtorDtorStmt : public Statement { | 
|---|
|  | 522 | public: | 
|---|
| [c570806] | 523 | // the constructor/destructor call statement; owned here for a while, eventually transferred elsewhere | 
|---|
| [65cdc1e] | 524 | Statement * callStmt; | 
|---|
|  | 525 |  | 
|---|
| [f1b1e4c] | 526 | ImplicitCtorDtorStmt( Statement * callStmt ); | 
|---|
|  | 527 | ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); | 
|---|
|  | 528 | virtual ~ImplicitCtorDtorStmt(); | 
|---|
|  | 529 |  | 
|---|
| [35a2d47] | 530 | Statement * get_callStmt() const { return callStmt; } | 
|---|
| [f1b1e4c] | 531 | void set_callStmt( Statement * newValue ) { callStmt = newValue; } | 
|---|
|  | 532 |  | 
|---|
| [35a2d47] | 533 | virtual ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt( *this ); } | 
|---|
|  | 534 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
| [7870799] | 535 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
| [35a2d47] | 536 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 537 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
| [f1b1e4c] | 538 | }; | 
|---|
|  | 539 |  | 
|---|
| [6cebfef] | 540 | class MutexStmt : public Statement { | 
|---|
|  | 541 | public: | 
|---|
|  | 542 | Statement * stmt; | 
|---|
|  | 543 | std::list<Expression *> mutexObjs; // list of mutex objects to acquire | 
|---|
|  | 544 |  | 
|---|
| [6180274] | 545 | MutexStmt( Statement * stmt, const std::list<Expression *> mutexObjs ); | 
|---|
| [6cebfef] | 546 | MutexStmt( const MutexStmt & other ); | 
|---|
|  | 547 | virtual ~MutexStmt(); | 
|---|
|  | 548 |  | 
|---|
|  | 549 | virtual MutexStmt * clone() const override { return new MutexStmt( *this ); } | 
|---|
|  | 550 | virtual void accept( Visitor & v ) override { v.visit( this ); } | 
|---|
|  | 551 | virtual void accept( Visitor & v ) const override { v.visit( this ); } | 
|---|
|  | 552 | virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); } | 
|---|
|  | 553 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; | 
|---|
|  | 554 | }; | 
|---|
|  | 555 |  | 
|---|
| [0dd3a2f] | 556 | // Local Variables: // | 
|---|
|  | 557 | // tab-width: 4 // | 
|---|
|  | 558 | // mode: c++ // | 
|---|
|  | 559 | // compile-command: "make install" // | 
|---|
|  | 560 | // End: // | 
|---|