@@ -62,7 +62,7 @@ fn add_var(def_id v, ident nm, uint next, fn_info tbl) -> uint {
62
62
63
63
/* builds a table mapping each local var defined in f
64
64
to a bit number in the precondition/postcondition vectors */
65
- fn mk_fn_info ( & _fn f , & def_id f_id , & ident f_name ) -> fn_info {
65
+ fn mk_fn_info ( & crate_ctxt ccx , & _fn f , & ident f_name , & def_id f_id ) -> ( ) {
66
66
auto res = rec ( vars=@new_def_hash[ var_info] ( ) ,
67
67
cf=f. decl . cf ) ;
68
68
let uint next = 0 u;
@@ -72,7 +72,6 @@ fn mk_fn_info(&_fn f, &def_id f_id, &ident f_name) -> fn_info {
72
72
just collect locally declared vars */
73
73
74
74
let @vec[ tup( ident, def_id) ] locals = find_locals ( f, f_name, f_id) ;
75
- // log (uistr(vec::len[tup(ident, def_id)](locals)) + " locals");
76
75
for ( tup( ident, def_id) p in * locals) {
77
76
next = add_var ( p. _1 , p. _0 , next, res) ;
78
77
}
@@ -83,39 +82,15 @@ fn mk_fn_info(&_fn f, &def_id f_id, &ident f_name) -> fn_info {
83
82
log ( f_name + " has " + uistr ( vec:: len[ tup ( ident, def_id) ] ( * locals) )
84
83
+ " locals" ) ;
85
84
86
- ret res;
87
- }
88
-
89
- /* FIXME: can do this with just one case -- for fn -- now */
90
-
91
- /* extends mk_fn_info to an item, side-effecting the map fi from
92
- function IDs to fn_info maps
93
- only looks at function and object items. */
94
- fn mk_fn_info_item ( & crate_ctxt ccx, & @item i ) -> ( ) {
95
- alt ( i. node ) {
96
- case ( item_fn ( ?i, ?f, ?ty_params, ?id, ?a) ) {
97
- auto f_inf = mk_fn_info ( f, id, i) ;
98
- ccx. fm . insert ( id, f_inf) ;
99
- }
100
- case ( item_obj ( ?i, ?o, ?ty_params, ?odid, ?a) ) {
101
- auto all_methods = vec:: clone[ @method] ( o. methods ) ;
102
- plus_option[ @method] ( all_methods, o. dtor ) ;
103
- auto f_inf;
104
- for ( @method m in all_methods) {
105
- f_inf = mk_fn_info ( m. node . meth , m. node . id , m. node . ident ) ;
106
- ccx. fm . insert ( m. node . id , f_inf) ;
107
- }
108
- }
109
- case ( _) { ret; }
110
- }
85
+ ccx. fm . insert ( f_id, res) ;
111
86
}
112
87
113
88
/* initializes the global fn_info_map (mapping each function ID, including
114
89
nested locally defined functions, onto a mapping from local variable name
115
90
to bit number) */
116
91
fn mk_f_to_fn_info ( & crate_ctxt ccx, @crate c ) -> ( ) {
117
92
let ast_visitor vars_visitor = walk:: default_visitor ( ) ;
118
- vars_visitor = rec ( visit_item_post =bind mk_fn_info_item ( ccx, _)
93
+ vars_visitor = rec ( visit_fn_pre =bind mk_fn_info ( ccx, _ , _ , _)
119
94
with vars_visitor) ;
120
95
121
96
walk_crate ( vars_visitor, * c) ;
0 commit comments