7 #include <hilti/ast/declarations/local-variable.h> 8 #include <hilti/ast/expression.h> 9 #include <hilti/ast/statement.h> 10 #include <hilti/base/logger.h> 18 If(
hilti::Declaration init, std::optional<hilti::Expression> cond, Statement true_, std::optional<Statement> false_,
20 :
NodeBase(nodes(init, std::move(cond), std::move(true_), std::move(false_)), std::move(m)) {
22 logger().internalError(
"initialization for 'if' must be a local declaration");
25 If(hilti::Expression cond, Statement true_, std::optional<Statement> false_,
Meta m =
Meta())
26 :
NodeBase(nodes(
node::none, std::move(cond), std::move(true_), std::move(false_)), std::move(m)) {}
29 auto initRef()
const {
32 auto condition()
const {
return children()[1].tryAs<hilti::Expression>(); }
33 const auto& true_()
const {
return child<hilti::Statement>(2); }
34 auto false_()
const {
return children()[3].tryAs<Statement>(); }
36 void setCondition(hilti::Expression e) {
children()[1] = std::move(e); }
39 bool operator==(
const If& other)
const {
40 return init() == other.init() && condition() == other.condition() && true_() == other.true_() &&
41 false_() == other.false_();
51 auto isEqual(
const Statement& other)
const {
return node::isEqual(
this, other); }
Definition: local-variable.h:19
Definition: declaration.h:53
auto properties() const
Definition: if.h:54
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:470
auto & _falseNode()
Definition: if.h:48
auto & _trueNode()
Definition: if.h:45
Definition: statement.h:14
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:99
auto isEqual(const Statement &other) const
Definition: if.h:51
Definition: node-ref.h:44