| [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 | 
|---|
| [6d49ea3] | 12 | // Last Modified On : Thu Aug 17 15:37:53 2017 | 
|---|
|  | 13 | // Update Count     : 72 | 
|---|
| [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 | 
|---|
|  | 21 |  | 
|---|
|  | 22 | #include "BaseSyntaxNode.h"        // for BaseSyntaxNode | 
|---|
|  | 23 | #include "Common/SemanticError.h"  // for SemanticError | 
|---|
|  | 24 | #include "Label.h"                 // for Label | 
|---|
|  | 25 | #include "Mutator.h"               // for Mutator | 
|---|
|  | 26 | #include "Visitor.h"               // for Visitor | 
|---|
|  | 27 |  | 
|---|
|  | 28 | class CatchStmt; | 
|---|
|  | 29 | class ConstantExpr; | 
|---|
|  | 30 | class Declaration; | 
|---|
|  | 31 | class Expression; | 
|---|
|  | 32 | class FinallyStmt; | 
|---|
| [51b73452] | 33 |  | 
|---|
| [294647b] | 34 | class Statement : public BaseSyntaxNode { | 
|---|
| [0dd3a2f] | 35 | public: | 
|---|
| [65cdc1e] | 36 | std::list<Label> labels; | 
|---|
|  | 37 |  | 
|---|
| [0dd3a2f] | 38 | Statement( std::list<Label> labels ); | 
|---|
|  | 39 | virtual ~Statement(); | 
|---|
| [51b73452] | 40 |  | 
|---|
| [0dd3a2f] | 41 | std::list<Label> & get_labels() { return labels; } | 
|---|
| [de62360d] | 42 | const std::list<Label> & get_labels() const { return labels; } | 
|---|
| [51b73452] | 43 |  | 
|---|
| [0dd3a2f] | 44 | virtual Statement *clone() const = 0; | 
|---|
|  | 45 | virtual void accept( Visitor &v ) = 0; | 
|---|
|  | 46 | virtual Statement *acceptMutator( Mutator &m ) = 0; | 
|---|
| [de62360d] | 47 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 48 | }; | 
|---|
|  | 49 |  | 
|---|
| [0dd3a2f] | 50 | class CompoundStmt : public Statement { | 
|---|
|  | 51 | public: | 
|---|
| [65cdc1e] | 52 | std::list<Statement*> kids; | 
|---|
|  | 53 |  | 
|---|
| [0dd3a2f] | 54 | CompoundStmt( std::list<Label> labels ); | 
|---|
|  | 55 | CompoundStmt( const CompoundStmt &other ); | 
|---|
|  | 56 | virtual ~CompoundStmt(); | 
|---|
| [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 |  | 
|---|
| [0dd3a2f] | 62 | virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); } | 
|---|
|  | 63 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 64 | virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 65 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 66 | }; | 
|---|
|  | 67 |  | 
|---|
| [daf1af8] | 68 | class NullStmt : public CompoundStmt { | 
|---|
|  | 69 | public: | 
|---|
|  | 70 | NullStmt(); | 
|---|
|  | 71 | NullStmt( std::list<Label> labels ); | 
|---|
|  | 72 |  | 
|---|
|  | 73 | virtual NullStmt *clone() const { return new NullStmt( *this ); } | 
|---|
|  | 74 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 75 | virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
|  | 76 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
|  | 77 | }; | 
|---|
|  | 78 |  | 
|---|
| [0dd3a2f] | 79 | class ExprStmt : public Statement { | 
|---|
|  | 80 | public: | 
|---|
| [65cdc1e] | 81 | Expression *expr; | 
|---|
|  | 82 |  | 
|---|
| [0dd3a2f] | 83 | ExprStmt( std::list<Label> labels, Expression *expr ); | 
|---|
| [3be261a] | 84 | ExprStmt( const ExprStmt &other ); | 
|---|
| [0dd3a2f] | 85 | virtual ~ExprStmt(); | 
|---|
| [51b73452] | 86 |  | 
|---|
| [0dd3a2f] | 87 | Expression *get_expr() { return expr; } | 
|---|
|  | 88 | void set_expr( Expression *newValue ) { expr = newValue; } | 
|---|
| [51b73452] | 89 |  | 
|---|
| [0dd3a2f] | 90 | virtual ExprStmt *clone() const { return new ExprStmt( *this ); } | 
|---|
|  | 91 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 92 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 93 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [0dd3a2f] | 94 | }; | 
|---|
| [51b73452] | 95 |  | 
|---|
| [7f5566b] | 96 | class AsmStmt : public Statement { | 
|---|
|  | 97 | public: | 
|---|
| [65cdc1e] | 98 | bool voltile; | 
|---|
|  | 99 | ConstantExpr *instruction; | 
|---|
|  | 100 | std::list<Expression *> output, input; | 
|---|
|  | 101 | std::list<ConstantExpr *> clobber; | 
|---|
|  | 102 | std::list<Label> gotolabels; | 
|---|
|  | 103 |  | 
|---|
| [7f5566b] | 104 | AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); | 
|---|
| [3be261a] | 105 | AsmStmt( const AsmStmt &other ); | 
|---|
| [7f5566b] | 106 | virtual ~AsmStmt(); | 
|---|
|  | 107 |  | 
|---|
|  | 108 | bool get_voltile() { return voltile; } | 
|---|
|  | 109 | void set_voltile( bool newValue ) { voltile = newValue; } | 
|---|
|  | 110 | ConstantExpr *get_instruction() { return instruction; } | 
|---|
|  | 111 | void set_instruction( ConstantExpr *newValue ) { instruction = newValue; } | 
|---|
|  | 112 | std::list<Expression *> &get_output() { return output; } | 
|---|
|  | 113 | void set_output( const std::list<Expression *> &newValue ) { output = newValue; } | 
|---|
|  | 114 | std::list<Expression *> &get_input() { return input; } | 
|---|
|  | 115 | void set_input( const std::list<Expression *> &newValue ) { input = newValue; } | 
|---|
|  | 116 | std::list<ConstantExpr *> &get_clobber() { return clobber; } | 
|---|
|  | 117 | void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; } | 
|---|
|  | 118 | std::list<Label> &get_gotolabels() { return gotolabels; } | 
|---|
|  | 119 | void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; } | 
|---|
|  | 120 |  | 
|---|
|  | 121 | virtual AsmStmt *clone() const { return new AsmStmt( *this ); } | 
|---|
|  | 122 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 123 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
|  | 124 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
|  | 125 | }; | 
|---|
|  | 126 |  | 
|---|
| [0dd3a2f] | 127 | class IfStmt : public Statement { | 
|---|
|  | 128 | public: | 
|---|
| [65cdc1e] | 129 | Expression *condition; | 
|---|
|  | 130 | Statement *thenPart; | 
|---|
|  | 131 | Statement *elsePart; | 
|---|
| [6d49ea3] | 132 | std::list<Statement *> initialization; | 
|---|
| [65cdc1e] | 133 |  | 
|---|
| [6d49ea3] | 134 | IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart, | 
|---|
|  | 135 | std::list<Statement *> initialization = std::list<Statement *>() ); | 
|---|
| [3be261a] | 136 | IfStmt( const IfStmt &other ); | 
|---|
| [0dd3a2f] | 137 | virtual ~IfStmt(); | 
|---|
|  | 138 |  | 
|---|
| [936e9f4] | 139 | std::list<Statement *> &get_initialization() { return initialization; } | 
|---|
| [0dd3a2f] | 140 | Expression *get_condition() { return condition; } | 
|---|
|  | 141 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
|  | 142 | Statement *get_thenPart() { return thenPart; } | 
|---|
|  | 143 | void set_thenPart( Statement *newValue ) { thenPart = newValue; } | 
|---|
|  | 144 | Statement *get_elsePart() { return elsePart; } | 
|---|
|  | 145 | void set_elsePart( Statement *newValue ) { elsePart = newValue; } | 
|---|
| [3be261a] | 146 |  | 
|---|
| [0dd3a2f] | 147 | virtual IfStmt *clone() const { return new IfStmt( *this ); } | 
|---|
|  | 148 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 149 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 150 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 151 | }; | 
|---|
|  | 152 |  | 
|---|
| [0dd3a2f] | 153 | class SwitchStmt : public Statement { | 
|---|
|  | 154 | public: | 
|---|
| [65cdc1e] | 155 | Expression * condition; | 
|---|
|  | 156 |  | 
|---|
| [8688ce1] | 157 | SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); | 
|---|
| [3be261a] | 158 | SwitchStmt( const SwitchStmt &other ); | 
|---|
| [0dd3a2f] | 159 | virtual ~SwitchStmt(); | 
|---|
| [51b73452] | 160 |  | 
|---|
| [0dd3a2f] | 161 | Expression *get_condition() { return condition; } | 
|---|
|  | 162 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
| [51b73452] | 163 |  | 
|---|
| [8688ce1] | 164 | std::list<Statement *> & get_statements() { return statements; } | 
|---|
| [51b73452] | 165 |  | 
|---|
| [0dd3a2f] | 166 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 167 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [51b73452] | 168 |  | 
|---|
| [0dd3a2f] | 169 | virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); } | 
|---|
| [de62360d] | 170 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [0dd3a2f] | 171 | private: | 
|---|
| [8688ce1] | 172 | std::list<Statement *> statements; | 
|---|
| [51b73452] | 173 | }; | 
|---|
|  | 174 |  | 
|---|
| [0dd3a2f] | 175 | class CaseStmt : public Statement { | 
|---|
|  | 176 | public: | 
|---|
| [65cdc1e] | 177 | Expression * condition; | 
|---|
|  | 178 | std::list<Statement *> stmts; | 
|---|
|  | 179 |  | 
|---|
| [8688ce1] | 180 | CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); | 
|---|
| [3be261a] | 181 | CaseStmt( const CaseStmt &other ); | 
|---|
| [0dd3a2f] | 182 | virtual ~CaseStmt(); | 
|---|
|  | 183 |  | 
|---|
| [8688ce1] | 184 | static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() ); | 
|---|
| [b2152e7a] | 185 |  | 
|---|
| [de62360d] | 186 | bool isDefault() const { return _isDefault; } | 
|---|
| [0dd3a2f] | 187 | void set_default(bool b) { _isDefault = b; } | 
|---|
|  | 188 |  | 
|---|
|  | 189 | Expression * &get_condition() { return condition; } | 
|---|
|  | 190 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
|  | 191 |  | 
|---|
|  | 192 | std::list<Statement *> &get_statements() { return stmts; } | 
|---|
|  | 193 | void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; } | 
|---|
| [3be261a] | 194 |  | 
|---|
| [0dd3a2f] | 195 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 196 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
|  | 197 |  | 
|---|
|  | 198 | virtual CaseStmt *clone() const { return new CaseStmt( *this ); } | 
|---|
| [de62360d] | 199 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [0dd3a2f] | 200 | private: | 
|---|
|  | 201 | bool _isDefault; | 
|---|
| [51b73452] | 202 | }; | 
|---|
|  | 203 |  | 
|---|
| [0dd3a2f] | 204 | class WhileStmt : public Statement { | 
|---|
|  | 205 | public: | 
|---|
| [65cdc1e] | 206 | Expression *condition; | 
|---|
|  | 207 | Statement *body; | 
|---|
|  | 208 | bool isDoWhile; | 
|---|
|  | 209 |  | 
|---|
| [0dd3a2f] | 210 | WhileStmt( std::list<Label> labels, Expression *condition, | 
|---|
|  | 211 | Statement *body, bool isDoWhile = false ); | 
|---|
| [3be261a] | 212 | WhileStmt( const WhileStmt &other ); | 
|---|
| [0dd3a2f] | 213 | virtual ~WhileStmt(); | 
|---|
|  | 214 |  | 
|---|
|  | 215 | Expression *get_condition() { return condition; } | 
|---|
|  | 216 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
|  | 217 | Statement *get_body() { return body; } | 
|---|
|  | 218 | void set_body( Statement *newValue ) { body = newValue; } | 
|---|
|  | 219 | bool get_isDoWhile() { return isDoWhile; } | 
|---|
|  | 220 | void set_isDoWhile( bool newValue ) { isDoWhile = newValue; } | 
|---|
| [3be261a] | 221 |  | 
|---|
| [0dd3a2f] | 222 | virtual WhileStmt *clone() const { return new WhileStmt( *this ); } | 
|---|
|  | 223 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 224 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 225 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 226 | }; | 
|---|
|  | 227 |  | 
|---|
| [0dd3a2f] | 228 | class ForStmt : public Statement { | 
|---|
|  | 229 | public: | 
|---|
| [65cdc1e] | 230 | std::list<Statement *> initialization; | 
|---|
|  | 231 | Expression *condition; | 
|---|
|  | 232 | Expression *increment; | 
|---|
|  | 233 | Statement *body; | 
|---|
|  | 234 |  | 
|---|
| [145f1fc] | 235 | ForStmt( std::list<Label> labels, std::list<Statement *> initialization, | 
|---|
| [0dd3a2f] | 236 | Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); | 
|---|
| [3be261a] | 237 | ForStmt( const ForStmt &other ); | 
|---|
| [0dd3a2f] | 238 | virtual ~ForStmt(); | 
|---|
|  | 239 |  | 
|---|
| [145f1fc] | 240 | std::list<Statement *> &get_initialization() { return initialization; } | 
|---|
| [0dd3a2f] | 241 | Expression *get_condition() { return condition; } | 
|---|
|  | 242 | void set_condition( Expression *newValue ) { condition = newValue; } | 
|---|
|  | 243 | Expression *get_increment() { return increment; } | 
|---|
|  | 244 | void set_increment( Expression *newValue ) { increment = newValue; } | 
|---|
|  | 245 | Statement *get_body() { return body; } | 
|---|
|  | 246 | void set_body( Statement *newValue ) { body = newValue; } | 
|---|
| [3be261a] | 247 |  | 
|---|
| [0dd3a2f] | 248 | virtual ForStmt *clone() const { return new ForStmt( *this ); } | 
|---|
|  | 249 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 250 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 251 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 252 | }; | 
|---|
|  | 253 |  | 
|---|
| [0dd3a2f] | 254 | class BranchStmt : public Statement { | 
|---|
|  | 255 | public: | 
|---|
| [de62360d] | 256 | enum Type { Goto = 0, Break, Continue }; | 
|---|
| [0dd3a2f] | 257 |  | 
|---|
| [65cdc1e] | 258 | // originalTarget kept for error messages. | 
|---|
|  | 259 | const Label originalTarget; | 
|---|
|  | 260 | Label target; | 
|---|
|  | 261 | Expression *computedTarget; | 
|---|
|  | 262 | Type type; | 
|---|
|  | 263 |  | 
|---|
| [0dd3a2f] | 264 | BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); | 
|---|
|  | 265 | BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError); | 
|---|
|  | 266 |  | 
|---|
| [be5aa1b] | 267 | Label get_originalTarget() { return originalTarget; } | 
|---|
| [0dd3a2f] | 268 | Label get_target() { return target; } | 
|---|
|  | 269 | void set_target( Label newValue ) { target = newValue; } | 
|---|
| [3be261a] | 270 |  | 
|---|
| [0dd3a2f] | 271 | Expression *get_computedTarget() { return computedTarget; } | 
|---|
|  | 272 | void set_target( Expression * newValue ) { computedTarget = newValue; } | 
|---|
|  | 273 |  | 
|---|
|  | 274 | Type get_type() { return type; } | 
|---|
|  | 275 | const char *get_typename() { return brType[ type ]; } | 
|---|
|  | 276 |  | 
|---|
|  | 277 | virtual BranchStmt *clone() const { return new BranchStmt( *this ); } | 
|---|
|  | 278 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 279 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 280 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [0dd3a2f] | 281 | private: | 
|---|
|  | 282 | static const char *brType[]; | 
|---|
| [51b73452] | 283 | }; | 
|---|
|  | 284 |  | 
|---|
| [0dd3a2f] | 285 | class ReturnStmt : public Statement { | 
|---|
|  | 286 | public: | 
|---|
| [65cdc1e] | 287 | Expression *expr; | 
|---|
|  | 288 |  | 
|---|
| [daf1af8] | 289 | ReturnStmt( std::list<Label> labels, Expression *expr ); | 
|---|
| [3be261a] | 290 | ReturnStmt( const ReturnStmt &other ); | 
|---|
| [0dd3a2f] | 291 | virtual ~ReturnStmt(); | 
|---|
|  | 292 |  | 
|---|
|  | 293 | Expression *get_expr() { return expr; } | 
|---|
|  | 294 | void set_expr( Expression *newValue ) { expr = newValue; } | 
|---|
| [3be261a] | 295 |  | 
|---|
| [0dd3a2f] | 296 | virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); } | 
|---|
|  | 297 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 298 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 299 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 300 | }; | 
|---|
|  | 301 |  | 
|---|
| [daf1af8] | 302 | class ThrowStmt : public Statement { | 
|---|
| [0dd3a2f] | 303 | public: | 
|---|
| [daf1af8] | 304 | enum Kind { Terminate, Resume }; | 
|---|
| [51b73452] | 305 |  | 
|---|
| [65cdc1e] | 306 | const Kind kind; | 
|---|
|  | 307 | Expression * expr; | 
|---|
|  | 308 | Expression * target; | 
|---|
|  | 309 |  | 
|---|
| [ca78437] | 310 | ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr ); | 
|---|
| [daf1af8] | 311 | ThrowStmt( const ThrowStmt &other ); | 
|---|
|  | 312 | virtual ~ThrowStmt(); | 
|---|
|  | 313 |  | 
|---|
|  | 314 | Kind get_kind() { return kind; } | 
|---|
|  | 315 | Expression * get_expr() { return expr; } | 
|---|
|  | 316 | void set_expr( Expression * newExpr ) { expr = newExpr; } | 
|---|
|  | 317 | Expression * get_target() { return target; } | 
|---|
|  | 318 | void set_target( Expression * newTarget ) { target = newTarget; } | 
|---|
|  | 319 |  | 
|---|
|  | 320 | virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); } | 
|---|
| [0dd3a2f] | 321 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
| [daf1af8] | 322 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 323 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 324 | }; | 
|---|
|  | 325 |  | 
|---|
| [3be261a] | 326 | class TryStmt : public Statement { | 
|---|
| [0dd3a2f] | 327 | public: | 
|---|
| [65cdc1e] | 328 | CompoundStmt *block; | 
|---|
|  | 329 | std::list<CatchStmt *> handlers; | 
|---|
|  | 330 | FinallyStmt *finallyBlock; | 
|---|
|  | 331 |  | 
|---|
| [046e04a] | 332 | TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); | 
|---|
| [0dd3a2f] | 333 | TryStmt( const TryStmt &other ); | 
|---|
|  | 334 | virtual ~TryStmt(); | 
|---|
|  | 335 |  | 
|---|
|  | 336 | CompoundStmt *get_block() const { return block; } | 
|---|
|  | 337 | void set_block( CompoundStmt *newValue ) { block = newValue; } | 
|---|
| [046e04a] | 338 | std::list<CatchStmt *>& get_catchers() { return handlers; } | 
|---|
| [0dd3a2f] | 339 |  | 
|---|
|  | 340 | FinallyStmt *get_finally() const { return finallyBlock; } | 
|---|
|  | 341 | void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; } | 
|---|
|  | 342 |  | 
|---|
|  | 343 | virtual TryStmt *clone() const { return new TryStmt( *this ); } | 
|---|
|  | 344 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 345 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 346 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [3be261a] | 347 | }; | 
|---|
| [51b73452] | 348 |  | 
|---|
| [0dd3a2f] | 349 | class CatchStmt : public Statement { | 
|---|
|  | 350 | public: | 
|---|
| [ca78437] | 351 | enum Kind { Terminate, Resume }; | 
|---|
|  | 352 |  | 
|---|
| [65cdc1e] | 353 | const Kind kind; | 
|---|
|  | 354 | Declaration *decl; | 
|---|
|  | 355 | Expression *cond; | 
|---|
|  | 356 | Statement *body; | 
|---|
|  | 357 |  | 
|---|
| [ca78437] | 358 | CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, | 
|---|
|  | 359 | Expression *cond, Statement *body ); | 
|---|
| [3be261a] | 360 | CatchStmt( const CatchStmt &other ); | 
|---|
| [0dd3a2f] | 361 | virtual ~CatchStmt(); | 
|---|
|  | 362 |  | 
|---|
| [ca78437] | 363 | Kind get_kind() { return kind; } | 
|---|
| [0dd3a2f] | 364 | Declaration *get_decl() { return decl; } | 
|---|
|  | 365 | void set_decl( Declaration *newValue ) { decl = newValue; } | 
|---|
| [ca78437] | 366 | Expression *get_cond() { return cond; } | 
|---|
|  | 367 | void set_cond( Expression *newCond ) { cond = newCond; } | 
|---|
| [0dd3a2f] | 368 | Statement *get_body() { return body; } | 
|---|
|  | 369 | void set_body( Statement *newValue ) { body = newValue; } | 
|---|
| [3be261a] | 370 |  | 
|---|
| [0dd3a2f] | 371 | virtual CatchStmt *clone() const { return new CatchStmt( *this ); } | 
|---|
|  | 372 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 373 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 374 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 375 | }; | 
|---|
|  | 376 |  | 
|---|
| [3be261a] | 377 | class FinallyStmt : public Statement { | 
|---|
| [0dd3a2f] | 378 | public: | 
|---|
| [65cdc1e] | 379 | CompoundStmt *block; | 
|---|
|  | 380 |  | 
|---|
| [0dd3a2f] | 381 | FinallyStmt( std::list<Label> labels, CompoundStmt *block ); | 
|---|
| [3be261a] | 382 | FinallyStmt( const FinallyStmt &other ); | 
|---|
| [0dd3a2f] | 383 | virtual ~FinallyStmt(); | 
|---|
|  | 384 |  | 
|---|
|  | 385 | CompoundStmt *get_block() const { return block; } | 
|---|
|  | 386 | void set_block( CompoundStmt *newValue ) { block = newValue; } | 
|---|
| [3be261a] | 387 |  | 
|---|
| [0dd3a2f] | 388 | virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); } | 
|---|
|  | 389 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 390 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 391 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [3be261a] | 392 | }; | 
|---|
| [51b73452] | 393 |  | 
|---|
|  | 394 |  | 
|---|
|  | 395 | // represents a declaration that occurs as part of a compound statement | 
|---|
| [0dd3a2f] | 396 | class DeclStmt : public Statement { | 
|---|
|  | 397 | public: | 
|---|
| [65cdc1e] | 398 | Declaration *decl; | 
|---|
|  | 399 |  | 
|---|
| [0dd3a2f] | 400 | DeclStmt( std::list<Label> labels, Declaration *decl ); | 
|---|
|  | 401 | DeclStmt( const DeclStmt &other ); | 
|---|
|  | 402 | virtual ~DeclStmt(); | 
|---|
|  | 403 |  | 
|---|
| [f1b1e4c] | 404 | Declaration *get_decl() const { return decl; } | 
|---|
| [0dd3a2f] | 405 | void set_decl( Declaration *newValue ) { decl = newValue; } | 
|---|
|  | 406 |  | 
|---|
|  | 407 | virtual DeclStmt *clone() const { return new DeclStmt( *this ); } | 
|---|
|  | 408 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 409 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
| [de62360d] | 410 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
| [51b73452] | 411 | }; | 
|---|
|  | 412 |  | 
|---|
| [f1b1e4c] | 413 |  | 
|---|
|  | 414 | /// represents an implicit application of a constructor or destructor. Qualifiers are replaced | 
|---|
|  | 415 | /// immediately before and after the call so that qualified objects can be constructed | 
|---|
|  | 416 | /// with the same functions as unqualified objects. | 
|---|
|  | 417 | class ImplicitCtorDtorStmt : public Statement { | 
|---|
|  | 418 | public: | 
|---|
| [65cdc1e] | 419 | // Non-owned pointer to the constructor/destructor statement | 
|---|
|  | 420 | Statement * callStmt; | 
|---|
|  | 421 |  | 
|---|
| [f1b1e4c] | 422 | ImplicitCtorDtorStmt( Statement * callStmt ); | 
|---|
|  | 423 | ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); | 
|---|
|  | 424 | virtual ~ImplicitCtorDtorStmt(); | 
|---|
|  | 425 |  | 
|---|
|  | 426 | Statement *get_callStmt() const { return callStmt; } | 
|---|
|  | 427 | void set_callStmt( Statement * newValue ) { callStmt = newValue; } | 
|---|
|  | 428 |  | 
|---|
|  | 429 | virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); } | 
|---|
|  | 430 | virtual void accept( Visitor &v ) { v.visit( this ); } | 
|---|
|  | 431 | virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } | 
|---|
|  | 432 | virtual void print( std::ostream &os, int indent = 0 ) const; | 
|---|
|  | 433 | }; | 
|---|
|  | 434 |  | 
|---|
|  | 435 |  | 
|---|
| [3906301] | 436 | std::ostream & operator<<( std::ostream & out, const Statement * statement ); | 
|---|
| [baf7fee] | 437 |  | 
|---|
| [0dd3a2f] | 438 | // Local Variables: // | 
|---|
|  | 439 | // tab-width: 4 // | 
|---|
|  | 440 | // mode: c++ // | 
|---|
|  | 441 | // compile-command: "make install" // | 
|---|
|  | 442 | // End: // | 
|---|