Spicy
break.h
1 // Copyright (c) 2020-now by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 
7 #include <hilti/ast/statement.h>
8 
9 namespace hilti::statement {
10 
12 class Break : public Statement {
13 public:
18  Statement* linkedLoop() const { return _loop; }
19 
27  void setLinkedLoop(Statement* loop) { _loop = loop; }
28 
29  node::Properties properties() const final {
30  node::Properties properties;
31 
32  if ( _loop )
33  properties = {{"loop", util::fmt("%p", _loop->identity())}};
34 
35  return std::move(properties) + Statement::properties();
36  }
37 
38  static auto create(ASTContext* ctx, Meta meta = {}) { return ctx->make<Break>(ctx, {}, std::move(meta)); }
39 
40 protected:
41  Break(ASTContext* ctx, Nodes children, Meta meta)
42  : Statement(ctx, NodeTags, std::move(children), std::move(meta)) {}
43 
44  HILTI_NODE_1(statement::Break, Statement, final);
45 
46 private:
47  Statement* _loop = nullptr;
48 };
49 
50 } // namespace hilti::statement
Definition: ast-context.h:128
T * make(Args &&... args)
Definition: ast-context.h:382
Definition: meta.h:30
const auto & children() const
Definition: node.h:382
uint64_t identity() const
Definition: node.h:379
const auto & meta() const
Definition: node.h:324
virtual node::Properties properties() const
Definition: node.h:953
Definition: statement.h:15
Definition: break.h:12
Statement * linkedLoop() const
Definition: break.h:18
node::Properties properties() const final
Definition: break.h:29
void setLinkedLoop(Statement *loop)
Definition: break.h:27