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(nodes(std::move(op0), std::move(op1), type::Bool(m)), m) {}
18 
19  const auto& op0() const { return child<Expression>(0); }
20  const auto& op1() const { return child<Expression>(1); }
21 
22  void setOp0(const Expression& op) { childs()[0] = std::move(op); }
23  void setOp1(const Expression& op) { childs()[1] = std::move(op); }
24 
25  bool operator==(const LogicalOr& other) const { return op0() == other.op0() && op1() == other.op1(); }
26 
28  bool isLhs() const { return false; }
30  bool isTemporary() const { return true; }
32  const auto& type() const { return child<Type>(2); }
34  auto isConstant() const { return op0().isConstant() && op1().isConstant(); }
36  auto isEqual(const Expression& other) const { return node::isEqual(this, other); }
37 
39  auto properties() const { return node::Properties{}; }
40 };
41 
42 } // namespace expression
43 } // namespace hilti
bool isTemporary() const
Definition: logical-or.h:30
bool isLhs() const
Definition: logical-or.h:28
Definition: expression.h:17
Definition: meta.h:18
const auto & type() const
Definition: logical-or.h:32
auto isConstant() const
Definition: logical-or.h:34
Definition: logical-or.h:14
auto properties() const
Definition: logical-or.h:39
auto isEqual(const Expression &other) const
Definition: logical-or.h:36
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:99
Definition: bool.h:13
const auto & childs() const
Definition: node.h:470
Definition: node.h:358