Spicy
throw.h
1 // Copyright (c) 2020-now by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <memory>
6 #include <utility>
7 
8 #include <hilti/ast/expression.h>
9 #include <hilti/ast/statement.h>
10 
11 namespace hilti::statement {
12 
14 class Throw : public Statement {
15 public:
16  auto expression() const { return child<::hilti::Expression>(0); }
17 
18  static auto create(ASTContext* ctx, hilti::Expression* expr, Meta meta = {}) {
19  return ctx->make<Throw>(ctx, {expr}, std::move(meta));
20  }
21 
22  static auto create(ASTContext* ctx, Meta meta = {}) { return ctx->make<Throw>(ctx, {nullptr}, std::move(meta)); }
23 
24 protected:
26  : Statement(ctx, NodeTags, std::move(children), std::move(meta)) {}
27 
28  HILTI_NODE_1(statement::Throw, Statement, final);
29 };
30 
31 } // namespace hilti::statement
Definition: ast-context.h:121
T * make(Args &&... args)
Definition: ast-context.h:366
Definition: expression.h:15
Definition: meta.h:30
const auto & children() const
Definition: node.h:364
const auto & meta() const
Definition: node.h:306
Definition: forward.h:758
Definition: statement.h:15
Definition: throw.h:14