27
27
//! the format of the output away from extracting it from the compiler.
28
28
//! DumpCsvVisitor walks the AST and processes it.
29
29
30
- use super :: { escape, generated_code, recorder} ;
30
+ use super :: { escape, generated_code, recorder, SaveContext } ;
31
31
32
32
use session:: Session ;
33
33
@@ -55,6 +55,7 @@ use util::ppaux;
55
55
56
56
57
57
pub struct DumpCsvVisitor < ' l , ' tcx : ' l > {
58
+ save_ctxt : SaveContext < ' l > ,
58
59
sess : & ' l Session ,
59
60
analysis : & ' l ty:: CrateAnalysis < ' tcx > ,
60
61
@@ -68,20 +69,12 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
68
69
}
69
70
70
71
impl < ' 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
-
80
72
pub fn new ( sess : & ' l Session ,
81
73
analysis : & ' l ty:: CrateAnalysis < ' tcx > ,
82
74
output_file : Box < File > ) -> DumpCsvVisitor < ' l , ' tcx > {
83
75
DumpCsvVisitor {
84
76
sess : sess,
77
+ save_ctxt : SaveContext { sess : sess } ,
85
78
analysis : analysis,
86
79
collected_paths : vec ! [ ] ,
87
80
collecting : false ,
@@ -101,14 +94,23 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
101
94
}
102
95
}
103
96
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
+
104
106
pub fn dump_crate_info ( & mut self , name : & str , krate : & ast:: Crate ) {
105
- // the current crate
107
+ // The current crate.
106
108
self . fmt . crate_str ( krate. span , name) ;
107
109
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
+ }
112
114
self . fmt . recorder . record ( "end_external_crates\n " ) ;
113
115
}
114
116
0 commit comments