Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Stmt.hpp

    ra1da039 reb779d5  
    2828// Must be included in *all* AST classes; should be #undef'd at the end of the file
    2929#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); \
    3131        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    3232
     
    340340
    341341        CatchClause( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
    342                         const Stmt * body )
     342                           const Stmt * body )
    343343                : StmtClause(loc), decl(decl), cond(cond), body(body), kind(kind) {}
    344344
     
    380380// Base class of WaitFor/WaitUntil statements
    381381// form: KEYWORD(...) ... timeout(...) ... else ...
    382 class WaitStmt : public Stmt {
    383   public:
    384         ptr<Expr> timeout_time;
     382class WaitStmt : public Stmt { 
     383  public:
     384    ptr<Expr> timeout_time;
    385385        ptr<Stmt> timeout_stmt;
    386386        ptr<Expr> timeout_cond;
     
    388388        ptr<Expr> else_cond;
    389389
    390         WaitStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
     390    WaitStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    391391                : Stmt(loc, std::move(labels)) {}
    392392
    393393  private:
    394         WaitStmt * clone() const override = 0;
     394    WaitStmt * clone() const override = 0;
    395395        MUTATE_FRIEND
    396396};
     
    444444class WaitUntilStmt final : public WaitStmt {
    445445  public:
    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         };
     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    };
    474474
    475475        std::vector<ptr<WhenClause>> clauses;
    476         ClauseNode * predicateTree;
     476    ClauseNode * predicateTree;
    477477
    478478        WaitUntilStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    479479                : WaitStmt(loc, std::move(labels)) {}
    480480
    481         ~WaitUntilStmt() { delete predicateTree; }
     481    ~WaitUntilStmt() { delete predicateTree; }
    482482
    483483        const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
     
    522522        std::vector<ptr<Expr>> mutexObjs;
    523523
    524         MutexStmt( const CodeLocation & loc, const Stmt * stmt,
     524        MutexStmt( const CodeLocation & loc, const Stmt * stmt, 
    525525                           const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} )
    526526                : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}
Note: See TracChangeset for help on using the changeset viewer.