@@ -25,9 +25,12 @@ use oxc_allocator::Vec;
2525use oxc_ast:: ast:: * ;
2626use oxc_data_structures:: stack:: NonEmptyStack ;
2727use oxc_syntax:: { es_target:: ESTarget , scope:: ScopeId } ;
28- use oxc_traverse:: { ReusableTraverseCtx , Traverse , TraverseCtx , traverse_mut_with_ctx} ;
28+ use oxc_traverse:: { ReusableTraverseCtx , Traverse , traverse_mut_with_ctx} ;
2929
30- use crate :: { ctx:: Ctx , options:: CompressOptionsKeepNames } ;
30+ use crate :: {
31+ ctx:: { Ctx , MinifierState , TraverseCtx } ,
32+ options:: CompressOptionsKeepNames ,
33+ } ;
3134
3235pub use self :: normalize:: { Normalize , NormalizeOptions } ;
3336
@@ -64,11 +67,19 @@ impl<'a> PeepholeOptimizations {
6467 }
6568 }
6669
67- pub fn build ( & mut self , program : & mut Program < ' a > , ctx : & mut ReusableTraverseCtx < ' a > ) {
70+ pub fn build (
71+ & mut self ,
72+ program : & mut Program < ' a > ,
73+ ctx : & mut ReusableTraverseCtx < ' a , MinifierState < ' a > > ,
74+ ) {
6875 traverse_mut_with_ctx ( self , program, ctx) ;
6976 }
7077
71- pub fn run_in_loop ( & mut self , program : & mut Program < ' a > , ctx : & mut ReusableTraverseCtx < ' a > ) {
78+ pub fn run_in_loop (
79+ & mut self ,
80+ program : & mut Program < ' a > ,
81+ ctx : & mut ReusableTraverseCtx < ' a , MinifierState < ' a > > ,
82+ ) {
7283 loop {
7384 self . build ( program, ctx) ;
7485 if self . functions_changed . is_empty ( ) {
@@ -137,7 +148,7 @@ impl<'a> PeepholeOptimizations {
137148 }
138149}
139150
140- impl < ' a > Traverse < ' a > for PeepholeOptimizations {
151+ impl < ' a > Traverse < ' a , MinifierState < ' a > > for PeepholeOptimizations {
141152 fn enter_program ( & mut self , program : & mut Program < ' a > , _ctx : & mut TraverseCtx < ' a > ) {
142153 self . enter_program_or_function ( program. scope_id ( ) ) ;
143154 }
@@ -391,12 +402,16 @@ impl<'a> LatePeepholeOptimizations {
391402 Self { target }
392403 }
393404
394- pub fn build ( & mut self , program : & mut Program < ' a > , ctx : & mut ReusableTraverseCtx < ' a > ) {
405+ pub fn build (
406+ & mut self ,
407+ program : & mut Program < ' a > ,
408+ ctx : & mut ReusableTraverseCtx < ' a , MinifierState < ' a > > ,
409+ ) {
395410 traverse_mut_with_ctx ( self , program, ctx) ;
396411 }
397412}
398413
399- impl < ' a > Traverse < ' a > for LatePeepholeOptimizations {
414+ impl < ' a > Traverse < ' a , MinifierState < ' a > > for LatePeepholeOptimizations {
400415 fn exit_member_expression (
401416 & mut self ,
402417 expr : & mut MemberExpression < ' a > ,
@@ -440,12 +455,16 @@ impl<'a> DeadCodeElimination {
440455 }
441456 }
442457
443- pub fn build ( & mut self , program : & mut Program < ' a > , ctx : & mut ReusableTraverseCtx < ' a > ) {
458+ pub fn build (
459+ & mut self ,
460+ program : & mut Program < ' a > ,
461+ ctx : & mut ReusableTraverseCtx < ' a , MinifierState < ' a > > ,
462+ ) {
444463 traverse_mut_with_ctx ( self , program, ctx) ;
445464 }
446465}
447466
448- impl < ' a > Traverse < ' a > for DeadCodeElimination {
467+ impl < ' a > Traverse < ' a , MinifierState < ' a > > for DeadCodeElimination {
449468 fn exit_statement ( & mut self , stmt : & mut Statement < ' a > , ctx : & mut TraverseCtx < ' a > ) {
450469 let mut state = State :: default ( ) ;
451470 self . inner . remove_dead_code_exit_statement ( stmt, & mut state, Ctx ( ctx) ) ;
0 commit comments