mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
LibJS: Add support for do..while statements
This commit is contained in:
parent
da0715aba9
commit
f8393b80e3
5 changed files with 74 additions and 0 deletions
|
@ -177,6 +177,20 @@ Value WhileStatement::execute(Interpreter& interpreter) const
|
|||
return last_value;
|
||||
}
|
||||
|
||||
Value DoWhileStatement::execute(Interpreter& interpreter) const
|
||||
{
|
||||
Value last_value = js_undefined();
|
||||
do {
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
last_value = interpreter.run(*m_body);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
} while (m_test->execute(interpreter).to_boolean());
|
||||
|
||||
return last_value;
|
||||
}
|
||||
|
||||
Value ForStatement::execute(Interpreter& interpreter) const
|
||||
{
|
||||
RefPtr<BlockStatement> wrapper;
|
||||
|
@ -568,6 +582,16 @@ void WhileStatement::dump(int indent) const
|
|||
body().dump(indent + 1);
|
||||
}
|
||||
|
||||
void DoWhileStatement::dump(int indent) const
|
||||
{
|
||||
ASTNode::dump(indent);
|
||||
|
||||
print_indent(indent);
|
||||
printf("DoWhile\n");
|
||||
test().dump(indent + 1);
|
||||
body().dump(indent + 1);
|
||||
}
|
||||
|
||||
void ForStatement::dump(int indent) const
|
||||
{
|
||||
ASTNode::dump(indent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue