Changes in src/SynTree/Statement.h [7f5566b:8688ce1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.h
r7f5566b r8688ce1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Statement.h -- 7 // Statement.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 25 18:25:37 201513 // Update Count : 4412 // Last Modified On : Thu Aug 4 11:26:02 2016 13 // Update Count : 64 14 14 // 15 15 … … 21 21 #include "Mutator.h" 22 22 #include "Common/SemanticError.h" 23 #include "Type.h" 24 #include "Label.h" 23 25 24 26 class Statement { … … 57 59 public: 58 60 ExprStmt( std::list<Label> labels, Expression *expr ); 61 ExprStmt( const ExprStmt &other ); 59 62 virtual ~ExprStmt(); 60 63 … … 73 76 public: 74 77 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 ); 78 AsmStmt( const AsmStmt &other ); 75 79 virtual ~AsmStmt(); 76 80 … … 103 107 public: 104 108 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 109 IfStmt( const IfStmt &other ); 105 110 virtual ~IfStmt(); 106 111 … … 111 116 Statement *get_elsePart() { return elsePart; } 112 117 void set_elsePart( Statement *newValue ) { elsePart = newValue; } 113 118 114 119 virtual IfStmt *clone() const { return new IfStmt( *this ); } 115 120 virtual void accept( Visitor &v ) { v.visit( this ); } … … 124 129 class SwitchStmt : public Statement { 125 130 public: 126 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 132 SwitchStmt( const SwitchStmt &other ); 127 133 virtual ~SwitchStmt(); 128 134 … … 130 136 void set_condition( Expression *newValue ) { condition = newValue; } 131 137 132 std::list<Statement *> & get_branches() { return branches; } 133 void add_case( CaseStmt * ); 138 std::list<Statement *> & get_statements() { return statements; } 134 139 135 140 virtual void accept( Visitor &v ) { v.visit( this ); } … … 140 145 private: 141 146 Expression * condition; 142 std::list<Statement *> branches; // should be list of CaseStmt 143 }; 144 145 class ChooseStmt : public Statement { 146 public: 147 ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 148 virtual ~ChooseStmt(); 149 150 Expression *get_condition() { return condition; } 151 void set_condition( Expression *newValue ) { condition = newValue; } 152 153 std::list<Statement *>& get_branches() { return branches; } 154 void add_case( CaseStmt * ); 155 156 virtual void accept( Visitor &v ) { v.visit( this ); } 157 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 158 159 virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); } 160 virtual void print( std::ostream &os, int indent = 0 ) const; 161 private: 162 Expression *condition; 163 std::list<Statement *> branches; // should be list of CaseStmt 164 }; 165 166 class FallthruStmt : public Statement { 167 public: 168 FallthruStmt( std::list<Label> labels ) : Statement( labels ) { } 169 170 virtual void accept( Visitor &v ) { v.visit( this ); } 171 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 172 173 virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); } 174 virtual void print( std::ostream &os, int indent = 0 ) const; 147 std::list<Statement *> statements; 175 148 }; 176 149 177 150 class CaseStmt : public Statement { 178 151 public: 179 CaseStmt( std::list<Label> labels, Expression *conditions, 180 std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);152 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 153 CaseStmt( const CaseStmt &other ); 181 154 virtual ~CaseStmt(); 182 155 183 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), 184 std::list<Statement *> stmts = std::list<Statement *>() ); 156 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() ); 185 157 186 158 bool isDefault() const { return _isDefault; } … … 192 164 std::list<Statement *> &get_statements() { return stmts; } 193 165 void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; } 194 166 195 167 virtual void accept( Visitor &v ) { v.visit( this ); } 196 168 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 208 180 WhileStmt( std::list<Label> labels, Expression *condition, 209 181 Statement *body, bool isDoWhile = false ); 182 WhileStmt( const WhileStmt &other ); 210 183 virtual ~WhileStmt(); 211 184 … … 216 189 bool get_isDoWhile() { return isDoWhile; } 217 190 void set_isDoWhile( bool newValue ) { isDoWhile = newValue; } 218 191 219 192 virtual WhileStmt *clone() const { return new WhileStmt( *this ); } 220 193 virtual void accept( Visitor &v ) { v.visit( this ); } … … 231 204 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 232 205 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 206 ForStmt( const ForStmt &other ); 233 207 virtual ~ForStmt(); 234 208 … … 241 215 Statement *get_body() { return body; } 242 216 void set_body( Statement *newValue ) { body = newValue; } 243 217 244 218 virtual ForStmt *clone() const { return new ForStmt( *this ); } 245 219 virtual void accept( Visitor &v ) { v.visit( this ); } … … 259 233 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); 260 234 BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError); 261 virtual ~BranchStmt() {}262 235 263 236 Label get_originalTarget() { return originalTarget; } 264 237 Label get_target() { return target; } 265 238 void set_target( Label newValue ) { target = newValue; } 266 239 267 240 Expression *get_computedTarget() { return computedTarget; } 268 241 void set_target( Expression * newValue ) { computedTarget = newValue; } … … 286 259 public: 287 260 ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false ); 261 ReturnStmt( const ReturnStmt &other ); 288 262 virtual ~ReturnStmt(); 289 263 290 264 Expression *get_expr() { return expr; } 291 265 void set_expr( Expression *newValue ) { expr = newValue; } 292 266 293 267 virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); } 294 268 virtual void accept( Visitor &v ) { v.visit( this ); } … … 305 279 NullStmt(); 306 280 NullStmt( std::list<Label> labels ); 307 virtual ~NullStmt();308 281 309 282 virtual NullStmt *clone() const { return new NullStmt( *this ); } … … 311 284 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 312 285 virtual void print( std::ostream &os, int indent = 0 ) const; 313 314 private: 315 }; 316 317 class TryStmt : public Statement { 286 287 private: 288 }; 289 290 class TryStmt : public Statement { 318 291 public: 319 292 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 ); … … 332 305 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 333 306 virtual void print( std::ostream &os, int indent = 0 ) const; 334 307 335 308 private: 336 309 CompoundStmt *block; 337 310 std::list<Statement *> handlers; 338 311 FinallyStmt *finallyBlock; 339 }; 312 }; 340 313 341 314 class CatchStmt : public Statement { 342 315 public: 343 316 CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false ); 317 CatchStmt( const CatchStmt &other ); 344 318 virtual ~CatchStmt(); 345 319 … … 349 323 Statement *get_body() { return body; } 350 324 void set_body( Statement *newValue ) { body = newValue; } 351 325 352 326 virtual CatchStmt *clone() const { return new CatchStmt( *this ); } 353 327 virtual void accept( Visitor &v ) { v.visit( this ); } 354 328 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 355 329 virtual void print( std::ostream &os, int indent = 0 ) const; 356 330 357 331 private: 358 332 Declaration *decl; … … 361 335 }; 362 336 363 class FinallyStmt : public Statement { 337 class FinallyStmt : public Statement { 364 338 public: 365 339 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 340 FinallyStmt( const FinallyStmt &other ); 366 341 virtual ~FinallyStmt(); 367 342 368 343 CompoundStmt *get_block() const { return block; } 369 344 void set_block( CompoundStmt *newValue ) { block = newValue; } 370 345 371 346 virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); } 372 347 virtual void accept( Visitor &v ) { v.visit( this ); } … … 375 350 private: 376 351 CompoundStmt *block; 377 }; 352 }; 378 353 379 354 … … 385 360 virtual ~DeclStmt(); 386 361 387 Declaration *get_decl() { return decl; }362 Declaration *get_decl() const { return decl; } 388 363 void set_decl( Declaration *newValue ) { decl = newValue; } 389 364 … … 395 370 Declaration *decl; 396 371 }; 372 373 374 /// represents an implicit application of a constructor or destructor. Qualifiers are replaced 375 /// immediately before and after the call so that qualified objects can be constructed 376 /// with the same functions as unqualified objects. 377 class ImplicitCtorDtorStmt : public Statement { 378 public: 379 ImplicitCtorDtorStmt( Statement * callStmt ); 380 ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); 381 virtual ~ImplicitCtorDtorStmt(); 382 383 Statement *get_callStmt() const { return callStmt; } 384 void set_callStmt( Statement * newValue ) { callStmt = newValue; } 385 386 virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); } 387 virtual void accept( Visitor &v ) { v.visit( this ); } 388 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 389 virtual void print( std::ostream &os, int indent = 0 ) const; 390 391 private: 392 // Non-owned pointer to the constructor/destructor statement 393 Statement * callStmt; 394 }; 395 396 397 std::ostream & operator<<( std::ostream & out, Statement * statement ); 397 398 398 399 #endif // STATEMENT_H
Note:
See TracChangeset
for help on using the changeset viewer.