Changes in / [dd7c2ce0:1da2affb]


Ignore:
Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    rdd7c2ce0 r1da2affb  
    125125
    126126/// Object declaration `int foo()`
    127 class FunctionDecl final : public DeclWithType {
     127class FunctionDecl : public DeclWithType {
    128128public:
    129129        std::vector<ptr<TypeDecl>> type_params;
     
    314314class EnumDecl final : public AggregateDecl {
    315315public:
    316         // isTyped indicated if the enum has a declaration like:
     316        bool isTyped; // isTyped indicated if the enum has a declaration like:
    317317        // enum (type_optional) Name {...}
    318         bool isTyped;
    319         // if isTyped == true && base.get() == nullptr, it is a "void" type enum
    320         ptr<Type> base;
     318        ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum
    321319        enum class EnumHiding { Visible, Hide } hide;
    322320
     
    376374
    377375/// Assembly declaration: `asm ... ( "..." : ... )`
    378 class AsmDecl final : public Decl {
     376class AsmDecl : public Decl {
    379377public:
    380378        ptr<AsmStmt> stmt;
    381379
    382380        AsmDecl( const CodeLocation & loc, AsmStmt * stmt )
    383         : Decl( loc, "", {}, Linkage::C ), stmt(stmt) {}
     381        : Decl( loc, "", {}, {} ), stmt(stmt) {}
    384382
    385383        const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); }
     
    390388
    391389/// C-preprocessor directive `#...`
    392 class DirectiveDecl final : public Decl {
     390class DirectiveDecl : public Decl {
    393391public:
    394392        ptr<DirectiveStmt> stmt;
    395393
    396394        DirectiveDecl( const CodeLocation & loc, DirectiveStmt * stmt )
    397         : Decl( loc, "", {}, Linkage::C ), stmt(stmt) {}
     395        : Decl( loc, "", {}, {} ), stmt(stmt) {}
    398396
    399397        const DirectiveDecl * accept( Visitor & v ) const override { return v.visit( this ); }
     
    404402
    405403/// Static Assertion `_Static_assert( ... , ... );`
    406 class StaticAssertDecl final : public Decl {
     404class StaticAssertDecl : public Decl {
    407405public:
    408406        ptr<Expr> cond;
     
    410408
    411409        StaticAssertDecl( const CodeLocation & loc, const Expr * condition, const ConstantExpr * msg )
    412         : Decl( loc, "", {}, Linkage::C ), cond( condition ), msg( msg ) {}
     410        : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {}
    413411
    414412        const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/Stmt.hpp

    rdd7c2ce0 r1da2affb  
    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.