Changeset 0720e049 for src/SynTree/Statement.h
- Timestamp:
- Aug 11, 2017, 10:33:37 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 54cd58b0
- Parents:
- 3d4b23fa (diff), 59a75cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:35:00 201713 // Update Count : 6 712 // Last Modified On : Thr Aug 3 14:08:00 2017 13 // Update Count : 69 14 14 // 15 15 16 #ifndef STATEMENT_H 17 #define STATEMENT_H 16 #pragma once 18 17 19 18 #include "BaseSyntaxNode.h" … … 27 26 class Statement : public BaseSyntaxNode { 28 27 public: 28 std::list<Label> labels; 29 29 30 Statement( std::list<Label> labels ); 30 31 virtual ~Statement(); … … 37 38 virtual Statement *acceptMutator( Mutator &m ) = 0; 38 39 virtual void print( std::ostream &os, int indent = 0 ) const; 39 protected:40 std::list<Label> labels;41 40 }; 42 41 43 42 class CompoundStmt : public Statement { 44 43 public: 44 std::list<Statement*> kids; 45 45 46 CompoundStmt( std::list<Label> labels ); 46 47 CompoundStmt( const CompoundStmt &other ); … … 55 56 virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 56 57 virtual void print( std::ostream &os, int indent = 0 ) const; 57 private:58 std::list<Statement*> kids;59 58 }; 60 59 … … 68 67 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 69 68 virtual void print( std::ostream &os, int indent = 0 ) const; 70 71 private:72 69 }; 73 70 74 71 class ExprStmt : public Statement { 75 72 public: 73 Expression *expr; 74 76 75 ExprStmt( std::list<Label> labels, Expression *expr ); 77 76 ExprStmt( const ExprStmt &other ); … … 85 84 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 86 85 virtual void print( std::ostream &os, int indent = 0 ) const; 87 private:88 Expression *expr;89 86 }; 90 87 91 88 class AsmStmt : public Statement { 92 89 public: 90 bool voltile; 91 ConstantExpr *instruction; 92 std::list<Expression *> output, input; 93 std::list<ConstantExpr *> clobber; 94 std::list<Label> gotolabels; 95 93 96 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 ); 94 97 AsmStmt( const AsmStmt &other ); … … 112 115 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 113 116 virtual void print( std::ostream &os, int indent = 0 ) const; 114 private:115 bool voltile;116 ConstantExpr *instruction;117 std::list<Expression *> output, input;118 std::list<ConstantExpr *> clobber;119 std::list<Label> gotolabels;120 117 }; 121 118 122 119 class IfStmt : public Statement { 123 120 public: 121 Expression *condition; 122 Statement *thenPart; 123 Statement *elsePart; 124 124 125 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 125 126 IfStmt( const IfStmt &other ); … … 137 138 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 138 139 virtual void print( std::ostream &os, int indent = 0 ) const; 139 private:140 Expression *condition;141 Statement *thenPart;142 Statement *elsePart;143 140 }; 144 141 145 142 class SwitchStmt : public Statement { 146 143 public: 144 Expression * condition; 145 147 146 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 148 147 SwitchStmt( const SwitchStmt &other ); … … 160 159 virtual void print( std::ostream &os, int indent = 0 ) const; 161 160 private: 161 std::list<Statement *> statements; 162 }; 163 164 class CaseStmt : public Statement { 165 public: 162 166 Expression * condition; 163 std::list<Statement *> statements; 164 }; 165 166 class CaseStmt : public Statement { 167 public: 167 std::list<Statement *> stmts; 168 168 169 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 169 170 CaseStmt( const CaseStmt &other ); … … 187 188 virtual void print( std::ostream &os, int indent = 0 ) const; 188 189 private: 189 Expression * condition;190 std::list<Statement *> stmts;191 190 bool _isDefault; 192 191 }; … … 194 193 class WhileStmt : public Statement { 195 194 public: 195 Expression *condition; 196 Statement *body; 197 bool isDoWhile; 198 196 199 WhileStmt( std::list<Label> labels, Expression *condition, 197 200 Statement *body, bool isDoWhile = false ); … … 210 213 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 211 214 virtual void print( std::ostream &os, int indent = 0 ) const; 212 private: 215 }; 216 217 class ForStmt : public Statement { 218 public: 219 std::list<Statement *> initialization; 213 220 Expression *condition; 221 Expression *increment; 214 222 Statement *body; 215 bool isDoWhile; 216 }; 217 218 class ForStmt : public Statement { 219 public: 223 220 224 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 221 225 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); … … 236 240 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 237 241 virtual void print( std::ostream &os, int indent = 0 ) const; 238 private:239 std::list<Statement *> initialization;240 Expression *condition;241 Expression *increment;242 Statement *body;243 242 }; 244 243 … … 246 245 public: 247 246 enum Type { Goto = 0, Break, Continue }; 247 248 // originalTarget kept for error messages. 249 const Label originalTarget; 250 Label target; 251 Expression *computedTarget; 252 Type type; 248 253 249 254 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); … … 266 271 private: 267 272 static const char *brType[]; 268 Label originalTarget; // can give better error messages if we remember the label name that the user entered269 Label target;270 Expression *computedTarget;271 Type type;272 273 }; 273 274 274 275 class ReturnStmt : public Statement { 275 276 public: 277 Expression *expr; 278 276 279 ReturnStmt( std::list<Label> labels, Expression *expr ); 277 280 ReturnStmt( const ReturnStmt &other ); … … 285 288 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 286 289 virtual void print( std::ostream &os, int indent = 0 ) const; 287 private:288 Expression *expr;289 290 }; 290 291 … … 292 293 public: 293 294 enum Kind { Terminate, Resume }; 295 296 const Kind kind; 297 Expression * expr; 298 Expression * target; 294 299 295 300 ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr ); … … 307 312 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 308 313 virtual void print( std::ostream &os, int indent = 0 ) const; 309 private:310 Kind kind;311 Expression * expr;312 Expression * target;313 314 }; 314 315 315 316 class TryStmt : public Statement { 316 317 public: 318 CompoundStmt *block; 319 std::list<CatchStmt *> handlers; 320 FinallyStmt *finallyBlock; 321 317 322 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 318 323 TryStmt( const TryStmt &other ); … … 330 335 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 331 336 virtual void print( std::ostream &os, int indent = 0 ) const; 332 333 private:334 CompoundStmt *block;335 std::list<CatchStmt *> handlers;336 FinallyStmt *finallyBlock;337 337 }; 338 338 … … 340 340 public: 341 341 enum Kind { Terminate, Resume }; 342 343 const Kind kind; 344 Declaration *decl; 345 Expression *cond; 346 Statement *body; 342 347 343 348 CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, … … 358 363 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 359 364 virtual void print( std::ostream &os, int indent = 0 ) const; 360 361 private:362 Kind kind;363 Declaration *decl;364 Expression *cond;365 Statement *body;366 365 }; 367 366 368 367 class FinallyStmt : public Statement { 369 368 public: 369 CompoundStmt *block; 370 370 371 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 371 372 FinallyStmt( const FinallyStmt &other ); … … 379 380 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 380 381 virtual void print( std::ostream &os, int indent = 0 ) const; 381 private:382 CompoundStmt *block;383 382 }; 384 383 … … 387 386 class DeclStmt : public Statement { 388 387 public: 388 Declaration *decl; 389 389 390 DeclStmt( std::list<Label> labels, Declaration *decl ); 390 391 DeclStmt( const DeclStmt &other ); … … 398 399 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 399 400 virtual void print( std::ostream &os, int indent = 0 ) const; 400 private:401 Declaration *decl;402 401 }; 403 402 … … 408 407 class ImplicitCtorDtorStmt : public Statement { 409 408 public: 409 // Non-owned pointer to the constructor/destructor statement 410 Statement * callStmt; 411 410 412 ImplicitCtorDtorStmt( Statement * callStmt ); 411 413 ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); … … 419 421 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 420 422 virtual void print( std::ostream &os, int indent = 0 ) const; 421 422 private:423 // Non-owned pointer to the constructor/destructor statement424 Statement * callStmt;425 423 }; 426 424 427 425 428 426 std::ostream & operator<<( std::ostream & out, const Statement * statement ); 429 430 #endif // STATEMENT_H431 427 432 428 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.