Skip to content

Typestate #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rewrite pre_postconditions to use walk instead of fold
  • Loading branch information
catamorphism committed May 19, 2011
commit 86d09647b6ecc95e27d5f15ff4881d0aedfbd5ed
13 changes: 6 additions & 7 deletions src/comp/middle/tstate/ck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import bitvectors::promises;

import annotate::annotate_crate;
import collect_locals::mk_f_to_fn_info;
import pre_post_conditions::check_item_fn;
import pre_post_conditions::fn_pre_post;
import states::find_pre_post_state_fn;

fn check_states_expr(&fn_ctxt fcx, @expr e) -> () {
Expand Down Expand Up @@ -199,19 +199,18 @@ fn check_crate(ty::node_type_table nt, ty::ctxt cx, @crate crate) -> @crate {
annotate_crate(ccx, *crate);

/* Compute the pre and postcondition for every subexpression */

auto fld = new_identity_fold[crate_ctxt]();
fld = @rec(fold_item_fn = bind check_item_fn(_,_,_,_,_,_,_) with *fld);
auto with_pre_postconditions =
fold_crate[crate_ctxt](ccx, fld, crate);
auto do_pre_post = walk::default_visitor();
do_pre_post = rec(visit_fn_pre = bind fn_pre_post(ccx, _, _, _)
with do_pre_post);
walk::walk_crate(do_pre_post, *crate);

auto fld1 = new_identity_fold[crate_ctxt]();

fld1 = @rec(fold_item_fn = bind check_item_fn_state(_,_,_,_,_,_,_),
fold_obj = bind check_obj_state(_,_,_,_)
with *fld1);

ret fold_crate[crate_ctxt](ccx, fld1, with_pre_postconditions);
ret fold_crate[crate_ctxt](ccx, fld1, crate);
}

//
Expand Down
9 changes: 1 addition & 8 deletions src/comp/middle/tstate/pre_post_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,18 +679,11 @@ fn find_pre_post_fn(&fn_ctxt fcx, &_fn f) -> () {
find_pre_post_block(fcx, f.body);
}

fn check_item_fn(&crate_ctxt ccx, &span sp, &ident i, &_fn f,
&vec[ty_param] ty_params,
&def_id id, &ann a) -> @item {
log("check_item_fn:");
log_fn(f, i, ty_params);

fn fn_pre_post(crate_ctxt ccx, &_fn f, &ident i, &def_id id) -> () {
assert (ccx.fm.contains_key(id));
auto fcx = rec(enclosing=ccx.fm.get(id),
id=id, name=i, ccx=ccx);
find_pre_post_fn(fcx, f);

ret @respan(sp, item_fn(i, f, ty_params, id, a));
}

//
Expand Down