while
This commit is contained in:
parent
16378e5d48
commit
5f560f079b
5 changed files with 30 additions and 5 deletions
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue