@@ -13,9 +13,6 @@ import front::ast::ty_param;
13
13
import front:: ast:: crate;
14
14
15
15
import front:: ast:: expr;
16
- import middle:: fold:: respan;
17
- import middle:: fold:: new_identity_fold;
18
- import middle:: fold:: fold_crate;
19
16
import middle:: ty:: type_is_nil;
20
17
import middle:: ty:: ret_ty_of_fn;
21
18
import util:: common:: span;
@@ -153,43 +150,16 @@ fn check_fn_states(&fn_ctxt fcx, &_fn f, &ann a) -> () {
153
150
check_states_against_conditions ( fcx, f, a) ;
154
151
}
155
152
156
- fn check_item_fn_state ( & crate_ctxt ccx, & span sp, & ident i,
157
- & _fn f, & vec[ ty_param] ty_params ,
158
- & def_id id, & ann a) -> @item {
159
-
153
+ fn fn_states ( & crate_ctxt ccx, & _fn f, & ident i, & def_id id, & ann a) -> ( ) {
160
154
/* Look up the var-to-bit-num map for this function */
161
155
assert ( ccx. fm . contains_key ( id) ) ;
162
156
auto f_info = ccx. fm . get ( id) ;
163
157
164
158
auto fcx = rec ( enclosing=f_info, id=id, name=i, ccx=ccx) ;
165
159
check_fn_states ( fcx, f, a) ;
166
-
167
- /* Rebuild the same function */
168
- ret @respan ( sp, item_fn ( i, f, ty_params, id, a) ) ;
169
- }
170
-
171
- fn check_method_states ( & crate_ctxt ccx, @method m ) -> ( ) {
172
- assert ( ccx. fm . contains_key ( m. node . id ) ) ;
173
- auto fcx = rec ( enclosing=ccx. fm . get ( m. node . id ) ,
174
- id=m. node . id , name=m. node . ident , ccx=ccx) ;
175
- check_fn_states ( fcx, m. node . meth , m. node . ann ) ;
176
- }
177
-
178
- fn check_obj_state ( & crate_ctxt ccx, & vec[ obj_field] fields ,
179
- & vec[ @method] methods ,
180
- & option:: t[ @method] dtor ) -> _obj {
181
- fn one ( crate_ctxt ccx, & @method m ) -> ( ) {
182
- ret check_method_states ( ccx, m) ;
183
- }
184
- auto f = bind one( ccx, _) ;
185
- vec:: map[ @method, ( ) ] ( f, methods) ;
186
- option:: map[ @method, ( ) ] ( f, dtor) ;
187
- ret rec( fields=fields, methods=methods, dtor=dtor) ;
188
160
}
189
161
190
- /* FIXME use walk instead of fold where possible */
191
-
192
- fn check_crate ( ty:: node_type_table nt, ty:: ctxt cx, @crate crate) -> @crate {
162
+ fn check_crate ( ty:: node_type_table nt, ty:: ctxt cx, @crate crate) -> ( ) {
193
163
let crate_ctxt ccx = new_crate_ctxt ( nt, cx) ;
194
164
195
165
/* Build the global map from function id to var-to-bit-num-map */
@@ -200,17 +170,16 @@ fn check_crate(ty::node_type_table nt, ty::ctxt cx, @crate crate) -> @crate {
200
170
201
171
/* Compute the pre and postcondition for every subexpression */
202
172
auto do_pre_post = walk:: default_visitor ( ) ;
203
- do_pre_post = rec ( visit_fn_pre = bind fn_pre_post ( ccx, _ , _ , _)
173
+ do_pre_post = rec ( visit_fn_pre = bind fn_pre_post ( ccx, _ , _ , _ , _)
204
174
with do_pre_post) ;
205
175
walk:: walk_crate ( do_pre_post, * crate ) ;
206
176
207
- auto fld1 = new_identity_fold[ crate_ctxt] ( ) ;
208
-
209
- fld1 = @rec ( fold_item_fn = bind check_item_fn_state ( _, _, _, _, _, _, _) ,
210
- fold_obj = bind check_obj_state ( _, _, _, _)
211
- with * fld1) ;
212
-
213
- ret fold_crate[ crate_ctxt] ( ccx, fld1, crate ) ;
177
+ /* Check the pre- and postcondition against the pre- and poststate
178
+ for every expression */
179
+ auto do_states = walk:: default_visitor ( ) ;
180
+ do_states = rec ( visit_fn_pre = bind fn_states ( ccx, _, _, _, _)
181
+ with do_states) ;
182
+ walk:: walk_crate ( do_states, * crate ) ;
214
183
}
215
184
216
185
//
0 commit comments