[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 | |
---|
[f3cc5b6] | 63 | void push_back( Stmt * s ) { kids.emplace_back( s ); } |
---|
| 64 | void push_front( 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, |
---|
| 145 | Stmt * const elsePart, std::vector<ptr<Stmt>> && inits, |
---|
| 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 | |
---|
| 246 | const char * kindName() { return kindNames[kind]; } |
---|
| 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 | |
---|
[0f740d6] | 270 | /// Throw statement `throw ...` |
---|
[1e97287] | 271 | class ThrowStmt final : public Stmt { |
---|
| 272 | public: |
---|
| 273 | enum Kind { Terminate, Resume }; |
---|
| 274 | |
---|
| 275 | ptr<Expr> expr; |
---|
| 276 | ptr<Expr> target; |
---|
| 277 | Kind kind; |
---|
| 278 | |
---|
[f3cc5b6] | 279 | ThrowStmt( const CodeLocation & loc, Kind kind, const Expr * expr, const Expr * target, |
---|
| 280 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 281 | : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} |
---|
| 282 | |
---|
[f3cc5b6] | 283 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 284 | private: |
---|
[f3cc5b6] | 285 | ThrowStmt * clone() const override { return new ThrowStmt{ *this }; } |
---|
| 286 | MUTATE_FRIEND |
---|
[1e97287] | 287 | }; |
---|
| 288 | |
---|
[0f740d6] | 289 | /// Try statement `try { ... } ...` |
---|
[1e97287] | 290 | class TryStmt final : public Stmt { |
---|
| 291 | public: |
---|
| 292 | ptr<CompoundStmt> body; |
---|
| 293 | std::vector<ptr<CatchStmt>> handlers; |
---|
| 294 | ptr<FinallyStmt> finally; |
---|
| 295 | |
---|
[f3cc5b6] | 296 | TryStmt( const CodeLocation & loc, const CompoundStmt * body, |
---|
| 297 | std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, |
---|
| 298 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 299 | : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} |
---|
| 300 | |
---|
[f3cc5b6] | 301 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 302 | private: |
---|
[f3cc5b6] | 303 | TryStmt * clone() const override { return new TryStmt{ *this }; } |
---|
| 304 | MUTATE_FRIEND |
---|
[1e97287] | 305 | }; |
---|
| 306 | |
---|
[0f740d6] | 307 | /// Catch clause of try statement |
---|
[1e97287] | 308 | class CatchStmt final : public Stmt { |
---|
| 309 | public: |
---|
| 310 | enum Kind { Terminate, Resume }; |
---|
| 311 | |
---|
| 312 | ptr<Decl> decl; |
---|
| 313 | ptr<Expr> cond; |
---|
| 314 | ptr<Stmt> body; |
---|
| 315 | Kind kind; |
---|
| 316 | |
---|
[f3cc5b6] | 317 | CatchStmt( const CodeLocation & loc, Kind kind, const Decl * decl, const Expr * cond, |
---|
| 318 | const Stmt * body, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 319 | : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} |
---|
| 320 | |
---|
[f3cc5b6] | 321 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 322 | private: |
---|
[f3cc5b6] | 323 | CatchStmt * clone() const override { return new CatchStmt{ *this }; } |
---|
| 324 | MUTATE_FRIEND |
---|
[1e97287] | 325 | }; |
---|
| 326 | |
---|
[0f740d6] | 327 | /// Finally clause of try statement |
---|
[1e97287] | 328 | class FinallyStmt final : public Stmt { |
---|
| 329 | public: |
---|
| 330 | ptr<CompoundStmt> body; |
---|
| 331 | |
---|
[f3cc5b6] | 332 | FinallyStmt( const CodeLocation & loc, const CompoundStmt * body, |
---|
| 333 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 334 | : Stmt(loc, std::move(labels)), body(body) {} |
---|
| 335 | |
---|
[f3cc5b6] | 336 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 337 | private: |
---|
[f3cc5b6] | 338 | FinallyStmt * clone() const override { return new FinallyStmt{ *this }; } |
---|
| 339 | MUTATE_FRIEND |
---|
[1e97287] | 340 | }; |
---|
[2bb4a01] | 341 | |
---|
[0f740d6] | 342 | /// Wait for concurrency statement `when (...) waitfor (... , ...) ... timeout(...) ... else ...` |
---|
[1e97287] | 343 | class WaitForStmt final : public Stmt { |
---|
| 344 | public: |
---|
| 345 | struct Target { |
---|
[e0016a5] | 346 | ptr<Expr> func; |
---|
| 347 | std::vector<ptr<Expr>> args; |
---|
[1e97287] | 348 | }; |
---|
| 349 | |
---|
| 350 | struct Clause { |
---|
| 351 | Target target; |
---|
| 352 | ptr<Stmt> stmt; |
---|
| 353 | ptr<Expr> cond; |
---|
| 354 | }; |
---|
| 355 | |
---|
| 356 | struct Timeout { |
---|
| 357 | ptr<Expr> time; |
---|
| 358 | ptr<Stmt> stmt; |
---|
| 359 | ptr<Expr> cond; |
---|
| 360 | }; |
---|
| 361 | |
---|
| 362 | struct OrElse { |
---|
| 363 | ptr<Stmt> stmt; |
---|
| 364 | ptr<Expr> cond; |
---|
| 365 | }; |
---|
| 366 | |
---|
| 367 | std::vector<Clause> clauses; |
---|
| 368 | Timeout timeout; |
---|
| 369 | OrElse orElse; |
---|
| 370 | |
---|
[f3cc5b6] | 371 | WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 372 | : Stmt(loc, std::move(labels)) {} |
---|
| 373 | |
---|
[f3cc5b6] | 374 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 375 | private: |
---|
[f3cc5b6] | 376 | WaitForStmt * clone() const override { return new WaitForStmt{ *this }; } |
---|
| 377 | MUTATE_FRIEND |
---|
[1e97287] | 378 | }; |
---|
| 379 | |
---|
[0f740d6] | 380 | /// With statement `with (...) ...` |
---|
[1e97287] | 381 | class WithStmt final : public Stmt { |
---|
| 382 | public: |
---|
| 383 | std::vector<ptr<Expr>> exprs; |
---|
| 384 | ptr<Stmt> stmt; |
---|
| 385 | |
---|
[f3cc5b6] | 386 | WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt, |
---|
| 387 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 388 | : Stmt(loc, std::move(labels)), exprs(std::move(exprs)), stmt(stmt) {} |
---|
| 389 | |
---|
[f3cc5b6] | 390 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 391 | private: |
---|
[f3cc5b6] | 392 | WithStmt * clone() const override { return new WithStmt{ *this }; } |
---|
| 393 | MUTATE_FRIEND |
---|
[1e97287] | 394 | }; |
---|
| 395 | |
---|
[0f740d6] | 396 | /// Any declaration in a (compound) statement. |
---|
[1e97287] | 397 | class DeclStmt final : public Stmt { |
---|
| 398 | public: |
---|
| 399 | ptr<Decl> decl; |
---|
| 400 | |
---|
[f3cc5b6] | 401 | DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} ) |
---|
[1e97287] | 402 | : Stmt(loc, std::move(labels)), decl(decl) {} |
---|
| 403 | |
---|
[f3cc5b6] | 404 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 405 | private: |
---|
[f3cc5b6] | 406 | DeclStmt * clone() const override { return new DeclStmt{ *this }; } |
---|
| 407 | MUTATE_FRIEND |
---|
[1e97287] | 408 | }; |
---|
| 409 | |
---|
[0f740d6] | 410 | /// Represents an implicit application of a constructor or destructor. |
---|
[1e97287] | 411 | class ImplicitCtorDtorStmt final : public Stmt { |
---|
| 412 | public: |
---|
| 413 | readonly<Stmt> callStmt; |
---|
| 414 | |
---|
[f3cc5b6] | 415 | ImplicitCtorDtorStmt( const CodeLocation & loc, const Stmt * callStmt, |
---|
| 416 | std::vector<Label> && labels = {} ) |
---|
[1e97287] | 417 | : Stmt(loc, std::move(labels)), callStmt(callStmt) {} |
---|
| 418 | |
---|
[f3cc5b6] | 419 | const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } |
---|
[1e97287] | 420 | private: |
---|
[f3cc5b6] | 421 | ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt{ *this }; } |
---|
| 422 | MUTATE_FRIEND |
---|
[1e97287] | 423 | }; |
---|
[2bb4a01] | 424 | |
---|
| 425 | } |
---|
| 426 | |
---|
[f3cc5b6] | 427 | #undef MUTATE_FRIEND |
---|
| 428 | |
---|
[2bb4a01] | 429 | // Local Variables: // |
---|
| 430 | // tab-width: 4 // |
---|
| 431 | // mode: c++ // |
---|
| 432 | // compile-command: "make install" // |
---|
[1e97287] | 433 | // End: // |
---|