Spicy
logical-not.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 #include <hilti/ast/types/bool.h>
11 
12 namespace hilti::expression {
13 
15 class LogicalNot : public Expression {
16 public:
17  auto expression() const { return child<Expression>(0); }
18 
19  QualifiedType* type() const final { return child<QualifiedType>(1); }
20 
21  void setExpression(ASTContext* ctx, Expression* e) { setChild(ctx, 0, e); }
22 
23  static auto create(ASTContext* ctx, Expression* expression, const Meta& meta = {}) {
24  return ctx->make<LogicalNot>(ctx,
25  {expression,
26  QualifiedType::create(ctx, type::Bool::create(ctx, meta), Constness::Const)},
27  meta);
28  }
29 
30 protected:
31  LogicalNot(ASTContext* ctx, Nodes children, Meta meta)
32  : Expression(ctx, NodeTags, std::move(children), std::move(meta)) {}
33 
34  HILTI_NODE_1(expression::LogicalNot, Expression, final);
35 };
36 
37 } // 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
void setChild(ASTContext *ctx, size_t idx, Node *n)
Definition: node.h:602
const auto & children() const
Definition: node.h:364
const auto & meta() const
Definition: node.h:306
Definition: type.h:362
static auto create(ASTContext *ctx, UnqualifiedType *t, Constness const_, Meta m=Meta())
Definition: type.h:427
Definition: logical-not.h:15
QualifiedType * type() const final
Definition: logical-not.h:19