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/ctor.h>
9 
10 namespace hilti::ctor {
11 
13 class Coerced : public Ctor {
14 public:
15  auto originalCtor() const { return child<Ctor>(0); }
16  auto coercedCtor() const { return child<Ctor>(1); }
17 
18  QualifiedType* type() const final { return coercedCtor()->type(); }
19 
20  static auto create(ASTContext* ctx, Ctor* orig, Ctor* new_, Meta meta = {}) {
21  return ctx->make<Coerced>(ctx, {orig, new_}, std::move(meta));
22  }
23 
24 protected:
25  Coerced(ASTContext* ctx, Nodes children, Meta meta) : Ctor(ctx, NodeTags, std::move(children), std::move(meta)) {}
26 
27  HILTI_NODE_1(ctor::Coerced, Ctor, final);
28 };
29 
30 } // namespace hilti::ctor
Definition: ast-context.h:121
T * make(Args &&... args)
Definition: ast-context.h:366
Definition: ctor.h:14
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:13
QualifiedType * type() const final
Definition: coerced.h:18