Changes in src/AST/Stmt.hpp [b8ab91a:6180274]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.hpp
rb8ab91a 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 : Fri May 17 12:45:00 201913 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:06:41 2022 13 // Update Count : 34 14 14 // 15 15 … … 17 17 18 18 #include <list> 19 #include <utility> 19 #include <utility> // for move 20 20 #include <vector> 21 21 22 22 #include "Label.hpp" 23 #include "Node.hpp" 23 #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 35 34 class Expr; 36 35 37 // /Base statement node36 // Base statement node 38 37 class Stmt : public ParseNode { 39 public:38 public: 40 39 std::vector<Label> labels; 41 40 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) {}41 Stmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 42 : ParseNode(loc), labels(std::move(labels)) {} 43 44 Stmt(const Stmt & o) : ParseNode(o), labels(o.labels) {} 46 45 47 46 const Stmt * accept( Visitor & v ) const override = 0; 48 private:47 private: 49 48 Stmt * clone() const override = 0; 50 49 MUTATE_FRIEND 51 50 }; 52 51 53 // / Compound statement `{ ... }`52 // Compound statement: { ... } 54 53 class CompoundStmt final : public Stmt { 55 public:54 public: 56 55 std::list<ptr<Stmt>> kids; 57 56 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; 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; 64 62 65 63 void push_back( const Stmt * s ) { kids.emplace_back( s ); } … … 67 65 68 66 const CompoundStmt * accept( Visitor & v ) const override { return v.visit( this ); } 69 private:67 private: 70 68 CompoundStmt * clone() const override { return new CompoundStmt{ *this }; } 71 69 MUTATE_FRIEND 72 70 }; 73 71 74 // / Empty statment `;`72 // Empty statment: ; 75 73 class NullStmt final : public Stmt { 76 public:77 NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )78 : Stmt(loc, std::move(labels)) {}74 public: 75 NullStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 76 : Stmt(loc, std::move(labels)) {} 79 77 80 78 const NullStmt * accept( Visitor & v ) const override { return v.visit( this ); } 81 private:79 private: 82 80 NullStmt * clone() const override { return new NullStmt{ *this }; } 83 81 MUTATE_FRIEND 84 82 }; 85 83 86 // /Expression wrapped by statement84 // Expression wrapped by statement 87 85 class ExprStmt final : public Stmt { 88 public:86 public: 89 87 ptr<Expr> expr; 90 88 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: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: 96 94 ExprStmt * clone() const override { return new ExprStmt{ *this }; } 97 95 MUTATE_FRIEND 98 96 }; 99 97 100 // / Assembly statement `asm ... ( "..." : ... )`98 // Assembly statement: asm ... ( "..." : ... ) 101 99 class AsmStmt final : public Stmt { 102 public:100 public: 103 101 bool isVolatile; 104 102 ptr<Expr> instruction; … … 108 106 109 107 AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction, 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: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 = {}) 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: 119 117 AsmStmt * clone() const override { return new AsmStmt{ *this }; } 120 118 MUTATE_FRIEND 121 119 }; 122 120 123 // / C-preprocessor directive `#...`121 // C-preprocessor directive: #... 124 122 class DirectiveStmt final : public Stmt { 125 public:123 public: 126 124 std::string directive; 127 125 128 126 DirectiveStmt( const CodeLocation & loc, const std::string & directive, 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: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: 134 132 DirectiveStmt * clone() const override { return new DirectiveStmt{ *this }; } 135 133 MUTATE_FRIEND 136 134 }; 137 135 138 // / If conditional statement `if (...) ... else ...`136 // If statement: if (...) ... else ... 139 137 class IfStmt final : public Stmt { 140 public:141 ptr<Expr> cond; 142 ptr<Stmt> then Part;143 ptr<Stmt> else Part;138 public: 139 ptr<Expr> cond; 140 ptr<Stmt> then; 141 ptr<Stmt> else_; 144 142 std::vector<ptr<Stmt>> inits; 145 143 146 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then Part,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:144 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then, 145 const Stmt * else_ = nullptr, const std::vector<ptr<Stmt>> && inits = {}, 146 const std::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: 154 152 IfStmt * clone() const override { return new IfStmt{ *this }; } 155 153 MUTATE_FRIEND 156 154 }; 157 155 158 // / Switch or choose conditional statement `switch (...) { ... }`156 // Switch or choose statement: switch (...) { ... } 159 157 class SwitchStmt final : public Stmt { 160 public:158 public: 161 159 ptr<Expr> cond; 162 160 std::vector<ptr<Stmt>> stmts; 163 161 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:162 SwitchStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts, 163 const std::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: 170 168 SwitchStmt * clone() const override { return new SwitchStmt{ *this }; } 171 169 MUTATE_FRIEND 172 170 }; 173 171 174 // / Case label `case ...:` `default:`172 // Case label: case ...: or default: 175 173 class CaseStmt final : public Stmt { 176 public:177 // /Null for the default label.174 public: 175 // Null for the default label. 178 176 ptr<Expr> cond; 179 177 std::vector<ptr<Stmt>> stmts; 180 178 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)) {}179 CaseStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts, 180 const std::vector<Label> && labels = {} ) 181 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 184 182 185 183 bool isDefault() const { return !cond; } 186 184 187 185 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 188 private:186 private: 189 187 CaseStmt * clone() const override { return new CaseStmt{ *this }; } 190 188 MUTATE_FRIEND 191 189 }; 192 190 193 // / While loop `while (...) ...` `do ... while (...);194 class While Stmt final : public Stmt {195 public:191 // While loop: while (...) ... else ... or do ... while (...) else ...; 192 class WhileDoStmt final : public Stmt { 193 public: 196 194 ptr<Expr> cond; 197 195 ptr<Stmt> body; 196 ptr<Stmt> else_; 198 197 std::vector<ptr<Stmt>> inits; 199 198 bool isDoWhile; 200 199 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 (... ; ... ; ...) ...` 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 ... 213 215 class ForStmt final : public Stmt { 214 public:216 public: 215 217 std::vector<ptr<Stmt>> inits; 216 218 ptr<Expr> cond; 217 219 ptr<Expr> inc; 218 220 ptr<Stmt> body; 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: 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: 227 233 ForStmt * clone() const override { return new ForStmt{ *this }; } 228 234 MUTATE_FRIEND 229 235 }; 230 236 231 // / Branch control flow statement `goto ...` `break` `continue` `fallthru`237 // Branch control flow statement: goto ... or break or continue or fallthru 232 238 class BranchStmt final : public Stmt { 233 public:239 public: 234 240 enum Kind { Goto, Break, Continue, FallThrough, FallThroughDefault }; 235 241 static constexpr size_t kindEnd = 1 + (size_t)FallThroughDefault; … … 240 246 Kind kind; 241 247 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) {} 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) {} 248 251 249 252 const char * kindName() const { return kindNames[kind]; } 250 253 251 254 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 252 private:255 private: 253 256 BranchStmt * clone() const override { return new BranchStmt{ *this }; } 254 257 MUTATE_FRIEND … … 257 260 }; 258 261 259 // / Return statement `return ...`262 // Return statement: return ... 260 263 class ReturnStmt final : public Stmt { 261 public:264 public: 262 265 ptr<Expr> expr; 263 266 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:267 ReturnStmt( const CodeLocation & loc, const Expr * expr, const std::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: 269 272 ReturnStmt * clone() const override { return new ReturnStmt{ *this }; } 270 273 MUTATE_FRIEND 271 274 }; 272 275 273 // /Kind of exception276 // Kind of exception 274 277 enum ExceptionKind { Terminate, Resume }; 275 278 276 // / Throw statement `throw ...`279 // Throw statement: throw ... 277 280 class ThrowStmt final : public Stmt { 278 public:281 public: 279 282 ptr<Expr> expr; 280 283 ptr<Expr> target; 281 284 ExceptionKind kind; 282 285 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: 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: 290 292 ThrowStmt * clone() const override { return new ThrowStmt{ *this }; } 291 293 MUTATE_FRIEND 292 294 }; 293 295 294 // / Try statement `try { ... } ...`296 // Try statement: try { ... } ... 295 297 class TryStmt final : public Stmt { 296 public:298 public: 297 299 ptr<CompoundStmt> body; 298 300 std::vector<ptr<CatchStmt>> handlers; 299 301 ptr<FinallyStmt> finally; 300 302 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: 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: 309 310 TryStmt * clone() const override { return new TryStmt{ *this }; } 310 311 MUTATE_FRIEND 311 312 }; 312 313 313 // /Catch clause of try statement314 // Catch clause of try statement 314 315 class CatchStmt final : public Stmt { 315 public:316 public: 316 317 ptr<Decl> decl; 317 318 ptr<Expr> cond; … … 319 320 ExceptionKind kind; 320 321 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: 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: 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, 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:353 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, const 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 // / Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...`362 // Waitfor 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, 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:391 WaitForStmt( const CodeLocation & loc, const 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, 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:405 DeclStmt( const CodeLocation & loc, const Decl * decl, const 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 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:436 const std::vector<ptr<Expr>> && mutexes, const 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 445 } 444 } // namespace ast 446 445 447 446 #undef MUTATE_FRIEND 448 447 449 448 // Local Variables: // 450 // tab-width: 4 //451 449 // mode: c++ // 452 // compile-command: "make install" //453 450 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.