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> 19 std::optional<Statement> else_ = {},
Meta m =
Meta())
20 :
NodeBase(nodes(init, std::move(cond), std::move(body), std::move(else_)), std::move(m)) {
22 logger().internalError(
"initialization for 'while' must be a local declaration");
25 While(hilti::Expression cond, Statement body,
Meta m =
Meta())
28 While(hilti::Expression cond, Statement body, std::optional<Statement> else_,
Meta m =
Meta())
29 :
NodeBase(nodes(
node::none, std::move(cond), std::move(body), std::move(else_)), std::move(m)) {}
32 auto initRef()
const {
35 auto condition()
const {
return children()[1].tryAs<hilti::Expression>(); }
36 const auto& body()
const {
return child<hilti::Statement>(2); }
37 auto else_()
const {
return children()[3].tryAs<Statement>(); }
39 void setCondition(hilti::Expression c) {
children()[1] = std::move(c); }
40 void setInit(hilti::Expression c) {
children()[0] = std::move(c); }
42 bool operator==(
const While& other)
const {
43 return init() == other.init() && condition() == other.condition() && body() == other.body() &&
44 else_() == other.else_();
54 auto isEqual(
const Statement& other)
const {
return node::isEqual(
this, other); }
Definition: local-variable.h:19
Definition: declaration.h:53
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:470
auto isEqual(const Statement &other) const
Definition: while.h:54
auto & _bodyNode()
Definition: while.h:48
Definition: statement.h:14
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:99
Definition: node-ref.h:44
auto & _elseNode()
Definition: while.h:51
auto properties() const
Definition: while.h:57