@@ -29,12 +29,12 @@ use std::map::HashMap;
29
29
use std:: map;
30
30
use std;
31
31
32
- enum path_elt {
32
+ pub enum path_elt {
33
33
path_mod( ident ) ,
34
34
path_name( ident )
35
35
}
36
36
37
- impl path_elt : cmp:: Eq {
37
+ pub impl path_elt : cmp:: Eq {
38
38
pure fn eq ( & self , other : & path_elt ) -> bool {
39
39
match ( * self ) {
40
40
path_mod( e0a) => {
@@ -54,10 +54,10 @@ impl path_elt : cmp::Eq {
54
54
pure fn ne ( & self , other : & path_elt ) -> bool { !( * self ) . eq ( other) }
55
55
}
56
56
57
- type path = ~[ path_elt ] ;
57
+ pub type path = ~[ path_elt ] ;
58
58
59
- fn path_to_str_with_sep ( p : & [ path_elt ] , sep : ~str , itr : @ident_interner )
60
- -> ~str {
59
+ pub fn path_to_str_with_sep ( p : & [ path_elt ] , sep : ~str , itr : @ident_interner )
60
+ -> ~str {
61
61
let strs = do p. map |e| {
62
62
match * e {
63
63
path_mod( s) => * itr. get ( s) ,
@@ -67,7 +67,7 @@ fn path_to_str_with_sep(p: &[path_elt], sep: ~str, itr: @ident_interner)
67
67
str:: connect ( strs, sep)
68
68
}
69
69
70
- fn path_ident_to_str ( p : path , i : ident , itr : @ident_interner ) -> ~str {
70
+ pub fn path_ident_to_str ( p : path , i : ident , itr : @ident_interner ) -> ~str {
71
71
if vec:: is_empty ( p) {
72
72
//FIXME /* FIXME (#2543) */ copy *i
73
73
* itr. get ( i)
@@ -76,18 +76,18 @@ fn path_ident_to_str(p: path, i: ident, itr: @ident_interner) -> ~str {
76
76
}
77
77
}
78
78
79
- fn path_to_str ( p : & [ path_elt ] , itr : @ident_interner ) -> ~str {
79
+ pub fn path_to_str ( p : & [ path_elt ] , itr : @ident_interner ) -> ~str {
80
80
path_to_str_with_sep ( p, ~":: ", itr)
81
81
}
82
82
83
- fn path_elt_to_str ( pe : path_elt , itr : @ident_interner ) -> ~str {
83
+ pub fn path_elt_to_str ( pe : path_elt , itr : @ident_interner ) -> ~str {
84
84
match pe {
85
85
path_mod( s) => * itr. get ( s) ,
86
86
path_name( s) => * itr. get ( s)
87
87
}
88
88
}
89
89
90
- enum ast_node {
90
+ pub enum ast_node {
91
91
node_item( @item, @path) ,
92
92
node_foreign_item( @foreign_item , foreign_abi , @path) ,
93
93
node_trait_method( @trait_method , def_id /* trait did */ ,
@@ -107,20 +107,20 @@ enum ast_node {
107
107
node_struct_ctor( @struct_def , @item, @path) ,
108
108
}
109
109
110
- type map = std:: map:: HashMap < node_id , ast_node > ;
111
- struct ctx {
110
+ pub type map = std:: map:: HashMap < node_id , ast_node > ;
111
+ pub struct ctx {
112
112
map : map ,
113
113
mut path : path ,
114
114
mut local_id : uint ,
115
115
diag : span_handler ,
116
116
}
117
- type vt = visit:: vt < ctx > ;
117
+ pub type vt = visit:: vt < ctx > ;
118
118
119
- fn extend ( cx : ctx , +elt : ident ) -> @path {
119
+ pub fn extend ( cx : ctx , +elt : ident ) -> @path {
120
120
@( vec:: append ( cx . path, ~[ path_name ( elt ) ] ) )
121
121
}
122
122
123
- fn mk_ast_map_visitor ( ) -> vt {
123
+ pub fn mk_ast_map_visitor ( ) -> vt {
124
124
return visit:: mk_vt ( @visit:: Visitor {
125
125
visit_item : map_item,
126
126
visit_expr : map_expr,
@@ -134,7 +134,7 @@ fn mk_ast_map_visitor() -> vt {
134
134
} ) ;
135
135
}
136
136
137
- fn map_crate ( diag : span_handler , c: crate ) -> map {
137
+ pub fn map_crate ( diag : span_handler , c: crate ) -> map {
138
138
let cx = ctx {
139
139
map : std:: map:: HashMap ( ) ,
140
140
mut path : ~[ ] ,
@@ -148,8 +148,8 @@ fn map_crate(diag: span_handler, c: crate) -> map {
148
148
// Used for items loaded from external crate that are being inlined into this
149
149
// crate. The `path` should be the path to the item but should not include
150
150
// the item itself.
151
- fn map_decoded_item ( diag : span_handler ,
152
- map : map , path : path , ii : inlined_item ) {
151
+ pub fn map_decoded_item ( diag : span_handler ,
152
+ map : map , path : path , ii : inlined_item ) {
153
153
// I believe it is ok for the local IDs of inlined items from other crates
154
154
// to overlap with the local ids from this crate, so just generate the ids
155
155
// starting from 0. (In particular, I think these ids are only used in
@@ -182,8 +182,8 @@ fn map_decoded_item(diag: span_handler,
182
182
ii. accept ( cx, v) ;
183
183
}
184
184
185
- fn map_fn ( fk : visit:: fn_kind , decl : fn_decl , body : blk ,
186
- sp : codemap:: span , id : node_id , cx : ctx , v : vt ) {
185
+ pub fn map_fn ( fk : visit:: fn_kind , decl : fn_decl , body : blk ,
186
+ sp : codemap:: span , id : node_id , cx : ctx , v : vt ) {
187
187
for decl. inputs. each |a| {
188
188
cx. map . insert ( a. id ,
189
189
node_arg ( /* FIXME (#2543) */
@@ -210,12 +210,12 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
210
210
visit:: visit_fn ( fk, decl, body, sp, id, cx, v) ;
211
211
}
212
212
213
- fn map_block ( b : blk , cx : ctx , v : vt ) {
213
+ pub fn map_block ( b : blk , cx : ctx , v : vt ) {
214
214
cx. map . insert ( b. node . id , node_block ( /* FIXME (#2543) */ copy b) ) ;
215
215
visit:: visit_block ( b, cx, v) ;
216
216
}
217
217
218
- fn number_pat ( cx : ctx , pat : @pat) {
218
+ pub fn number_pat ( cx : ctx , pat : @pat) {
219
219
do ast_util:: walk_pat ( pat ) |p| {
220
220
match p. node {
221
221
pat_ident( * ) => {
@@ -227,24 +227,24 @@ fn number_pat(cx: ctx, pat: @pat) {
227
227
} ;
228
228
}
229
229
230
- fn map_local ( loc : @local , cx : ctx , v : vt ) {
230
+ pub fn map_local ( loc : @local , cx : ctx , v : vt ) {
231
231
number_pat( cx, loc. node. pat) ;
232
232
visit:: visit_local ( loc , cx , v ) ;
233
233
}
234
234
235
- fn map_arm ( arm : arm , cx : ctx , v : vt ) {
235
+ pub fn map_arm ( arm : arm , cx : ctx , v : vt ) {
236
236
number_pat( cx, arm. pats[ 0 ] ) ;
237
237
visit:: visit_arm ( arm , cx , v ) ;
238
238
}
239
239
240
- fn map_method ( impl_did : def_id , impl_path: @path,
241
- m : @method , cx : ctx ) {
240
+ pub fn map_method ( impl_did : def_id , impl_path: @path,
241
+ m : @method , cx : ctx ) {
242
242
cx. map . insert ( m. id , node_method ( m, impl_did, impl_path) ) ;
243
243
cx. map . insert ( m. self_id , node_local ( cx. local_id ) ) ;
244
244
cx. local_id += 1 u;
245
245
}
246
246
247
- fn map_item ( i : @item, cx : ctx , v : vt ) {
247
+ pub fn map_item ( i : @item, cx : ctx , v : vt ) {
248
248
let item_path = @/* FIXME ( #2543 ) * / copy cx. path ;
249
249
cx. map . insert ( i. id , node_item ( i, item_path) ) ;
250
250
match i. node {
@@ -306,8 +306,8 @@ fn map_item(i: @item, cx: ctx, v: vt) {
306
306
cx. path . pop ( ) ;
307
307
}
308
308
309
- fn map_struct_def ( struct_def : @ast:: struct_def , parent_node : ast_node ,
310
- ident : ast:: ident , cx : ctx , _v : vt ) {
309
+ pub fn map_struct_def ( struct_def : @ast:: struct_def , parent_node : ast_node ,
310
+ ident : ast:: ident , cx : ctx , _v : vt ) {
311
311
let p = extend ( cx, ident) ;
312
312
// If this is a tuple-like struct, register the constructor.
313
313
match struct_def. ctor_id {
@@ -324,7 +324,7 @@ fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
324
324
}
325
325
}
326
326
327
- fn map_view_item ( vi : @view_item , cx : ctx , _v : vt ) {
327
+ pub fn map_view_item ( vi : @view_item , cx : ctx , _v : vt ) {
328
328
match vi. node {
329
329
view_item_export( vps) => for vps. each |vp| {
330
330
let ( id, name) = match vp. node {
@@ -341,17 +341,17 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
341
341
}
342
342
}
343
343
344
- fn map_expr ( ex : @expr, cx : ctx , v : vt ) {
344
+ pub fn map_expr ( ex : @expr, cx : ctx , v : vt ) {
345
345
cx. map . insert ( ex. id , node_expr ( ex) ) ;
346
346
visit:: visit_expr ( ex, cx, v) ;
347
347
}
348
348
349
- fn map_stmt ( stmt : @stmt, cx : ctx , v : vt ) {
349
+ pub fn map_stmt ( stmt : @stmt, cx : ctx , v : vt ) {
350
350
cx. map . insert ( stmt_id ( * stmt) , node_stmt ( stmt) ) ;
351
351
visit:: visit_stmt ( stmt, cx, v) ;
352
352
}
353
353
354
- fn node_id_to_str( map : map , id : node_id , itr : @ident_interner ) -> ~str {
354
+ pub fn node_id_to_str( map : map , id : node_id , itr : @ident_interner ) -> ~str {
355
355
match map. find ( id) {
356
356
None => {
357
357
fmt ! ( "unknown node (id=%d)" , id)
@@ -419,7 +419,7 @@ fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
419
419
}
420
420
}
421
421
422
- fn node_item_query<Result >( items: map, id: node_id,
422
+ pub fn node_item_query<Result >( items: map, id: node_id,
423
423
query : fn ( @item) -> Result ,
424
424
error_msg: ~str ) -> Result {
425
425
match items. find ( id) {
0 commit comments