@@ -28,6 +28,35 @@ import common::*;
28
28
export read_crates;
29
29
export list_file_metadata;
30
30
31
+ // Traverses an AST, reading all the information about use'd crates and native
32
+ // libraries necessary for later resolving, typechecking, linking, etc.
33
+ fn read_crates ( session:: session sess, resolve:: crate_map crate_map,
34
+ & ast:: crate crate) {
35
+ auto e =
36
+ @rec ( sess=sess,
37
+ crate_map=crate_map,
38
+ crate_cache=@std:: map:: new_str_hash[ int] ( ) ,
39
+ library_search_paths=sess. get_opts ( ) . library_search_paths ,
40
+ mutable next_crate_num=1 ) ;
41
+ auto v =
42
+ rec ( visit_view_item_pre=bind visit_view_item ( e, _) ,
43
+ visit_item_pre=bind visit_item ( e, _)
44
+ with walk:: default_visitor ( ) ) ;
45
+ walk:: walk_crate ( v, crate ) ;
46
+ }
47
+
48
+ // A diagnostic function for dumping crate metadata to an output stream
49
+ fn list_file_metadata ( str path , io:: writer out) {
50
+ alt ( get_metadata_section ( path) ) {
51
+ case ( option:: some ( ?bytes) ) {
52
+ decoder:: list_crate_metadata ( bytes, out) ;
53
+ }
54
+ case ( option:: none) {
55
+ out. write_str ( "Could not find metadata in " + path + ".\n " ) ;
56
+ }
57
+ }
58
+ }
59
+
31
60
fn metadata_matches( & vec[ u8] crate_data ,
32
61
& ( @ast:: meta_item ) [ ] metas) -> bool {
33
62
auto attrs = decoder:: get_crate_attributes ( crate_data ) ;
@@ -199,34 +228,6 @@ fn visit_item(env e, &@ast::item i) {
199
228
}
200
229
}
201
230
202
- // Reads external crates referenced by "use" directives.
203
- fn read_crates( session:: session sess, resolve:: crate_map crate_map,
204
- & ast:: crate crate) {
205
- auto e =
206
- @rec( sess=sess,
207
- crate_map=crate_map,
208
- crate_cache=@std:: map:: new_str_hash[ int] ( ) ,
209
- library_search_paths=sess. get_opts( ) . library_search_paths,
210
- mutable next_crate_num=1 ) ;
211
- auto v =
212
- rec( visit_view_item_pre=bind visit_view_item( e, _) ,
213
- visit_item_pre=bind visit_item( e, _)
214
- with walk:: default_visitor( ) ) ;
215
- walk:: walk_crate( v, crate ) ;
216
- }
217
-
218
-
219
- fn list_file_metadata( str path, io:: writer out) {
220
- alt ( get_metadata_section( path) ) {
221
- case ( option:: some( ?bytes) ) {
222
- decoder:: list_crate_metadata( bytes, out) ;
223
- }
224
- case ( option:: none) {
225
- out. write_str( "Could not find metadata in " + path + ".\n " ) ;
226
- }
227
- }
228
- }
229
-
230
231
231
232
// Local Variables:
232
233
// mode: rust
0 commit comments