Changes in src/AST/Stmt.hpp [a1da039:eb779d5]
- File:
-
- 1 edited
-
src/AST/Stmt.hpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.hpp
ra1da039 reb779d5 28 28 // Must be included in *all* AST classes; should be #undef'd at the end of the file 29 29 #define MUTATE_FRIEND \ 30 template<typename node_t> friend node_t * mutate(const node_t * node); \30 template<typename node_t> friend node_t * mutate(const node_t * node); \ 31 31 template<typename node_t> friend node_t * shallowCopy(const node_t * node); 32 32 … … 340 340 341 341 CatchClause( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 342 const Stmt * body )342 const Stmt * body ) 343 343 : StmtClause(loc), decl(decl), cond(cond), body(body), kind(kind) {} 344 344 … … 380 380 // Base class of WaitFor/WaitUntil statements 381 381 // form: KEYWORD(...) ... timeout(...) ... else ... 382 class WaitStmt : public Stmt { 383 public: 384 ptr<Expr> timeout_time;382 class WaitStmt : public Stmt { 383 public: 384 ptr<Expr> timeout_time; 385 385 ptr<Stmt> timeout_stmt; 386 386 ptr<Expr> timeout_cond; … … 388 388 ptr<Expr> else_cond; 389 389 390 WaitStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )390 WaitStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 391 391 : Stmt(loc, std::move(labels)) {} 392 392 393 393 private: 394 WaitStmt * clone() const override = 0;394 WaitStmt * clone() const override = 0; 395 395 MUTATE_FRIEND 396 396 }; … … 444 444 class WaitUntilStmt final : public WaitStmt { 445 445 public: 446 // Non-ast node used during compilation to store data needed to generate predicates447 // and set initial status values for clauses448 // Used to create a tree corresponding to the structure of the clauses in a WaitUntil449 struct ClauseNode { 450 enum Op { AND, OR, LEFT_OR, LEAF, ELSE, TIMEOUT } op; // operation/type tag451 // LEFT_OR used with TIMEOUT/ELSE to indicate that we ignore right hand side after parsing452 453 ClauseNode * left;454 ClauseNode * right;455 WhenClause * leaf; // only set if this node is a leaf (points into vector of clauses)456 457 bool ambiguousWhen; // used to paint nodes of predicate tree based on when() clauses458 bool whenState; // used to track if when_cond is toggled on or off for generating init values459 bool childOfAnd; // true on leaf nodes that are children of AND, false otherwise460 461 ClauseNode( Op op, ClauseNode * left, ClauseNode * right )462 : op(op), left(left), right(right), leaf(nullptr), 463 ambiguousWhen(false), whenState(true), childOfAnd(false) {}464 ClauseNode( Op op, WhenClause * leaf )465 : op(op), left(nullptr), right(nullptr), leaf(leaf),466 ambiguousWhen(false), whenState(true), childOfAnd(false) {}467 ClauseNode( WhenClause * leaf ) : ClauseNode(LEAF, leaf) {}468 469 ~ClauseNode() {470 if ( left ) delete left;471 if ( right ) delete right;472 }473 };446 // Non-ast node used during compilation to store data needed to generate predicates 447 // and set initial status values for clauses 448 // Used to create a tree corresponding to the structure of the clauses in a WaitUntil 449 struct ClauseNode { 450 enum Op { AND, OR, LEFT_OR, LEAF, ELSE, TIMEOUT } op; // operation/type tag 451 // LEFT_OR used with TIMEOUT/ELSE to indicate that we ignore right hand side after parsing 452 453 ClauseNode * left; 454 ClauseNode * right; 455 WhenClause * leaf; // only set if this node is a leaf (points into vector of clauses) 456 457 bool ambiguousWhen; // used to paint nodes of predicate tree based on when() clauses 458 bool whenState; // used to track if when_cond is toggled on or off for generating init values 459 bool childOfAnd; // true on leaf nodes that are children of AND, false otherwise 460 461 ClauseNode( Op op, ClauseNode * left, ClauseNode * right ) 462 : op(op), left(left), right(right), leaf(nullptr), 463 ambiguousWhen(false), whenState(true), childOfAnd(false) {} 464 ClauseNode( Op op, WhenClause * leaf ) 465 : op(op), left(nullptr), right(nullptr), leaf(leaf), 466 ambiguousWhen(false), whenState(true), childOfAnd(false) {} 467 ClauseNode( WhenClause * leaf ) : ClauseNode(LEAF, leaf) {} 468 469 ~ClauseNode() { 470 if ( left ) delete left; 471 if ( right ) delete right; 472 } 473 }; 474 474 475 475 std::vector<ptr<WhenClause>> clauses; 476 ClauseNode * predicateTree;476 ClauseNode * predicateTree; 477 477 478 478 WaitUntilStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 479 479 : WaitStmt(loc, std::move(labels)) {} 480 480 481 ~WaitUntilStmt() { delete predicateTree; }481 ~WaitUntilStmt() { delete predicateTree; } 482 482 483 483 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } … … 522 522 std::vector<ptr<Expr>> mutexObjs; 523 523 524 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 524 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 525 525 const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} ) 526 526 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}
Note:
See TracChangeset
for help on using the changeset viewer.