File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ use crate::{
2727 unknown:: UnknownValue ,
2828 } ,
2929} ;
30+
3031pub struct Factory < ' a > {
3132 pub allocator : & ' a Allocator ,
3233 instance_id_counter : Cell < usize > ,
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ pub mod conditional;
22pub mod exhaustive;
33mod factory;
44mod operations;
5+ mod post;
6+ mod pre;
57
68use std:: collections:: BTreeSet ;
79
@@ -81,37 +83,6 @@ impl<'a> Analyzer<'a> {
8183 }
8284 }
8385
84- pub fn finalize ( & mut self ) {
85- self . module_stack . push ( ModuleId :: new ( 0 ) ) ;
86-
87- self . consume_exports ( ModuleId :: new ( 0 ) ) ;
88-
89- let mut round = 0usize ;
90- loop {
91- round += 1 ;
92- if round > 1000 {
93- panic ! ( "Possible infinite loop in post analysis" ) ;
94- }
95-
96- let mut dirty = false ;
97- dirty |= self . call_exhaustive_callbacks ( ) ;
98- dirty |= self . post_analyze_handle_conditional ( ) ;
99- // dirty |= self.post_analyze_handle_loops();
100- dirty |= self . post_analyze_handle_folding ( ) ;
101- if !dirty {
102- break ;
103- }
104- }
105-
106- self . module_stack . pop ( ) ;
107-
108- #[ cfg( feature = "flame" ) ]
109- {
110- self . scoping . call . pop ( ) . unwrap ( ) . scope_guard . end ( ) ;
111- flamescope:: dump ( & mut std:: fs:: File :: create ( "flamescope.json" ) . unwrap ( ) ) . unwrap ( ) ;
112- }
113- }
114-
11586 pub fn throw_builtin_error ( & mut self , message : impl Into < String > ) {
11687 if self . exit_by_throw ( false ) == 0 {
11788 self . add_diagnostic ( message) ;
Original file line number Diff line number Diff line change 1+ use crate :: module:: ModuleId ;
2+
3+ use super :: Analyzer ;
4+
5+ impl Analyzer < ' _ > {
6+ pub fn post_analysis ( & mut self ) {
7+ self . module_stack . push ( ModuleId :: new ( 0 ) ) ;
8+
9+ self . consume_exports ( ModuleId :: new ( 0 ) ) ;
10+
11+ let mut round = 0usize ;
12+ loop {
13+ round += 1 ;
14+ if round > 1000 {
15+ panic ! ( "Possible infinite loop in post analysis" ) ;
16+ }
17+
18+ let mut dirty = false ;
19+ dirty |= self . call_exhaustive_callbacks ( ) ;
20+ dirty |= self . post_analyze_handle_conditional ( ) ;
21+ // dirty |= self.post_analyze_handle_loops();
22+ dirty |= self . post_analyze_handle_folding ( ) ;
23+ if !dirty {
24+ break ;
25+ }
26+ }
27+
28+ self . module_stack . pop ( ) ;
29+
30+ #[ cfg( feature = "flame" ) ]
31+ {
32+ self . scoping . call . pop ( ) . unwrap ( ) . scope_guard . end ( ) ;
33+ flamescope:: dump ( & mut std:: fs:: File :: create ( "flamescope.json" ) . unwrap ( ) ) . unwrap ( ) ;
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ use super :: Analyzer ;
2+
3+ impl Analyzer < ' _ > {
4+ pub fn pre_analysis ( & mut self ) {
5+
6+ }
7+ }
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ pub fn tree_shake<F: Vfs + 'static>(
5757 // Step 1: Analyze
5858 let mut analyzer = Analyzer :: new_in ( Box :: new ( vfs) , config, & allocator) ;
5959 analyzer. import_module ( entry) ;
60- analyzer. finalize ( ) ;
60+ analyzer. post_analysis ( ) ;
6161 let Analyzer {
6262 modules,
6363 diagnostics,
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ impl<'a> Scoping<'a> {
4545 node: CalleeNode :: Root ,
4646 instance_id: factory. alloc_instance_id( ) ,
4747 #[ cfg( feature = "flame" ) ]
48- debug_name: "<Module >" ,
48+ debug_name: "<Root >" ,
4949 } ,
5050 vec![ ] ,
5151 0 ,
You can’t perform that action at this time.
0 commit comments