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 std::optional<Statement> false_,
Meta m =
Meta())
19 :
NodeBase(nodes(init, std::move(cond), std::move(true_), std::move(false_)), std::move(m)) {
21 logger().internalError(
"initialization for 'if' must be a local declaration");
24 If(hilti::Expression cond, Statement true_, std::optional<Statement> false_,
Meta m =
Meta())
25 :
NodeBase(nodes(
node::none, std::move(cond), std::move(true_), std::move(false_)), std::move(m)) {}
28 auto initRef()
const {
31 auto condition()
const {
return children()[1].tryAs<hilti::Expression>(); }
32 const auto& true_()
const {
return child<hilti::Statement>(2); }
33 auto false_()
const {
return children()[3].tryAs<Statement>(); }
35 void setCondition(
const hilti::Expression& e) {
children()[1] = e; }
38 bool operator==(
const If& other)
const {
39 return init() == other.init() && condition() == other.condition() && true_() == other.true_() &&
40 false_() == other.false_();
50 auto isEqual(
const Statement& other)
const {
return node::isEqual(
this, other); }
Definition: local-variable.h:18
Definition: declaration.h:53
auto properties() const
Definition: if.h:53
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:471
auto & _falseNode()
Definition: if.h:47
auto & _trueNode()
Definition: if.h:44
Definition: statement.h:14
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:97
auto isEqual(const Statement &other) const
Definition: if.h:50
Definition: node-ref.h:45