Changeset cd7ef0b for src/SynTree/Statement.h
- Timestamp:
- Aug 10, 2017, 3:39:11 PM (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:
- 38d70ab
- Parents:
- 275f4b4 (diff), e1780a2 (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
r275f4b4 rcd7ef0b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:54:32201713 // Update Count : 6 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 3 14:08:00 2017 13 // Update Count : 69 14 14 // 15 15 … … 26 26 class Statement : public BaseSyntaxNode { 27 27 public: 28 std::list<Label> labels; 29 28 30 Statement( std::list<Label> labels ); 29 31 virtual ~Statement(); … … 36 38 virtual Statement *acceptMutator( Mutator &m ) = 0; 37 39 virtual void print( std::ostream &os, int indent = 0 ) const; 38 protected:39 std::list<Label> labels;40 40 }; 41 41 42 42 class CompoundStmt : public Statement { 43 43 public: 44 std::list<Statement*> kids; 45 44 46 CompoundStmt( std::list<Label> labels ); 45 47 CompoundStmt( const CompoundStmt &other ); … … 54 56 virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 55 57 virtual void print( std::ostream &os, int indent = 0 ) const; 56 private:57 std::list<Statement*> kids;58 58 }; 59 59 … … 67 67 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 68 68 virtual void print( std::ostream &os, int indent = 0 ) const; 69 70 private:71 69 }; 72 70 73 71 class ExprStmt : public Statement { 74 72 public: 73 Expression *expr; 74 75 75 ExprStmt( std::list<Label> labels, Expression *expr ); 76 76 ExprStmt( const ExprStmt &other ); … … 84 84 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 85 85 virtual void print( std::ostream &os, int indent = 0 ) const; 86 private:87 Expression *expr;88 86 }; 89 87 90 88 class AsmStmt : public Statement { 91 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 92 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 ); 93 97 AsmStmt( const AsmStmt &other ); … … 111 115 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 112 116 virtual void print( std::ostream &os, int indent = 0 ) const; 113 private:114 bool voltile;115 ConstantExpr *instruction;116 std::list<Expression *> output, input;117 std::list<ConstantExpr *> clobber;118 std::list<Label> gotolabels;119 117 }; 120 118 121 119 class IfStmt : public Statement { 122 120 public: 121 Expression *condition; 122 Statement *thenPart; 123 Statement *elsePart; 124 123 125 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 124 126 IfStmt( const IfStmt &other ); … … 136 138 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 137 139 virtual void print( std::ostream &os, int indent = 0 ) const; 138 private:139 Expression *condition;140 Statement *thenPart;141 Statement *elsePart;142 140 }; 143 141 144 142 class SwitchStmt : public Statement { 145 143 public: 144 Expression * condition; 145 146 146 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 147 147 SwitchStmt( const SwitchStmt &other ); … … 159 159 virtual void print( std::ostream &os, int indent = 0 ) const; 160 160 private: 161 std::list<Statement *> statements; 162 }; 163 164 class CaseStmt : public Statement { 165 public: 161 166 Expression * condition; 162 std::list<Statement *> statements; 163 }; 164 165 class CaseStmt : public Statement { 166 public: 167 std::list<Statement *> stmts; 168 167 169 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 168 170 CaseStmt( const CaseStmt &other ); … … 186 188 virtual void print( std::ostream &os, int indent = 0 ) const; 187 189 private: 188 Expression * condition;189 std::list<Statement *> stmts;190 190 bool _isDefault; 191 191 }; … … 193 193 class WhileStmt : public Statement { 194 194 public: 195 Expression *condition; 196 Statement *body; 197 bool isDoWhile; 198 195 199 WhileStmt( std::list<Label> labels, Expression *condition, 196 200 Statement *body, bool isDoWhile = false ); … … 209 213 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 210 214 virtual void print( std::ostream &os, int indent = 0 ) const; 211 private: 215 }; 216 217 class ForStmt : public Statement { 218 public: 219 std::list<Statement *> initialization; 212 220 Expression *condition; 221 Expression *increment; 213 222 Statement *body; 214 bool isDoWhile; 215 }; 216 217 class ForStmt : public Statement { 218 public: 223 219 224 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 220 225 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); … … 235 240 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 236 241 virtual void print( std::ostream &os, int indent = 0 ) const; 237 private:238 std::list<Statement *> initialization;239 Expression *condition;240 Expression *increment;241 Statement *body;242 242 }; 243 243 … … 245 245 public: 246 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; 247 253 248 254 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); … … 265 271 private: 266 272 static const char *brType[]; 267 Label originalTarget; // can give better error messages if we remember the label name that the user entered268 Label target;269 Expression *computedTarget;270 Type type;271 273 }; 272 274 273 275 class ReturnStmt : public Statement { 274 276 public: 277 Expression *expr; 278 275 279 ReturnStmt( std::list<Label> labels, Expression *expr ); 276 280 ReturnStmt( const ReturnStmt &other ); … … 284 288 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 285 289 virtual void print( std::ostream &os, int indent = 0 ) const; 286 private:287 Expression *expr;288 290 }; 289 291 … … 291 293 public: 292 294 enum Kind { Terminate, Resume }; 295 296 const Kind kind; 297 Expression * expr; 298 Expression * target; 293 299 294 300 ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr ); … … 306 312 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 307 313 virtual void print( std::ostream &os, int indent = 0 ) const; 308 private:309 Kind kind;310 Expression * expr;311 Expression * target;312 314 }; 313 315 314 316 class TryStmt : public Statement { 315 317 public: 318 CompoundStmt *block; 319 std::list<CatchStmt *> handlers; 320 FinallyStmt *finallyBlock; 321 316 322 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 317 323 TryStmt( const TryStmt &other ); … … 329 335 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 330 336 virtual void print( std::ostream &os, int indent = 0 ) const; 331 332 private:333 CompoundStmt *block;334 std::list<CatchStmt *> handlers;335 FinallyStmt *finallyBlock;336 337 }; 337 338 … … 339 340 public: 340 341 enum Kind { Terminate, Resume }; 342 343 const Kind kind; 344 Declaration *decl; 345 Expression *cond; 346 Statement *body; 341 347 342 348 CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, … … 357 363 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 358 364 virtual void print( std::ostream &os, int indent = 0 ) const; 359 360 private:361 Kind kind;362 Declaration *decl;363 Expression *cond;364 Statement *body;365 365 }; 366 366 367 367 class FinallyStmt : public Statement { 368 368 public: 369 CompoundStmt *block; 370 369 371 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 370 372 FinallyStmt( const FinallyStmt &other ); … … 378 380 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 379 381 virtual void print( std::ostream &os, int indent = 0 ) const; 380 private:381 CompoundStmt *block;382 382 }; 383 383 … … 386 386 class DeclStmt : public Statement { 387 387 public: 388 Declaration *decl; 389 388 390 DeclStmt( std::list<Label> labels, Declaration *decl ); 389 391 DeclStmt( const DeclStmt &other ); … … 397 399 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 398 400 virtual void print( std::ostream &os, int indent = 0 ) const; 399 private:400 Declaration *decl;401 401 }; 402 402 … … 407 407 class ImplicitCtorDtorStmt : public Statement { 408 408 public: 409 // Non-owned pointer to the constructor/destructor statement 410 Statement * callStmt; 411 409 412 ImplicitCtorDtorStmt( Statement * callStmt ); 410 413 ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); … … 418 421 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 419 422 virtual void print( std::ostream &os, int indent = 0 ) const; 420 421 private:422 // Non-owned pointer to the constructor/destructor statement423 Statement * callStmt;424 423 }; 425 424
Note:
See TracChangeset
for help on using the changeset viewer.