LibJS: Box ExpressionKind::Conditional variant
This commit is contained in:
parent
333ae7cc6d
commit
07e187ae6d
4 changed files with 25 additions and 28 deletions
|
|
@ -307,14 +307,10 @@ impl FunctionTable {
|
|||
}
|
||||
self.collect_from_expression(&data.rhs, result);
|
||||
}
|
||||
ExpressionKind::Conditional {
|
||||
test,
|
||||
consequent,
|
||||
alternate,
|
||||
} => {
|
||||
self.collect_from_expression(test, result);
|
||||
self.collect_from_expression(consequent, result);
|
||||
self.collect_from_expression(alternate, result);
|
||||
ExpressionKind::Conditional(data) => {
|
||||
self.collect_from_expression(&data.test, result);
|
||||
self.collect_from_expression(&data.consequent, result);
|
||||
self.collect_from_expression(&data.alternate, result);
|
||||
}
|
||||
ExpressionKind::Sequence(exprs) => {
|
||||
for expr in exprs.iter() {
|
||||
|
|
@ -1351,6 +1347,13 @@ pub struct AssignmentExprData {
|
|||
pub rhs: Box<Expression>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ConditionalExprData {
|
||||
pub test: Box<Expression>,
|
||||
pub consequent: Box<Expression>,
|
||||
pub alternate: Box<Expression>,
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Expression enum
|
||||
// =============================================================================
|
||||
|
|
@ -1378,11 +1381,7 @@ pub enum ExpressionKind {
|
|||
},
|
||||
Update(Box<UpdateExprData>),
|
||||
Assignment(Box<AssignmentExprData>),
|
||||
Conditional {
|
||||
test: Box<Expression>,
|
||||
consequent: Box<Expression>,
|
||||
alternate: Box<Expression>,
|
||||
},
|
||||
Conditional(Box<ConditionalExprData>),
|
||||
Sequence(Box<Vec<Expression>>),
|
||||
|
||||
// Member access
|
||||
|
|
|
|||
|
|
@ -805,15 +805,11 @@ fn dump_expression(expression: &Expression, state: &DumpState) {
|
|||
dump_expression(&data.rhs, &child_state(state, true));
|
||||
}
|
||||
|
||||
ExpressionKind::Conditional {
|
||||
test,
|
||||
consequent,
|
||||
alternate,
|
||||
} => {
|
||||
ExpressionKind::Conditional(data) => {
|
||||
dump_node!(state, "ConditionalExpression", &expression.range);
|
||||
dump_labeled_expression("test", test, false, state);
|
||||
dump_labeled_expression("consequent", consequent, false, state);
|
||||
dump_labeled_expression("alternate", alternate, true, state);
|
||||
dump_labeled_expression("test", &data.test, false, state);
|
||||
dump_labeled_expression("consequent", &data.consequent, false, state);
|
||||
dump_labeled_expression("alternate", &data.alternate, true, state);
|
||||
}
|
||||
|
||||
ExpressionKind::Sequence(expressions) => {
|
||||
|
|
|
|||
|
|
@ -152,11 +152,13 @@ fn generate_expression_inner(
|
|||
}
|
||||
|
||||
// === Conditional (ternary) ===
|
||||
ExpressionKind::Conditional {
|
||||
test,
|
||||
consequent,
|
||||
alternate,
|
||||
} => generate_conditional(generator, test, consequent, alternate, preferred_dst),
|
||||
ExpressionKind::Conditional(data) => generate_conditional(
|
||||
generator,
|
||||
&data.test,
|
||||
&data.consequent,
|
||||
&data.alternate,
|
||||
preferred_dst,
|
||||
),
|
||||
|
||||
// === Sequence ===
|
||||
ExpressionKind::Sequence(expressions) => {
|
||||
|
|
|
|||
|
|
@ -941,11 +941,11 @@ impl Parser<'_> {
|
|||
(
|
||||
self.expression(
|
||||
start,
|
||||
ExpressionKind::Conditional {
|
||||
ExpressionKind::Conditional(Box::new(ConditionalExprData {
|
||||
test: Box::new(lhs),
|
||||
consequent: Box::new(consequent),
|
||||
alternate: Box::new(alternate),
|
||||
},
|
||||
})),
|
||||
),
|
||||
ForbiddenTokens::none(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue