LibJS: Box StatementKind::DoWhile variant

This commit is contained in:
Johan Dahlin 2026-03-22 19:38:51 +01:00 committed by Andreas Kling
parent f29b7ab579
commit 31ae13eec6
5 changed files with 16 additions and 16 deletions

View file

@ -166,9 +166,9 @@ impl FunctionTable {
self.collect_from_expression(&data.test, result);
self.collect_from_statement(&data.body, result);
}
StatementKind::DoWhile { test, body } => {
self.collect_from_statement(body, result);
self.collect_from_expression(test, result);
StatementKind::DoWhile(data) => {
self.collect_from_statement(&data.body, result);
self.collect_from_expression(&data.test, result);
}
StatementKind::For {
init,
@ -1488,10 +1488,7 @@ pub enum StatementKind {
// Control flow
If(Box<IfStatementData>),
While(Box<WhileStatementData>),
DoWhile {
test: Box<Expression>,
body: Box<Statement>,
},
DoWhile(Box<WhileStatementData>),
For {
init: Option<ForInit>,
test: Option<Box<Expression>>,

View file

@ -412,10 +412,10 @@ fn dump_statement(statement: &Statement, state: &DumpState) {
dump_labeled_statement("body", &data.body, true, state);
}
StatementKind::DoWhile { test, body } => {
StatementKind::DoWhile(data) => {
dump_node!(state, "DoWhileStatement", &statement.range);
dump_labeled_statement("body", body, false, state);
dump_labeled_expression("test", test, true, state);
dump_labeled_statement("body", &data.body, false, state);
dump_labeled_expression("test", &data.test, true, state);
}
StatementKind::For {

View file

@ -958,8 +958,8 @@ pub fn generate_statement(
}
// === DoWhile ===
StatementKind::DoWhile { test, body } => {
generate_do_while_statement(generator, test, body, preferred_dst)
StatementKind::DoWhile(data) => {
generate_do_while_statement(generator, &data.test, &data.body, preferred_dst)
}
// === For ===
@ -6689,7 +6689,7 @@ fn generate_labelled_statement(
StatementKind::For { .. }
| StatementKind::ForInOf { .. }
| StatementKind::While(_)
| StatementKind::DoWhile { .. }
| StatementKind::DoWhile(_)
| StatementKind::Switch(_)
);

View file

@ -1957,7 +1957,10 @@ fn for_each_child_statement(
StatementKind::While(data) => {
f(&data.body.inner);
}
StatementKind::DoWhile { body, .. } | StatementKind::With { body, .. } => {
StatementKind::DoWhile(data) => {
f(&data.body.inner);
}
StatementKind::With { body, .. } => {
f(&body.inner);
}
StatementKind::For { init, body, .. } => {

View file

@ -368,10 +368,10 @@ impl Parser<'_> {
self.statement(
start,
StatementKind::DoWhile {
StatementKind::DoWhile(Box::new(WhileStatementData {
test: Box::new(test),
body: Box::new(body),
},
})),
)
}