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