2727//! the format of the output away from extracting it from the compiler.
2828//! DumpCsvVisitor walks the AST and processes it.
2929
30- use super :: { escape, generated_code, recorder} ;
30+ use super :: { escape, generated_code, recorder, SaveContext } ;
3131
3232use session:: Session ;
3333
@@ -55,6 +55,7 @@ use util::ppaux;
5555
5656
5757pub struct DumpCsvVisitor < ' l , ' tcx : ' l > {
58+ save_ctxt : SaveContext < ' l > ,
5859 sess : & ' l Session ,
5960 analysis : & ' l ty:: CrateAnalysis < ' tcx > ,
6061
@@ -68,20 +69,12 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
6869}
6970
7071impl < ' l , ' tcx > DumpCsvVisitor < ' l , ' tcx > {
71- fn nest < F > ( & mut self , scope_id : NodeId , f : F ) where
72- F : FnOnce ( & mut DumpCsvVisitor < ' l , ' tcx > ) ,
73- {
74- let parent_scope = self . cur_scope ;
75- self . cur_scope = scope_id;
76- f ( self ) ;
77- self . cur_scope = parent_scope;
78- }
79-
8072 pub fn new ( sess : & ' l Session ,
8173 analysis : & ' l ty:: CrateAnalysis < ' tcx > ,
8274 output_file : Box < File > ) -> DumpCsvVisitor < ' l , ' tcx > {
8375 DumpCsvVisitor {
8476 sess : sess,
77+ save_ctxt : SaveContext { sess : sess } ,
8578 analysis : analysis,
8679 collected_paths : vec ! [ ] ,
8780 collecting : false ,
@@ -101,14 +94,23 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
10194 }
10295 }
10396
97+ fn nest < F > ( & mut self , scope_id : NodeId , f : F ) where
98+ F : FnOnce ( & mut DumpCsvVisitor < ' l , ' tcx > ) ,
99+ {
100+ let parent_scope = self . cur_scope ;
101+ self . cur_scope = scope_id;
102+ f ( self ) ;
103+ self . cur_scope = parent_scope;
104+ }
105+
104106 pub fn dump_crate_info ( & mut self , name : & str , krate : & ast:: Crate ) {
105- // the current crate
107+ // The current crate.
106108 self . fmt . crate_str ( krate. span , name) ;
107109
108- // dump info about all the external crates referenced from this crate
109- self . sess . cstore . iter_crate_data ( |n , cmd| {
110- self . fmt . external_crate_str ( krate. span , & cmd . name , n ) ;
111- } ) ;
110+ // Dump info about all the external crates referenced from this crate.
111+ for c in & self . save_ctxt . get_external_crates ( ) {
112+ self . fmt . external_crate_str ( krate. span , & c . name , c . number ) ;
113+ }
112114 self . fmt . recorder . record ( "end_external_crates\n " ) ;
113115 }
114116
0 commit comments