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