This commit is contained in:
bronku 2025-11-30 11:21:19 +01:00
parent 16378e5d48
commit 5f560f079b
5 changed files with 30 additions and 5 deletions

View file

@ -190,4 +190,26 @@ struct Module : Node
}
return oss.str();
}
};
struct While : Stmt
{
ptr<Expr> condition;
std::vector<ptr<Stmt>> body;
While(ptr<Expr> cond, std::vector<ptr<Stmt>> b)
: condition(std::move(cond)), body(std::move(b)) {}
std::string dump(int indent = 0) const override
{
std::ostringstream oss;
oss << indent_str(indent) << "While\n";
oss << condition->dump(indent + 1);
for (const auto &stmt : body)
{
oss << "\n"
<< stmt->dump(indent + 1);
}
return oss.str();
}
};