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> else_ = {},
Meta m =
Meta())
19 :
NodeBase(nodes(init, std::move(cond), std::move(body), std::move(else_)), std::move(m)) {
21 logger().internalError(
"initialization for 'while' must be a local declaration");
24 While(hilti::Expression cond, Statement body,
Meta m =
Meta())
27 While(hilti::Expression cond, Statement body, std::optional<Statement> else_,
Meta m =
Meta())
28 :
NodeBase(nodes(
node::none, std::move(cond), std::move(body), std::move(else_)), std::move(m)) {}
31 auto initRef()
const {
34 auto condition()
const {
return children()[1].tryAs<hilti::Expression>(); }
35 const auto& body()
const {
return child<hilti::Statement>(2); }
36 auto else_()
const {
return children()[3].tryAs<Statement>(); }
38 void setCondition(
const hilti::Expression& c) {
children()[1] = c; }
39 void setInit(
const hilti::Expression& c) {
children()[0] = c; }
41 bool operator==(
const While& other)
const {
42 return init() == other.init() && condition() == other.condition() && body() == other.body() &&
43 else_() == other.else_();
53 auto isEqual(
const Statement& other)
const {
return node::isEqual(
this, other); }
Definition: local-variable.h:18
Definition: declaration.h:54
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:472
auto isEqual(const Statement &other) const
Definition: while.h:53
auto & _bodyNode()
Definition: while.h:47
Definition: statement.h:14
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:98
Definition: node-ref.h:45
auto & _elseNode()
Definition: while.h:50
auto properties() const
Definition: while.h:56