[2bb4a01] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // Stmt.hpp -- |
---|
| 8 | // |
---|
| 9 | // Author : Aaron B. Moss |
---|
[1e97287] | 10 | // Created On : Wed May 8 13:00:00 2019 |
---|
| 11 | // Last Modified By : Andrew Beach |
---|
[675d816] | 12 | // Last Modified On : Fri May 17 12:45:00 2019 |
---|
| 13 | // Update Count : 5 |
---|
[2bb4a01] | 14 | // |
---|
| 15 | |
---|
| 16 | #pragma once |
---|
| 17 | |
---|
| 18 | #include <list> |
---|
| 19 | #include <utility> // for move |
---|
| 20 | #include <vector> |
---|
| 21 | |
---|
| 22 | #include "Label.hpp" |
---|
| 23 | #include "Node.hpp" // for node, ptr |
---|
| 24 | #include "ParseNode.hpp" |
---|
| 25 | #include "Visitor.hpp" |
---|
| 26 | #include "Common/CodeLocation.h" |
---|
| 27 | |
---|
[f3cc5b6] | 28 | // Must be included in *all* AST classes; should be #undef'd at the end of the file |
---|
[acd80b4] | 29 | #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node); |
---|
[f3cc5b6] | 30 | |
---|
[2bb4a01] | 31 | namespace ast { |
---|
| 32 | |
---|
| 33 | class Expr; |
---|
| 34 | |
---|
| 35 | /// Base statement node |
---|
| 36 | class Stmt : public ParseNode { |
---|
| 37 | public: |
---|
| 38 | std::vector<Label> labels; |
---|
| 39 | |
---|
[f3cc5b6] | 40 | Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) |
---|
[2bb4a01] | 41 | : ParseNode(loc), labels(std::move(labels)) {} |
---|
| 42 | |
---|
| 43 | Stmt(const Stmt& o) : ParseNode(o), labels(o.labels) {} |
---|
| 44 | |
---|
[f3cc5b6] | 45 | const Stmt * accept( Visitor & v ) const override = 0; |
---|
[2bb4a01] | 46 | private: |
---|
[f3cc5b6] | 47 | Stmt * clone() const override = 0; |
---|
| 48 | MUTATE_FRIEND |
---|
[2bb4a01] | 49 | }; |
---|
| 50 | |
---|
| 51 | /// Compound statement `{ ... }` |
---|
| 52 | class CompoundStmt final : public Stmt { |
---|
| 53 | public: |
---|
| 54 | std::list<ptr<Stmt>> kids; |
---|
| 55 | |
---|
[d66e7b7] | 56 | CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {}, |
---|
| 57 | std::vector<Label>&& labels = {} ) |
---|
| 58 | : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} |
---|
[2bb4a01] | 59 | |
---|
| 60 | CompoundStmt( const CompoundStmt& o ); |
---|
| 61 | CompoundStmt( CompoundStmt&& o ) = default; |
---|
| 62 | |
---|
[b8524ca] | 63 | void push_back( const Stmt * s ) { kids.emplace_back( s ); } |
---|
| 64 | void push_front( const Stmt * s ) { kids.emplace_front( s ); } |
---|
[2bb4a01] | 65 | |
---|
[f3cc5b6] | 66 | const CompoundStmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[2bb4a01] | 67 | private: |
---|
[f3cc5b6] | 68 | CompoundStmt * clone() const override { return new CompoundStmt{ *this }; } |
---|
| 69 | MUTATE_FRIEND |
---|
[2bb4a01] | 70 | }; |
---|
| 71 | |
---|
| 72 | /// Empty statment `;` |
---|
| 73 | class NullStmt final : public Stmt { |
---|
| 74 | public: |
---|
[f3cc5b6] | 75 | NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) |
---|
[2bb4a01] | 76 | : Stmt(loc, std::move(labels)) {} |
---|
| 77 | |
---|
[f3cc5b6] | 78 | const NullStmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[2bb4a01] | 79 | private: |
---|
[f3cc5b6] | 80 | NullStmt * clone() const override { return new NullStmt{ *this }; } |
---|
| 81 | MUTATE_FRIEND |
---|
[2bb4a01] | 82 | }; |
---|
| 83 | |
---|
| 84 | /// Expression wrapped by statement |
---|
| 85 | class ExprStmt final : public Stmt { |
---|
| 86 | public: |
---|
| 87 | ptr<Expr> expr; |
---|
| 88 | |
---|
[6f8e87d] | 89 | ExprStmt( const CodeLocation& loc, const Expr* e, std::vector<Label>&& labels = {} ) |
---|
| 90 | : Stmt(loc, std::move(labels)), expr(e) {} |
---|
[2bb4a01] | 91 | |
---|
[f3cc5b6] | 92 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[2bb4a01] | 93 | private: |
---|
[23f99e1] | 94 | ExprStmt * clone() const override { return new ExprStmt{ *this }; } |
---|
[f3cc5b6] | 95 | MUTATE_FRIEND |
---|
[2bb4a01] | 96 | }; |
---|
| 97 | |
---|
[0f740d6] | 98 | /// Assembly statement `asm ... ( "..." : ... )` |
---|
[1e97287] | 99 | class AsmStmt final : public Stmt { |
---|
| 100 | public: |
---|
| 101 | bool isVolatile; |
---|
| 102 | ptr<Expr> instruction; |
---|
| 103 | std::vector<ptr<Expr>> output, input; |
---|
| 104 | std::vector<ptr<ConstantExpr>> clobber; |
---|
| 105 | std::vector<Label> gotoLabels; |
---|
| 106 | |
---|
[f3cc5b6] | 107 | AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction, |
---|
| 108 | std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input, |
---|
| 109 | std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels, |
---|
| 110 | std::vector<Label> && labels = {}) |
---|
[1e97287] | 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 | |
---|
[f3cc5b6] | 115 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 116 | private: |
---|
[f3cc5b6] | 117 | AsmStmt * clone() const override { return new AsmStmt{ *this }; } |
---|
| 118 | MUTATE_FRIEND |
---|
[1e97287] | 119 | }; |
---|
| 120 | |
---|
[0f740d6] | 121 | /// C-preprocessor directive `#...` |
---|
[1e97287] | 122 | class DirectiveStmt final : public Stmt { |
---|
| 123 | public: |
---|
| 124 | std::string directive; |
---|
| 125 | |
---|
[f3cc5b6] | 126 | DirectiveStmt( const CodeLocation & loc, const std::string & directive, |
---|
| 127 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 128 | : Stmt(loc, std::move(labels)), directive(directive) {} |
---|
| 129 | |
---|
[f3cc5b6] | 130 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 131 | private: |
---|
[f3cc5b6] | 132 | DirectiveStmt * clone() const override { return new DirectiveStmt{ *this }; } |
---|
| 133 | MUTATE_FRIEND |
---|
[1e97287] | 134 | }; |
---|
| 135 | |
---|
[0f740d6] | 136 | /// If conditional statement `if (...) ... else ...` |
---|
[1e97287] | 137 | class IfStmt final : public Stmt { |
---|
| 138 | public: |
---|
| 139 | ptr<Expr> cond; |
---|
| 140 | ptr<Stmt> thenPart; |
---|
| 141 | ptr<Stmt> elsePart; |
---|
| 142 | std::vector<ptr<Stmt>> inits; |
---|
| 143 | |
---|
[f3cc5b6] | 144 | IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * thenPart, |
---|
[c1ed2ee] | 145 | const Stmt * elsePart = nullptr, std::vector<ptr<Stmt>> && inits = {}, |
---|
[f3cc5b6] | 146 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 147 | : Stmt(loc, std::move(labels)), cond(cond), thenPart(thenPart), elsePart(elsePart), |
---|
| 148 | inits(std::move(inits)) {} |
---|
| 149 | |
---|
[f3cc5b6] | 150 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 151 | private: |
---|
[f3cc5b6] | 152 | IfStmt * clone() const override { return new IfStmt{ *this }; } |
---|
| 153 | MUTATE_FRIEND |
---|
[1e97287] | 154 | }; |
---|
| 155 | |
---|
[0f740d6] | 156 | /// Switch or choose conditional statement `switch (...) { ... }` |
---|
[1e97287] | 157 | class SwitchStmt final : public Stmt { |
---|
| 158 | public: |
---|
| 159 | ptr<Expr> cond; |
---|
| 160 | std::vector<ptr<Stmt>> stmts; |
---|
| 161 | |
---|
[f3cc5b6] | 162 | SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts, |
---|
| 163 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 164 | : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} |
---|
| 165 | |
---|
[f3cc5b6] | 166 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 167 | private: |
---|
[f3cc5b6] | 168 | SwitchStmt * clone() const override { return new SwitchStmt{ *this }; } |
---|
| 169 | MUTATE_FRIEND |
---|
[1e97287] | 170 | }; |
---|
| 171 | |
---|
[0f740d6] | 172 | /// Case label `case ...:` `default:` |
---|
[1e97287] | 173 | class CaseStmt final : public Stmt { |
---|
| 174 | public: |
---|
| 175 | ptr<Expr> cond; |
---|
| 176 | std::vector<ptr<Stmt>> stmts; |
---|
| 177 | |
---|
[f3cc5b6] | 178 | CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts, |
---|
| 179 | std::vector<Label> && labels = {} ) |
---|
| 180 | : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} |
---|
[1e97287] | 181 | |
---|
[675d816] | 182 | bool isDefault() const { return !cond; } |
---|
[1e97287] | 183 | |
---|
[f3cc5b6] | 184 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 185 | private: |
---|
[f3cc5b6] | 186 | CaseStmt * clone() const override { return new CaseStmt{ *this }; } |
---|
| 187 | MUTATE_FRIEND |
---|
[1e97287] | 188 | }; |
---|
| 189 | |
---|
[0f740d6] | 190 | /// While loop `while (...) ...` `do ... while (...); |
---|
[1e97287] | 191 | class WhileStmt final : public Stmt { |
---|
| 192 | public: |
---|
| 193 | ptr<Expr> cond; |
---|
| 194 | ptr<Stmt> body; |
---|
| 195 | std::vector<ptr<Stmt>> inits; |
---|
| 196 | bool isDoWhile; |
---|
| 197 | |
---|
[f3cc5b6] | 198 | WhileStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, |
---|
| 199 | std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 200 | : Stmt(loc, std::move(labels)), cond(cond), body(body), inits(std::move(inits)), |
---|
| 201 | isDoWhile(isDoWhile) {} |
---|
| 202 | |
---|
[f3cc5b6] | 203 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 204 | private: |
---|
[f3cc5b6] | 205 | WhileStmt * clone() const override { return new WhileStmt{ *this }; } |
---|
| 206 | MUTATE_FRIEND |
---|
[1e97287] | 207 | }; |
---|
| 208 | |
---|
[0f740d6] | 209 | /// For loop `for (... ; ... ; ...) ...` |
---|
[1e97287] | 210 | class ForStmt final : public Stmt { |
---|
| 211 | public: |
---|
| 212 | std::vector<ptr<Stmt>> inits; |
---|
| 213 | ptr<Expr> cond; |
---|
[8a5530c] | 214 | ptr<Expr> inc; |
---|
[1e97287] | 215 | ptr<Stmt> body; |
---|
| 216 | |
---|
[f3cc5b6] | 217 | ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, |
---|
| 218 | const Expr * inc, const Stmt * body, std::vector<Label> && labels = {} ) |
---|
[8a5530c] | 219 | : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), |
---|
[1e97287] | 220 | body(body) {} |
---|
| 221 | |
---|
[f3cc5b6] | 222 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 223 | private: |
---|
[f3cc5b6] | 224 | ForStmt * clone() const override { return new ForStmt{ *this }; } |
---|
| 225 | MUTATE_FRIEND |
---|
[1e97287] | 226 | }; |
---|
| 227 | |
---|
[0f740d6] | 228 | /// Branch control flow statement `goto ...` `break` `continue` `fallthru` |
---|
[1e97287] | 229 | class BranchStmt final : public Stmt { |
---|
| 230 | public: |
---|
| 231 | enum Kind { Goto, Break, Continue, FallThrough, FallThroughDefault }; |
---|
| 232 | static constexpr size_t kindEnd = 1 + (size_t)FallThroughDefault; |
---|
| 233 | |
---|
| 234 | const Label originalTarget; |
---|
| 235 | Label target; |
---|
| 236 | ptr<Expr> computedTarget; |
---|
| 237 | Kind kind; |
---|
| 238 | |
---|
[f3cc5b6] | 239 | BranchStmt( const CodeLocation & loc, Kind kind, Label target, |
---|
| 240 | std::vector<Label> && labels = {} ); |
---|
| 241 | BranchStmt( const CodeLocation & loc, const Expr * computedTarget, |
---|
| 242 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 243 | : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), |
---|
| 244 | computedTarget(computedTarget), kind(Goto) {} |
---|
| 245 | |
---|
[94b1f718] | 246 | const char * kindName() const { return kindNames[kind]; } |
---|
[1e97287] | 247 | |
---|
[f3cc5b6] | 248 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 249 | private: |
---|
[f3cc5b6] | 250 | BranchStmt * clone() const override { return new BranchStmt{ *this }; } |
---|
| 251 | MUTATE_FRIEND |
---|
[8a5530c] | 252 | |
---|
[1e97287] | 253 | static const char * kindNames[kindEnd]; |
---|
| 254 | }; |
---|
| 255 | |
---|
[0f740d6] | 256 | /// Return statement `return ...` |
---|
[1e97287] | 257 | class ReturnStmt final : public Stmt { |
---|
| 258 | public: |
---|
| 259 | ptr<Expr> expr; |
---|
| 260 | |
---|
[f3cc5b6] | 261 | ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 262 | : Stmt(loc, std::move(labels)), expr(expr) {} |
---|
| 263 | |
---|
[f3cc5b6] | 264 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 265 | private: |
---|
[f3cc5b6] | 266 | ReturnStmt * clone() const override { return new ReturnStmt{ *this }; } |
---|
| 267 | MUTATE_FRIEND |
---|
[1e97287] | 268 | }; |
---|
| 269 | |
---|
[6f4b7f2] | 270 | /// Kind of exception |
---|
| 271 | enum ExceptionKind { Terminate, Resume }; |
---|
| 272 | |
---|
[0f740d6] | 273 | /// Throw statement `throw ...` |
---|
[1e97287] | 274 | class ThrowStmt final : public Stmt { |
---|
| 275 | public: |
---|
| 276 | ptr<Expr> expr; |
---|
| 277 | ptr<Expr> target; |
---|
[6f4b7f2] | 278 | ExceptionKind kind; |
---|
[1e97287] | 279 | |
---|
[a7d50b6] | 280 | ThrowStmt( |
---|
[6f4b7f2] | 281 | const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target, |
---|
[f3cc5b6] | 282 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 283 | : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} |
---|
| 284 | |
---|
[f3cc5b6] | 285 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 286 | private: |
---|
[f3cc5b6] | 287 | ThrowStmt * clone() const override { return new ThrowStmt{ *this }; } |
---|
| 288 | MUTATE_FRIEND |
---|
[1e97287] | 289 | }; |
---|
| 290 | |
---|
[0f740d6] | 291 | /// Try statement `try { ... } ...` |
---|
[1e97287] | 292 | class TryStmt final : public Stmt { |
---|
| 293 | public: |
---|
| 294 | ptr<CompoundStmt> body; |
---|
| 295 | std::vector<ptr<CatchStmt>> handlers; |
---|
| 296 | ptr<FinallyStmt> finally; |
---|
| 297 | |
---|
[a7d50b6] | 298 | TryStmt( |
---|
[6f4b7f2] | 299 | const CodeLocation & loc, const CompoundStmt * body, |
---|
[f3cc5b6] | 300 | std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, |
---|
| 301 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 302 | : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} |
---|
| 303 | |
---|
[f3cc5b6] | 304 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 305 | private: |
---|
[f3cc5b6] | 306 | TryStmt * clone() const override { return new TryStmt{ *this }; } |
---|
| 307 | MUTATE_FRIEND |
---|
[1e97287] | 308 | }; |
---|
| 309 | |
---|
[0f740d6] | 310 | /// Catch clause of try statement |
---|
[1e97287] | 311 | class CatchStmt final : public Stmt { |
---|
| 312 | public: |
---|
| 313 | ptr<Decl> decl; |
---|
| 314 | ptr<Expr> cond; |
---|
| 315 | ptr<Stmt> body; |
---|
[6f4b7f2] | 316 | ExceptionKind kind; |
---|
[1e97287] | 317 | |
---|
[a7d50b6] | 318 | CatchStmt( |
---|
[6f4b7f2] | 319 | const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, |
---|
[f3cc5b6] | 320 | const Stmt * body, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 321 | : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} |
---|
| 322 | |
---|
[f3cc5b6] | 323 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 324 | private: |
---|
[f3cc5b6] | 325 | CatchStmt * clone() const override { return new CatchStmt{ *this }; } |
---|
| 326 | MUTATE_FRIEND |
---|
[1e97287] | 327 | }; |
---|
| 328 | |
---|
[0f740d6] | 329 | /// Finally clause of try statement |
---|
[1e97287] | 330 | class FinallyStmt final : public Stmt { |
---|
| 331 | public: |
---|
| 332 | ptr<CompoundStmt> body; |
---|
| 333 | |
---|
[f3cc5b6] | 334 | FinallyStmt( const CodeLocation & loc, const CompoundStmt * body, |
---|
| 335 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 336 | : Stmt(loc, std::move(labels)), body(body) {} |
---|
| 337 | |
---|
[f3cc5b6] | 338 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 339 | private: |
---|
[f3cc5b6] | 340 | FinallyStmt * clone() const override { return new FinallyStmt{ *this }; } |
---|
| 341 | MUTATE_FRIEND |
---|
[1e97287] | 342 | }; |
---|
[2bb4a01] | 343 | |
---|
[0f740d6] | 344 | /// Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...` |
---|
[1e97287] | 345 | class WaitForStmt final : public Stmt { |
---|
| 346 | public: |
---|
| 347 | struct Target { |
---|
[e0016a5] | 348 | ptr<Expr> func; |
---|
| 349 | std::vector<ptr<Expr>> args; |
---|
[1e97287] | 350 | }; |
---|
| 351 | |
---|
| 352 | struct Clause { |
---|
| 353 | Target target; |
---|
| 354 | ptr<Stmt> stmt; |
---|
| 355 | ptr<Expr> cond; |
---|
| 356 | }; |
---|
| 357 | |
---|
| 358 | struct Timeout { |
---|
| 359 | ptr<Expr> time; |
---|
| 360 | ptr<Stmt> stmt; |
---|
| 361 | ptr<Expr> cond; |
---|
| 362 | }; |
---|
| 363 | |
---|
| 364 | struct OrElse { |
---|
| 365 | ptr<Stmt> stmt; |
---|
| 366 | ptr<Expr> cond; |
---|
| 367 | }; |
---|
| 368 | |
---|
| 369 | std::vector<Clause> clauses; |
---|
| 370 | Timeout timeout; |
---|
| 371 | OrElse orElse; |
---|
| 372 | |
---|
[f3cc5b6] | 373 | WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 374 | : Stmt(loc, std::move(labels)) {} |
---|
| 375 | |
---|
[f3cc5b6] | 376 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 377 | private: |
---|
[f3cc5b6] | 378 | WaitForStmt * clone() const override { return new WaitForStmt{ *this }; } |
---|
| 379 | MUTATE_FRIEND |
---|
[1e97287] | 380 | }; |
---|
| 381 | |
---|
[0f740d6] | 382 | /// Any declaration in a (compound) statement. |
---|
[1e97287] | 383 | class DeclStmt final : public Stmt { |
---|
| 384 | public: |
---|
| 385 | ptr<Decl> decl; |
---|
| 386 | |
---|
[f3cc5b6] | 387 | DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 388 | : Stmt(loc, std::move(labels)), decl(decl) {} |
---|
| 389 | |
---|
[f3cc5b6] | 390 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 391 | private: |
---|
[f3cc5b6] | 392 | DeclStmt * clone() const override { return new DeclStmt{ *this }; } |
---|
| 393 | MUTATE_FRIEND |
---|
[1e97287] | 394 | }; |
---|
| 395 | |
---|
[0f740d6] | 396 | /// Represents an implicit application of a constructor or destructor. |
---|
[1e97287] | 397 | class ImplicitCtorDtorStmt final : public Stmt { |
---|
| 398 | public: |
---|
| 399 | readonly<Stmt> callStmt; |
---|
| 400 | |
---|
[f3cc5b6] | 401 | ImplicitCtorDtorStmt( const CodeLocation & loc, const Stmt * callStmt, |
---|
| 402 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 403 | : Stmt(loc, std::move(labels)), callStmt(callStmt) {} |
---|
| 404 | |
---|
[f3cc5b6] | 405 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 406 | private: |
---|
[f3cc5b6] | 407 | ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt{ *this }; } |
---|
| 408 | MUTATE_FRIEND |
---|
[1e97287] | 409 | }; |
---|
[2bb4a01] | 410 | |
---|
| 411 | } |
---|
| 412 | |
---|
[f3cc5b6] | 413 | #undef MUTATE_FRIEND |
---|
| 414 | |
---|
[2bb4a01] | 415 | // Local Variables: // |
---|
| 416 | // tab-width: 4 // |
---|
| 417 | // mode: c++ // |
---|
| 418 | // compile-command: "make install" // |
---|
[1e97287] | 419 | // End: // |
---|