Changeset 6180274 for src/AST


Ignore:
Timestamp:
Feb 2, 2022, 9:25:37 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
9dc0836
Parents:
4e7171f
Message:

more cleanup, make more function parameters const, remove more std::

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Stmt.cpp

    r4e7171f r6180274  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May  8 13:00:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 15 15:53:00 2019
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Feb  2 19:01:20 2022
     13// Update Count     : 3
    1414//
    1515
     
    5656
    5757// --- BranchStmt
    58 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, std::vector<Label>&& labels )
    59 : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {
     58BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, const std::vector<Label>&& labels )
     59                : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {
    6060        // Make sure a syntax error hasn't slipped through.
    6161        assert( Goto != kind || !target.empty() );
  • src/AST/Stmt.hpp

    r4e7171f r6180274  
    1010// Created On       : Wed May  8 13:00:00 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  1 17:44:46 2022
    13 // Update Count     : 24
     12// Last Modified On : Wed Feb  2 20:06:41 2022
     13// Update Count     : 34
    1414//
    1515
     
    3939        std::vector<Label> labels;
    4040
    41         Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     41        Stmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    4242                : ParseNode(loc), labels(std::move(labels)) {}
    4343
     
    5555        std::list<ptr<Stmt>> kids;
    5656
    57         CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {},
    58                                  std::vector<Label> && labels = {} )
     57        CompoundStmt(const CodeLocation & loc, const std::list<ptr<Stmt>> && ks = {}, const std::vector<Label> && labels = {} )
    5958                : Stmt(loc, std::move(labels)), kids(std::move(ks)) {}
    6059
     
    7473class NullStmt final : public Stmt {
    7574  public:
    76         NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     75        NullStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    7776                : Stmt(loc, std::move(labels)) {}
    7877
     
    8887        ptr<Expr> expr;
    8988
    90         ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} )
     89        ExprStmt( const CodeLocation & loc, const Expr* e, const std::vector<Label> && labels = {} )
    9190                : Stmt(loc, std::move(labels)), expr(e) {}
    9291
     
    107106
    108107        AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction,
    109                          std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input,
    110                          std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels,
    111                          std::vector<Label> && labels = {})
     108                         const std::vector<ptr<Expr>> && output, const std::vector<ptr<Expr>> && input,
     109                         const std::vector<ptr<ConstantExpr>> && clobber, const std::vector<Label> && gotoLabels,
     110                         const std::vector<Label> && labels = {})
    112111                : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction),
    113112                  output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)),
     
    144143
    145144        IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then,
    146                         const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {},
    147                         std::vector<Label> && labels = {} )
     145                        const Stmt * else_ = nullptr, const std::vector<ptr<Stmt>> && inits = {},
     146                        const std::vector<Label> && labels = {} )
    148147                : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_),
    149148                  inits(std::move(inits)) {}
     
    161160        std::vector<ptr<Stmt>> stmts;
    162161
    163         SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
    164                                 std::vector<Label> && labels = {} )
     162        SwitchStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts,
     163                                const std::vector<Label> && labels = {} )
    165164                : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    166165
     
    178177        std::vector<ptr<Stmt>> stmts;
    179178
    180         CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
    181                           std::vector<Label> && labels = {} )
     179        CaseStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts,
     180                          const std::vector<Label> && labels = {} )
    182181                : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    183182
     
    200199
    201200        WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,
    202                            std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
     201                                 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} )
    203202                : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {}
    204203
    205204        WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_,
    206                            std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
     205                                 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} )
    207206                : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {}
    208207
     
    222221        ptr<Stmt> else_;
    223222
    224         ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
    225                          const Expr * inc, const Stmt * body, std::vector<Label> && label = {} )
     223        ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond,
     224                         const Expr * inc, const Stmt * body, const std::vector<Label> && label = {} )
    226225                : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {}
    227226
    228         ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
    229                          const Expr * inc, const Stmt * body, const Stmt * else_, std::vector<Label> && labels = {} )
     227        ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond,
     228                         const Expr * inc, const Stmt * body, const Stmt * else_, const std::vector<Label> && labels = {} )
    230229                : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {}
    231230
     
    247246        Kind kind;
    248247
    249         BranchStmt( const CodeLocation & loc, Kind kind, Label target,
    250                                 std::vector<Label> && labels = {} );
    251         BranchStmt( const CodeLocation & loc, const Expr * computedTarget,
    252                                 std::vector<Label> && labels = {} )
    253                 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc),
    254                   computedTarget(computedTarget), kind(Goto) {}
     248        BranchStmt( const CodeLocation & loc, Kind kind, Label target, const std::vector<Label> && labels = {} );
     249        BranchStmt( const CodeLocation & loc, const Expr * computedTarget, const std::vector<Label> && labels = {} )
     250                : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), computedTarget(computedTarget), kind(Goto) {}
    255251
    256252        const char * kindName() const { return kindNames[kind]; }
     
    269265        ptr<Expr> expr;
    270266
    271         ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} )
     267        ReturnStmt( const CodeLocation & loc, const Expr * expr, const std::vector<Label> && labels = {} )
    272268                : Stmt(loc, std::move(labels)), expr(expr) {}
    273269
     
    288284        ExceptionKind kind;
    289285
    290         ThrowStmt(
    291                 const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target,
    292                 std::vector<Label> && labels = {} )
     286        ThrowStmt( const CodeLocation & loc, ExceptionKind kind, const Expr * expr,
     287                           const Expr * target, const std::vector<Label> && labels = {} )
    293288                : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {}
    294289
     
    306301        ptr<FinallyStmt> finally;
    307302
    308         TryStmt(
    309                 const CodeLocation & loc, const CompoundStmt * body,
    310                 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
    311                 std::vector<Label> && labels = {} )
     303        TryStmt( const CodeLocation & loc, const CompoundStmt * body,
     304                         const std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
     305                         const std::vector<Label> && labels = {} )
    312306                : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {}
    313307
     
    326320        ExceptionKind kind;
    327321
    328         CatchStmt(
    329                 const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
    330                 const Stmt * body, std::vector<Label> && labels = {} )
     322        CatchStmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
     323                           const Stmt * body, const std::vector<Label> && labels = {} )
    331324                : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {}
    332325
     
    358351        enum Type { None, Coroutine, Generator } type = None;
    359352
    360         SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} )
     353        SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, const std::vector<Label> && labels = {} )
    361354                : Stmt(loc, std::move(labels)), then(then), type(type) {}
    362355
     
    396389        OrElse orElse;
    397390
    398         WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     391        WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    399392                : Stmt(loc, std::move(labels)) {}
    400393
     
    410403        ptr<Decl> decl;
    411404
    412         DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} )
     405        DeclStmt( const CodeLocation & loc, const Decl * decl, const std::vector<Label> && labels = {} )
    413406                : Stmt(loc, std::move(labels)), decl(decl) {}
    414407
     
    441434
    442435        MutexStmt( const CodeLocation & loc, const Stmt * stmt,
    443                            std::vector<ptr<Expr>> && mutexes, std::vector<Label> && labels = {} )
     436                           const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} )
    444437                : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}
    445438
Note: See TracChangeset for help on using the changeset viewer.