Skip to content

Commit 2215d4f

Browse files
committed
Rename
1 parent 41ba9f9 commit 2215d4f

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

crates/swc_ecma_compiler/src/es2020/nullish_coalescing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ impl<'a> CompilerImpl<'a> {
1717
for mut stmt in stmts.take() {
1818
stmt.visit_mut_with(self);
1919

20-
if !self.nullish_coalescing_vars.is_empty() {
20+
if !self.es2020_nullish_coalescing_vars.is_empty() {
2121
buf.push(T::from(
2222
VarDecl {
2323
span: DUMMY_SP,
2424
kind: VarDeclKind::Var,
25-
decls: take(&mut self.nullish_coalescing_vars),
25+
decls: take(&mut self.es2020_nullish_coalescing_vars),
2626
declare: false,
2727
..Default::default()
2828
}
@@ -47,7 +47,7 @@ impl<'a> CompilerImpl<'a> {
4747
let (l, aliased) = alias_if_required(left, "ref");
4848

4949
if aliased {
50-
self.nullish_coalescing_vars.push(VarDeclarator {
50+
self.es2020_nullish_coalescing_vars.push(VarDeclarator {
5151
span: DUMMY_SP,
5252
name: l.clone().into(),
5353
init: None,
@@ -97,7 +97,7 @@ impl<'a> CompilerImpl<'a> {
9797

9898
AssignTarget::Simple(left) => {
9999
let alias = alias_ident_for_simple_assign_tatget(left, "refs");
100-
self.nullish_coalescing_vars.push(VarDeclarator {
100+
self.es2020_nullish_coalescing_vars.push(VarDeclarator {
101101
span: DUMMY_SP,
102102
name: alias.clone().into(),
103103
init: None,

crates/swc_ecma_compiler/src/es2021/logical_assignments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl<'a> CompilerImpl<'a> {
1111
c: ComputedPropName,
1212
) -> (ComputedPropName, ComputedPropName) {
1313
let alias = alias_ident_for(&c.expr, "_ref");
14-
self.logical_assignment_vars.push(VarDeclarator {
14+
self.es2021_logical_assignment_vars.push(VarDeclarator {
1515
span: DUMMY_SP,
1616
name: alias.clone().into(),
1717
init: None,
@@ -79,7 +79,7 @@ impl<'a> CompilerImpl<'a> {
7979
obj @ Expr::This(_) => (obj.clone().into(), obj.into()),
8080
obj => {
8181
let alias = alias_ident_for(&obj, "_ref");
82-
self.logical_assignment_vars.push(VarDeclarator {
82+
self.es2021_logical_assignment_vars.push(VarDeclarator {
8383
span: DUMMY_SP,
8484
name: alias.clone().into(),
8585
init: None,

crates/swc_ecma_compiler/src/lib.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ struct CompilerImpl<'a> {
5959
es2022_current_class_data: ClassData,
6060

6161
// Logical assignments transformation state
62-
logical_assignment_vars: Vec<VarDeclarator>,
62+
es2021_logical_assignment_vars: Vec<VarDeclarator>,
6363

6464
// ES2020: Nullish coalescing transformation state
65-
nullish_coalescing_vars: Vec<VarDeclarator>,
65+
es2020_nullish_coalescing_vars: Vec<VarDeclarator>,
6666
}
6767

6868
#[swc_trace]
@@ -74,8 +74,8 @@ impl<'a> CompilerImpl<'a> {
7474
es2022_private_field_init_exprs: Vec::new(),
7575
es2022_injected_weakset_vars: FxHashSet::default(),
7676
es2022_current_class_data: ClassData::default(),
77-
logical_assignment_vars: Vec::new(),
78-
nullish_coalescing_vars: Vec::new(),
77+
es2021_logical_assignment_vars: Vec::new(),
78+
es2020_nullish_coalescing_vars: Vec::new(),
7979
}
8080
}
8181

@@ -470,7 +470,7 @@ impl<'a> VisitMut for CompilerImpl<'a> {
470470
/// Prevents #1123 for nullish coalescing
471471
fn visit_mut_block_stmt(&mut self, s: &mut BlockStmt) {
472472
let old_vars = if self.config.includes.contains(Features::NULLISH_COALESCING) {
473-
self.nullish_coalescing_vars.take()
473+
self.es2020_nullish_coalescing_vars.take()
474474
} else {
475475
vec![]
476476
};
@@ -480,7 +480,7 @@ impl<'a> VisitMut for CompilerImpl<'a> {
480480

481481
// Restore vars only if feature is enabled
482482
if self.config.includes.contains(Features::NULLISH_COALESCING) {
483-
self.nullish_coalescing_vars = old_vars;
483+
self.es2020_nullish_coalescing_vars = old_vars;
484484
}
485485
}
486486

@@ -489,17 +489,17 @@ impl<'a> VisitMut for CompilerImpl<'a> {
489489
if self.config.includes.contains(Features::NULLISH_COALESCING) {
490490
// Prevents #6328 - test is visited separately
491491
s.test.visit_mut_with(self);
492-
let old_vars = self.nullish_coalescing_vars.take();
492+
let old_vars = self.es2020_nullish_coalescing_vars.take();
493493
s.cons.visit_mut_with(self);
494-
self.nullish_coalescing_vars = old_vars;
494+
self.es2020_nullish_coalescing_vars = old_vars;
495495
} else {
496496
s.visit_mut_children_with(self);
497497
}
498498
}
499499

500500
fn visit_mut_block_stmt_or_expr(&mut self, n: &mut BlockStmtOrExpr) {
501501
let saved_vars = if self.config.includes.contains(Features::NULLISH_COALESCING) {
502-
self.nullish_coalescing_vars.take()
502+
self.es2020_nullish_coalescing_vars.take()
503503
} else {
504504
vec![]
505505
};
@@ -509,13 +509,13 @@ impl<'a> VisitMut for CompilerImpl<'a> {
509509

510510
// Post-processing for nullish coalescing
511511
if self.config.includes.contains(Features::NULLISH_COALESCING) {
512-
if !self.nullish_coalescing_vars.is_empty() {
512+
if !self.es2020_nullish_coalescing_vars.is_empty() {
513513
if let BlockStmtOrExpr::Expr(expr) = n {
514514
let stmts = vec![
515515
VarDecl {
516516
span: DUMMY_SP,
517517
kind: VarDeclKind::Var,
518-
decls: self.nullish_coalescing_vars.take(),
518+
decls: self.es2020_nullish_coalescing_vars.take(),
519519
declare: false,
520520
..Default::default()
521521
}
@@ -532,7 +532,7 @@ impl<'a> VisitMut for CompilerImpl<'a> {
532532
});
533533
}
534534
}
535-
self.nullish_coalescing_vars = saved_vars;
535+
self.es2020_nullish_coalescing_vars = saved_vars;
536536
}
537537
}
538538

@@ -649,8 +649,8 @@ impl<'a> VisitMut for CompilerImpl<'a> {
649649

650650
let (saved_logical_vars, saved_nullish_vars) = if need_var_hoisting {
651651
(
652-
self.logical_assignment_vars.take(),
653-
self.nullish_coalescing_vars.take(),
652+
self.es2021_logical_assignment_vars.take(),
653+
self.es2020_nullish_coalescing_vars.take(),
654654
)
655655
} else {
656656
(vec![], vec![])
@@ -666,9 +666,9 @@ impl<'a> VisitMut for CompilerImpl<'a> {
666666
// Post-processing: Handle variable hoisting
667667
if need_var_hoisting {
668668
let logical_vars =
669-
std::mem::replace(&mut self.logical_assignment_vars, saved_logical_vars);
669+
std::mem::replace(&mut self.es2021_logical_assignment_vars, saved_logical_vars);
670670
let nullish_vars =
671-
std::mem::replace(&mut self.nullish_coalescing_vars, saved_nullish_vars);
671+
std::mem::replace(&mut self.es2020_nullish_coalescing_vars, saved_nullish_vars);
672672

673673
let mut all_vars = Vec::new();
674674
all_vars.extend(logical_vars);
@@ -719,8 +719,8 @@ impl<'a> VisitMut for CompilerImpl<'a> {
719719

720720
let (saved_logical_vars, saved_nullish_vars) = if need_var_hoisting {
721721
(
722-
self.logical_assignment_vars.take(),
723-
self.nullish_coalescing_vars.take(),
722+
self.es2021_logical_assignment_vars.take(),
723+
self.es2020_nullish_coalescing_vars.take(),
724724
)
725725
} else {
726726
(vec![], vec![])
@@ -736,9 +736,9 @@ impl<'a> VisitMut for CompilerImpl<'a> {
736736
// Post-processing: Handle variable hoisting
737737
if need_var_hoisting {
738738
let logical_vars =
739-
std::mem::replace(&mut self.logical_assignment_vars, saved_logical_vars);
739+
std::mem::replace(&mut self.es2021_logical_assignment_vars, saved_logical_vars);
740740
let nullish_vars =
741-
std::mem::replace(&mut self.nullish_coalescing_vars, saved_nullish_vars);
741+
std::mem::replace(&mut self.es2020_nullish_coalescing_vars, saved_nullish_vars);
742742

743743
let mut all_vars = Vec::new();
744744
all_vars.extend(logical_vars);

0 commit comments

Comments
 (0)