Changes in src/AST/Stmt.hpp [6180274:b8ab91a]
- File:
-
- 1 edited
-
src/AST/Stmt.hpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.hpp
r6180274 rb8ab91a 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 20:06:41 202213 // Update Count : 3411 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri May 17 12:45:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 17 17 18 18 #include <list> 19 #include <utility> // for move19 #include <utility> // for move 20 20 #include <vector> 21 21 22 22 #include "Label.hpp" 23 #include "Node.hpp" // for node, ptr23 #include "Node.hpp" // for node, ptr 24 24 #include "ParseNode.hpp" 25 25 #include "Visitor.hpp" … … 27 27 28 28 // Must be included in *all* AST classes; should be #undef'd at the end of the file 29 #define MUTATE_FRIEND \29 #define MUTATE_FRIEND \ 30 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 33 33 namespace ast { 34 34 35 class Expr; 35 36 36 // Base statement node37 /// Base statement node 37 38 class Stmt : public ParseNode { 38 public:39 public: 39 40 std::vector<Label> labels; 40 41 41 Stmt( const CodeLocation & loc, conststd::vector<Label> && labels = {} )42 : ParseNode(loc), labels(std::move(labels)) {}43 44 Stmt(const Stmt & o) : ParseNode(o), labels(o.labels) {}42 Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) 43 : ParseNode(loc), labels(std::move(labels)) {} 44 45 Stmt(const Stmt& o) : ParseNode(o), labels(o.labels) {} 45 46 46 47 const Stmt * accept( Visitor & v ) const override = 0; 47 private:48 private: 48 49 Stmt * clone() const override = 0; 49 50 MUTATE_FRIEND 50 51 }; 51 52 52 // Compound statement: { ... }53 /// Compound statement `{ ... }` 53 54 class CompoundStmt final : public Stmt { 54 public:55 public: 55 56 std::list<ptr<Stmt>> kids; 56 57 57 CompoundStmt(const CodeLocation & loc, const std::list<ptr<Stmt>> && ks = {}, const std::vector<Label> && labels = {} ) 58 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 59 60 CompoundStmt( const CompoundStmt & o ); 61 CompoundStmt( CompoundStmt && o ) = default; 58 CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {}, 59 std::vector<Label>&& labels = {} ) 60 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 61 62 CompoundStmt( const CompoundStmt& o ); 63 CompoundStmt( CompoundStmt&& o ) = default; 62 64 63 65 void push_back( const Stmt * s ) { kids.emplace_back( s ); } … … 65 67 66 68 const CompoundStmt * accept( Visitor & v ) const override { return v.visit( this ); } 67 private:69 private: 68 70 CompoundStmt * clone() const override { return new CompoundStmt{ *this }; } 69 71 MUTATE_FRIEND 70 72 }; 71 73 72 // Empty statment: ;74 /// Empty statment `;` 73 75 class NullStmt final : public Stmt { 74 public:75 NullStmt( const CodeLocation & loc, conststd::vector<Label> && labels = {} )76 : Stmt(loc, std::move(labels)) {}76 public: 77 NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) 78 : Stmt(loc, std::move(labels)) {} 77 79 78 80 const NullStmt * accept( Visitor & v ) const override { return v.visit( this ); } 79 private:81 private: 80 82 NullStmt * clone() const override { return new NullStmt{ *this }; } 81 83 MUTATE_FRIEND 82 84 }; 83 85 84 // Expression wrapped by statement86 /// Expression wrapped by statement 85 87 class ExprStmt final : public Stmt { 86 public:88 public: 87 89 ptr<Expr> expr; 88 90 89 ExprStmt( const CodeLocation & loc, const Expr* e, const std::vector<Label>&& labels = {} )90 : Stmt(loc, std::move(labels)), expr(e) {}91 92 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 93 private:91 ExprStmt( const CodeLocation& loc, const Expr* e, std::vector<Label>&& labels = {} ) 92 : Stmt(loc, std::move(labels)), expr(e) {} 93 94 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 95 private: 94 96 ExprStmt * clone() const override { return new ExprStmt{ *this }; } 95 97 MUTATE_FRIEND 96 98 }; 97 99 98 // Assembly statement: asm ... ( "..." : ... )100 /// Assembly statement `asm ... ( "..." : ... )` 99 101 class AsmStmt final : public Stmt { 100 public:102 public: 101 103 bool isVolatile; 102 104 ptr<Expr> instruction; … … 106 108 107 109 AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction, 108 const std::vector<ptr<Expr>> && output, conststd::vector<ptr<Expr>> && input,109 const std::vector<ptr<ConstantExpr>> && clobber, conststd::vector<Label> && gotoLabels,110 conststd::vector<Label> && labels = {})111 : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction),112 output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)),113 gotoLabels(std::move(gotoLabels)) {}114 115 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 116 private:110 std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input, 111 std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels, 112 std::vector<Label> && labels = {}) 113 : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction), 114 output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)), 115 gotoLabels(std::move(gotoLabels)) {} 116 117 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 118 private: 117 119 AsmStmt * clone() const override { return new AsmStmt{ *this }; } 118 120 MUTATE_FRIEND 119 121 }; 120 122 121 // C-preprocessor directive: #...123 /// C-preprocessor directive `#...` 122 124 class DirectiveStmt final : public Stmt { 123 public:125 public: 124 126 std::string directive; 125 127 126 128 DirectiveStmt( const CodeLocation & loc, const std::string & directive, 127 std::vector<Label> && labels = {} )128 : Stmt(loc, std::move(labels)), directive(directive) {}129 130 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 131 private:129 std::vector<Label> && labels = {} ) 130 : Stmt(loc, std::move(labels)), directive(directive) {} 131 132 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 133 private: 132 134 DirectiveStmt * clone() const override { return new DirectiveStmt{ *this }; } 133 135 MUTATE_FRIEND 134 136 }; 135 137 136 // If statement: if (...) ... else ...138 /// If conditional statement `if (...) ... else ...` 137 139 class IfStmt final : public Stmt { 138 public:139 ptr<Expr> cond; 140 ptr<Stmt> then ;141 ptr<Stmt> else _;140 public: 141 ptr<Expr> cond; 142 ptr<Stmt> thenPart; 143 ptr<Stmt> elsePart; 142 144 std::vector<ptr<Stmt>> inits; 143 145 144 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then ,145 const Stmt * else_ = nullptr, conststd::vector<ptr<Stmt>> && inits = {},146 conststd::vector<Label> && labels = {} )147 : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_),148 inits(std::move(inits)) {}149 150 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 151 private:146 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * thenPart, 147 const Stmt * elsePart = nullptr, std::vector<ptr<Stmt>> && inits = {}, 148 std::vector<Label> && labels = {} ) 149 : Stmt(loc, std::move(labels)), cond(cond), thenPart(thenPart), elsePart(elsePart), 150 inits(std::move(inits)) {} 151 152 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 153 private: 152 154 IfStmt * clone() const override { return new IfStmt{ *this }; } 153 155 MUTATE_FRIEND 154 156 }; 155 157 156 // Switch or choose statement: switch (...) { ... }158 /// Switch or choose conditional statement `switch (...) { ... }` 157 159 class SwitchStmt final : public Stmt { 158 public:160 public: 159 161 ptr<Expr> cond; 160 162 std::vector<ptr<Stmt>> stmts; 161 163 162 SwitchStmt( const CodeLocation & loc, const Expr * cond, conststd::vector<ptr<Stmt>> && stmts,163 conststd::vector<Label> && labels = {} )164 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}165 166 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 167 private:164 SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts, 165 std::vector<Label> && labels = {} ) 166 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 167 168 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 169 private: 168 170 SwitchStmt * clone() const override { return new SwitchStmt{ *this }; } 169 171 MUTATE_FRIEND 170 172 }; 171 173 172 // Case label: case ...: or default:174 /// Case label `case ...:` `default:` 173 175 class CaseStmt final : public Stmt { 174 public:175 // Null for the default label.176 public: 177 /// Null for the default label. 176 178 ptr<Expr> cond; 177 179 std::vector<ptr<Stmt>> stmts; 178 180 179 CaseStmt( const CodeLocation & loc, const Expr * cond, conststd::vector<ptr<Stmt>> && stmts,180 conststd::vector<Label> && labels = {} )181 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}181 CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts, 182 std::vector<Label> && labels = {} ) 183 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 182 184 183 185 bool isDefault() const { return !cond; } 184 186 185 187 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 186 private:188 private: 187 189 CaseStmt * clone() const override { return new CaseStmt{ *this }; } 188 190 MUTATE_FRIEND 189 191 }; 190 192 191 // While loop: while (...) ... else ... or do ... while (...) else ...;192 class While DoStmt final : public Stmt {193 public:193 /// While loop `while (...) ...` `do ... while (...); 194 class WhileStmt final : public Stmt { 195 public: 194 196 ptr<Expr> cond; 195 197 ptr<Stmt> body; 196 ptr<Stmt> else_;197 198 std::vector<ptr<Stmt>> inits; 198 199 bool isDoWhile; 199 200 200 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, 201 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} ) 202 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {} 203 204 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_, 205 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} ) 206 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {} 207 208 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 209 private: 210 WhileDoStmt * clone() const override { return new WhileDoStmt{ *this }; } 211 MUTATE_FRIEND 212 }; 213 214 // For loop: for (... ; ... ; ...) ... else ... 201 WhileStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, 202 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} ) 203 : Stmt(loc, std::move(labels)), cond(cond), body(body), inits(std::move(inits)), 204 isDoWhile(isDoWhile) {} 205 206 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 207 private: 208 WhileStmt * clone() const override { return new WhileStmt{ *this }; } 209 MUTATE_FRIEND 210 }; 211 212 /// For loop `for (... ; ... ; ...) ...` 215 213 class ForStmt final : public Stmt { 216 public:214 public: 217 215 std::vector<ptr<Stmt>> inits; 218 216 ptr<Expr> cond; 219 217 ptr<Expr> inc; 220 218 ptr<Stmt> body; 221 ptr<Stmt> else_; 222 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 = {} ) 225 : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {} 226 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 = {} ) 229 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {} 230 231 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 232 private: 219 220 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, 221 const Expr * inc, const Stmt * body, std::vector<Label> && labels = {} ) 222 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), 223 body(body) {} 224 225 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 226 private: 233 227 ForStmt * clone() const override { return new ForStmt{ *this }; } 234 228 MUTATE_FRIEND 235 229 }; 236 230 237 // Branch control flow statement: goto ... or break or continue or fallthru231 /// Branch control flow statement `goto ...` `break` `continue` `fallthru` 238 232 class BranchStmt final : public Stmt { 239 public:233 public: 240 234 enum Kind { Goto, Break, Continue, FallThrough, FallThroughDefault }; 241 235 static constexpr size_t kindEnd = 1 + (size_t)FallThroughDefault; … … 246 240 Kind kind; 247 241 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) {} 242 BranchStmt( const CodeLocation & loc, Kind kind, Label target, 243 std::vector<Label> && labels = {} ); 244 BranchStmt( const CodeLocation & loc, const Expr * computedTarget, 245 std::vector<Label> && labels = {} ) 246 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), 247 computedTarget(computedTarget), kind(Goto) {} 251 248 252 249 const char * kindName() const { return kindNames[kind]; } 253 250 254 251 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 255 private:252 private: 256 253 BranchStmt * clone() const override { return new BranchStmt{ *this }; } 257 254 MUTATE_FRIEND … … 260 257 }; 261 258 262 // Return statement: return ...259 /// Return statement `return ...` 263 260 class ReturnStmt final : public Stmt { 264 public:261 public: 265 262 ptr<Expr> expr; 266 263 267 ReturnStmt( const CodeLocation & loc, const Expr * expr, conststd::vector<Label> && labels = {} )268 : Stmt(loc, std::move(labels)), expr(expr) {}269 270 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 271 private:264 ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} ) 265 : Stmt(loc, std::move(labels)), expr(expr) {} 266 267 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 268 private: 272 269 ReturnStmt * clone() const override { return new ReturnStmt{ *this }; } 273 270 MUTATE_FRIEND 274 271 }; 275 272 276 // Kind of exception273 /// Kind of exception 277 274 enum ExceptionKind { Terminate, Resume }; 278 275 279 // Throw statement: throw ...276 /// Throw statement `throw ...` 280 277 class ThrowStmt final : public Stmt { 281 public:278 public: 282 279 ptr<Expr> expr; 283 280 ptr<Expr> target; 284 281 ExceptionKind kind; 285 282 286 ThrowStmt( const CodeLocation & loc, ExceptionKind kind, const Expr * expr, 287 const Expr * target, const std::vector<Label> && labels = {} ) 288 : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} 289 290 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 291 private: 283 ThrowStmt( 284 const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target, 285 std::vector<Label> && labels = {} ) 286 : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} 287 288 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 289 private: 292 290 ThrowStmt * clone() const override { return new ThrowStmt{ *this }; } 293 291 MUTATE_FRIEND 294 292 }; 295 293 296 // Try statement: try { ... } ...294 /// Try statement `try { ... } ...` 297 295 class TryStmt final : public Stmt { 298 public:296 public: 299 297 ptr<CompoundStmt> body; 300 298 std::vector<ptr<CatchStmt>> handlers; 301 299 ptr<FinallyStmt> finally; 302 300 303 TryStmt( const CodeLocation & loc, const CompoundStmt * body, 304 const std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, 305 const std::vector<Label> && labels = {} ) 306 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} 307 308 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 309 private: 301 TryStmt( 302 const CodeLocation & loc, const CompoundStmt * body, 303 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, 304 std::vector<Label> && labels = {} ) 305 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} 306 307 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 308 private: 310 309 TryStmt * clone() const override { return new TryStmt{ *this }; } 311 310 MUTATE_FRIEND 312 311 }; 313 312 314 // Catch clause of try statement313 /// Catch clause of try statement 315 314 class CatchStmt final : public Stmt { 316 public:315 public: 317 316 ptr<Decl> decl; 318 317 ptr<Expr> cond; … … 320 319 ExceptionKind kind; 321 320 322 CatchStmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 323 const Stmt * body, const std::vector<Label> && labels = {} ) 324 : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} 325 326 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 327 private: 321 CatchStmt( 322 const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 323 const Stmt * body, std::vector<Label> && labels = {} ) 324 : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} 325 326 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 327 private: 328 328 CatchStmt * clone() const override { return new CatchStmt{ *this }; } 329 329 MUTATE_FRIEND 330 330 }; 331 331 332 // Finally clause of try statement332 /// Finally clause of try statement 333 333 class FinallyStmt final : public Stmt { 334 public:334 public: 335 335 ptr<CompoundStmt> body; 336 336 337 337 FinallyStmt( const CodeLocation & loc, const CompoundStmt * body, 338 std::vector<Label> && labels = {} )339 : Stmt(loc, std::move(labels)), body(body) {}340 341 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 342 private:338 std::vector<Label> && labels = {} ) 339 : Stmt(loc, std::move(labels)), body(body) {} 340 341 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 342 private: 343 343 FinallyStmt * clone() const override { return new FinallyStmt{ *this }; } 344 344 MUTATE_FRIEND 345 345 }; 346 346 347 // Suspend statement347 /// Suspend statement 348 348 class SuspendStmt final : public Stmt { 349 public:349 public: 350 350 ptr<CompoundStmt> then; 351 351 enum Type { None, Coroutine, Generator } type = None; 352 352 353 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, conststd::vector<Label> && labels = {} )354 : Stmt(loc, std::move(labels)), then(then), type(type) {}355 356 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 357 private:353 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} ) 354 : Stmt(loc, std::move(labels)), then(then), type(type) {} 355 356 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 357 private: 358 358 SuspendStmt * clone() const override { return new SuspendStmt{ *this }; } 359 359 MUTATE_FRIEND 360 360 }; 361 361 362 // Waitfor statement: when (...) waitfor (... , ...) ... timeout(...) ... else ...362 /// Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...` 363 363 class WaitForStmt final : public Stmt { 364 public:364 public: 365 365 struct Target { 366 366 ptr<Expr> func; … … 389 389 OrElse orElse; 390 390 391 WaitForStmt( const CodeLocation & loc, conststd::vector<Label> && labels = {} )392 : Stmt(loc, std::move(labels)) {}393 394 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 395 private:391 WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) 392 : Stmt(loc, std::move(labels)) {} 393 394 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 395 private: 396 396 WaitForStmt * clone() const override { return new WaitForStmt{ *this }; } 397 397 MUTATE_FRIEND 398 398 }; 399 399 400 // Any declaration in a (compound) statement.400 /// Any declaration in a (compound) statement. 401 401 class DeclStmt final : public Stmt { 402 public:402 public: 403 403 ptr<Decl> decl; 404 404 405 DeclStmt( const CodeLocation & loc, const Decl * decl, conststd::vector<Label> && labels = {} )406 : Stmt(loc, std::move(labels)), decl(decl) {}407 408 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 409 private:405 DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} ) 406 : Stmt(loc, std::move(labels)), decl(decl) {} 407 408 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 409 private: 410 410 DeclStmt * clone() const override { return new DeclStmt{ *this }; } 411 411 MUTATE_FRIEND 412 412 }; 413 413 414 // Represents an implicit application of a constructor or destructor.414 /// Represents an implicit application of a constructor or destructor. 415 415 class ImplicitCtorDtorStmt final : public Stmt { 416 public:416 public: 417 417 ptr<Stmt> callStmt; 418 418 419 419 ImplicitCtorDtorStmt( const CodeLocation & loc, const Stmt * callStmt, 420 std::vector<Label> && labels = {} )421 : Stmt(loc, std::move(labels)), callStmt(callStmt) {}422 423 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 424 private:420 std::vector<Label> && labels = {} ) 421 : Stmt(loc, std::move(labels)), callStmt(callStmt) {} 422 423 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 424 private: 425 425 ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt{ *this }; } 426 426 MUTATE_FRIEND 427 427 }; 428 428 429 // Mutex Statement429 /// Mutex Statement 430 430 class MutexStmt final : public Stmt { 431 public:431 public: 432 432 ptr<Stmt> stmt; 433 433 std::vector<ptr<Expr>> mutexObjs; 434 434 435 435 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 436 const std::vector<ptr<Expr>> && mutexes, conststd::vector<Label> && labels = {} )437 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}438 439 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 440 private:436 std::vector<ptr<Expr>> && mutexes, std::vector<Label> && labels = {} ) 437 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {} 438 439 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 440 private: 441 441 MutexStmt * clone() const override { return new MutexStmt{ *this }; } 442 442 MUTATE_FRIEND 443 443 }; 444 } // namespace ast 444 445 } 445 446 446 447 #undef MUTATE_FRIEND 447 448 448 449 // Local Variables: // 450 // tab-width: 4 // 449 451 // mode: c++ // 452 // compile-command: "make install" // 450 453 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.