Spicy
coerced.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/type.h>
10 
11 namespace hilti::expression {
12 
14 class Coerced : public Expression {
15 public:
16  auto expression() const { return child<Expression>(0); }
17 
18  QualifiedType* type() const final { return child<QualifiedType>(1); }
19 
20  static auto create(ASTContext* ctx, Expression* expr, QualifiedType* target, Meta meta = {}) {
21  return ctx->make<Coerced>(ctx, {expr, target}, std::move(meta));
22  }
23 
24 protected:
25  Coerced(ASTContext* ctx, Nodes children, Meta meta)
26  : Expression(ctx, NodeTags, std::move(children), std::move(meta)) {}
27 
28  HILTI_NODE_1(expression::Coerced, Expression, final);
29 };
30 
31 } // namespace hilti::expression
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: type.h:362
Definition: coerced.h:14
QualifiedType * type() const final
Definition: coerced.h:18