- Timestamp:
- Feb 2, 2022, 9:25:37 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 9dc0836
- Parents:
- 4e7171f
- Location:
- src/AST
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.cpp
r4e7171f r6180274 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed May 15 15:53:00 201913 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 19:01:20 2022 13 // Update Count : 3 14 14 // 15 15 … … 56 56 57 57 // --- 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) {58 BranchStmt::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) { 60 60 // Make sure a syntax error hasn't slipped through. 61 61 assert( Goto != kind || !target.empty() ); -
src/AST/Stmt.hpp
r4e7171f r6180274 10 10 // Created On : Wed May 8 13:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 17:44:46202213 // Update Count : 2412 // Last Modified On : Wed Feb 2 20:06:41 2022 13 // Update Count : 34 14 14 // 15 15 … … 39 39 std::vector<Label> labels; 40 40 41 Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} )41 Stmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 42 42 : ParseNode(loc), labels(std::move(labels)) {} 43 43 … … 55 55 std::list<ptr<Stmt>> kids; 56 56 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 = {} ) 59 58 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 60 59 … … 74 73 class NullStmt final : public Stmt { 75 74 public: 76 NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )75 NullStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 77 76 : Stmt(loc, std::move(labels)) {} 78 77 … … 88 87 ptr<Expr> expr; 89 88 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 = {} ) 91 90 : Stmt(loc, std::move(labels)), expr(e) {} 92 91 … … 107 106 108 107 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 = {}) 112 111 : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction), 113 112 output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)), … … 144 143 145 144 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 = {} ) 148 147 : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_), 149 148 inits(std::move(inits)) {} … … 161 160 std::vector<ptr<Stmt>> stmts; 162 161 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 = {} ) 165 164 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 166 165 … … 178 177 std::vector<ptr<Stmt>> stmts; 179 178 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 = {} ) 182 181 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 183 182 … … 200 199 201 200 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 = {} ) 203 202 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {} 204 203 205 204 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 = {} ) 207 206 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {} 208 207 … … 222 221 ptr<Stmt> else_; 223 222 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 = {} ) 226 225 : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {} 227 226 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 = {} ) 230 229 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {} 231 230 … … 247 246 Kind kind; 248 247 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) {} 255 251 256 252 const char * kindName() const { return kindNames[kind]; } … … 269 265 ptr<Expr> expr; 270 266 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 = {} ) 272 268 : Stmt(loc, std::move(labels)), expr(expr) {} 273 269 … … 288 284 ExceptionKind kind; 289 285 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 = {} ) 293 288 : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} 294 289 … … 306 301 ptr<FinallyStmt> finally; 307 302 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 = {} ) 312 306 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} 313 307 … … 326 320 ExceptionKind kind; 327 321 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 = {} ) 331 324 : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} 332 325 … … 358 351 enum Type { None, Coroutine, Generator } type = None; 359 352 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 = {} ) 361 354 : Stmt(loc, std::move(labels)), then(then), type(type) {} 362 355 … … 396 389 OrElse orElse; 397 390 398 WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )391 WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 399 392 : Stmt(loc, std::move(labels)) {} 400 393 … … 410 403 ptr<Decl> decl; 411 404 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 = {} ) 413 406 : Stmt(loc, std::move(labels)), decl(decl) {} 414 407 … … 441 434 442 435 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 = {} ) 444 437 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {} 445 438
Note: See TracChangeset
for help on using the changeset viewer.