LibJS: Box StatementKind::While variant
This commit is contained in:
parent
3496379d09
commit
f29b7ab579
5 changed files with 22 additions and 18 deletions
|
|
@ -162,9 +162,9 @@ impl FunctionTable {
|
|||
self.collect_from_statement(alt, result);
|
||||
}
|
||||
}
|
||||
StatementKind::While { test, body } => {
|
||||
self.collect_from_expression(test, result);
|
||||
self.collect_from_statement(body, result);
|
||||
StatementKind::While(data) => {
|
||||
self.collect_from_expression(&data.test, result);
|
||||
self.collect_from_statement(&data.body, result);
|
||||
}
|
||||
StatementKind::DoWhile { test, body } => {
|
||||
self.collect_from_statement(body, result);
|
||||
|
|
@ -1459,6 +1459,12 @@ pub struct IfStatementData {
|
|||
pub alternate: Option<Box<Statement>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WhileStatementData {
|
||||
pub test: Box<Expression>,
|
||||
pub body: Box<Statement>,
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Statement enum
|
||||
// =============================================================================
|
||||
|
|
@ -1481,10 +1487,7 @@ pub enum StatementKind {
|
|||
|
||||
// Control flow
|
||||
If(Box<IfStatementData>),
|
||||
While {
|
||||
test: Box<Expression>,
|
||||
body: Box<Statement>,
|
||||
},
|
||||
While(Box<WhileStatementData>),
|
||||
DoWhile {
|
||||
test: Box<Expression>,
|
||||
body: Box<Statement>,
|
||||
|
|
|
|||
|
|
@ -406,10 +406,10 @@ fn dump_statement(statement: &Statement, state: &DumpState) {
|
|||
}
|
||||
}
|
||||
|
||||
StatementKind::While { test, body } => {
|
||||
StatementKind::While(data) => {
|
||||
dump_node!(state, "WhileStatement", &statement.range);
|
||||
dump_labeled_expression("test", test, false, state);
|
||||
dump_labeled_statement("body", body, true, state);
|
||||
dump_labeled_expression("test", &data.test, false, state);
|
||||
dump_labeled_statement("body", &data.body, true, state);
|
||||
}
|
||||
|
||||
StatementKind::DoWhile { test, body } => {
|
||||
|
|
|
|||
|
|
@ -953,8 +953,8 @@ pub fn generate_statement(
|
|||
),
|
||||
|
||||
// === While ===
|
||||
StatementKind::While { test, body } => {
|
||||
generate_while_statement(generator, test, body, preferred_dst)
|
||||
StatementKind::While(data) => {
|
||||
generate_while_statement(generator, &data.test, &data.body, preferred_dst)
|
||||
}
|
||||
|
||||
// === DoWhile ===
|
||||
|
|
@ -6688,7 +6688,7 @@ fn generate_labelled_statement(
|
|||
&effective_inner.inner,
|
||||
StatementKind::For { .. }
|
||||
| StatementKind::ForInOf { .. }
|
||||
| StatementKind::While { .. }
|
||||
| StatementKind::While(_)
|
||||
| StatementKind::DoWhile { .. }
|
||||
| StatementKind::Switch(_)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1954,9 +1954,10 @@ fn for_each_child_statement(
|
|||
f(&alt.inner);
|
||||
}
|
||||
}
|
||||
StatementKind::While { body, .. }
|
||||
| StatementKind::DoWhile { body, .. }
|
||||
| StatementKind::With { body, .. } => {
|
||||
StatementKind::While(data) => {
|
||||
f(&data.body.inner);
|
||||
}
|
||||
StatementKind::DoWhile { body, .. } | StatementKind::With { body, .. } => {
|
||||
f(&body.inner);
|
||||
}
|
||||
StatementKind::For { init, body, .. } => {
|
||||
|
|
|
|||
|
|
@ -344,10 +344,10 @@ impl Parser<'_> {
|
|||
|
||||
self.statement(
|
||||
start,
|
||||
StatementKind::While {
|
||||
StatementKind::While(Box::new(WhileStatementData {
|
||||
test: Box::new(test),
|
||||
body: Box::new(body),
|
||||
},
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue