Spicy
logical-or.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 
7 #include <hilti/ast/expression.h>
8 #include <hilti/ast/types/bool.h>
9 
10 namespace hilti {
11 namespace expression {
12 
14 class LogicalOr : public NodeBase, public trait::isExpression {
15 public:
16  LogicalOr(Expression op0, Expression op1, Meta m = Meta())
17  : NodeBase({std::move(op0), std::move(op1)}, std::move(m)) {}
18 
19  const auto& op0() const { return child<Expression>(0); }
20  const auto& op1() const { return child<Expression>(1); }
21 
22  bool operator==(const LogicalOr& other) const { return op0() == other.op0() && op1() == other.op1(); }
23 
25  bool isLhs() const { return false; }
27  bool isTemporary() const { return true; }
29  auto type() const { return type::Bool(); }
31  auto isConstant() const { return op0().isConstant() && op1().isConstant(); }
33  auto isEqual(const Expression& other) const { return node::isEqual(this, other); }
34 
36  auto properties() const { return node::Properties{}; }
37 
45  static Expression setOp0(const LogicalOr& e, const Expression& op) {
46  auto x = Expression(e)._clone().as<LogicalOr>();
47  x.childs()[0] = op;
48  return x;
49  }
50 
58  static Expression setOp1(const LogicalOr& e, const Expression& op) {
59  auto x = Expression(e)._clone().as<LogicalOr>();
60  x.childs()[1] = op;
61  return x;
62  }
63 };
64 
65 } // namespace expression
66 } // namespace hilti
auto type() const
Definition: logical-or.h:29
std::vector< T > childs(int begin, int end) const
Definition: node.h:373
bool isTemporary() const
Definition: logical-or.h:27
bool isLhs() const
Definition: logical-or.h:25
Definition: expression.h:16
Definition: meta.h:18
auto isConstant() const
Definition: logical-or.h:31
Definition: logical-or.h:14
auto properties() const
Definition: logical-or.h:36
auto isEqual(const Expression &other) const
Definition: logical-or.h:33
static Expression setOp0(const LogicalOr &e, const Expression &op)
Definition: logical-or.h:45
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: bool.h:13
static Expression setOp1(const LogicalOr &e, const Expression &op)
Definition: logical-or.h:58
Definition: node.h:318