diff --git a/src/comp/middle/tstate/annotate.rs b/src/comp/middle/tstate/annotate.rs index 9dc7a7ca843a..743f525401d1 100644 --- a/src/comp/middle/tstate/annotate.rs +++ b/src/comp/middle/tstate/annotate.rs @@ -127,14 +127,14 @@ fn collect_ids_decl(&@decl d, @vec[uint] res) -> () { } } -fn node_ids_in_fn(&_fn f, &ident i, &def_id d, @vec[uint] res) -> () { +fn node_ids_in_fn(&_fn f, &ident i, &def_id d, &ann a, @vec[uint] res) -> () { auto collect_ids = walk::default_visitor(); collect_ids = rec(visit_expr_pre = bind collect_ids_expr(_,res), visit_block_pre = bind collect_ids_block(_,res), visit_stmt_pre = bind collect_ids_stmt(_,res), visit_decl_pre = bind collect_ids_decl(_,res) with collect_ids); - walk::walk_fn(collect_ids, f, i, d); + walk::walk_fn(collect_ids, f, i, d, a); } fn init_vecs(&crate_ctxt ccx, @vec[uint] node_ids, uint len) -> () { @@ -145,21 +145,22 @@ fn init_vecs(&crate_ctxt ccx, @vec[uint] node_ids, uint len) -> () { } fn visit_fn(&crate_ctxt ccx, uint num_locals, &_fn f, &ident i, - &def_id d) -> () { + &def_id d, &ann a) -> () { let vec[uint] node_ids_ = []; let @vec[uint] node_ids = @node_ids_; - node_ids_in_fn(f, i, d, node_ids); + node_ids_in_fn(f, i, d, a, node_ids); init_vecs(ccx, node_ids, num_locals); } -fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &ident i, &def_id f_id) -> () { +fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &ident i, &def_id f_id, &ann a) + -> () { auto f_info = get_fn_info(ccx, f_id); - visit_fn(ccx, num_locals(f_info), f, i, f_id); + visit_fn(ccx, num_locals(f_info), f, i, f_id, a); } fn annotate_crate(&crate_ctxt ccx, &crate crate) -> () { auto do_ann = walk::default_visitor(); - do_ann = rec(visit_fn_pre = bind annotate_in_fn(ccx, _, _, _) + do_ann = rec(visit_fn_pre = bind annotate_in_fn(ccx,_,_,_,_) with do_ann); walk::walk_crate(do_ann, crate); } diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs index 73225dbe0615..83931ecbc553 100644 --- a/src/comp/middle/tstate/collect_locals.rs +++ b/src/comp/middle/tstate/collect_locals.rs @@ -45,11 +45,12 @@ fn collect_local(&@vec[tup(ident, def_id)] vars, &@decl d) -> () { } } -fn find_locals(&_fn f, &ident i, &def_id d) -> @vec[tup(ident,def_id)] { +fn find_locals(&_fn f, &ident i, &def_id d, &ann a) + -> @vec[tup(ident,def_id)] { auto res = @vec::alloc[tup(ident,def_id)](0u); auto visitor = walk::default_visitor(); visitor = rec(visit_decl_pre=bind collect_local(res,_) with visitor); - walk_fn(visitor, f, i, d); + walk_fn(visitor, f, i, d, a); ret res; } @@ -62,7 +63,8 @@ fn add_var(def_id v, ident nm, uint next, fn_info tbl) -> uint { /* builds a table mapping each local var defined in f to a bit number in the precondition/postcondition vectors */ -fn mk_fn_info(&crate_ctxt ccx, &_fn f, &ident f_name, &def_id f_id) -> () { +fn mk_fn_info(&crate_ctxt ccx, &_fn f, &ident f_name, &def_id f_id, &ann a) + -> () { auto res = rec(vars=@new_def_hash[var_info](), cf=f.decl.cf); let uint next = 0u; @@ -71,7 +73,7 @@ fn mk_fn_info(&crate_ctxt ccx, &_fn f, &ident f_name, &def_id f_id) -> () { /* ignore args, which we know are initialized; just collect locally declared vars */ - let @vec[tup(ident,def_id)] locals = find_locals(f, f_name, f_id); + let @vec[tup(ident,def_id)] locals = find_locals(f, f_name, f_id, a); for (tup(ident,def_id) p in *locals) { next = add_var(p._1, p._0, next, res); } @@ -90,7 +92,7 @@ fn mk_fn_info(&crate_ctxt ccx, &_fn f, &ident f_name, &def_id f_id) -> () { to bit number) */ fn mk_f_to_fn_info(&crate_ctxt ccx, @crate c) -> () { let ast_visitor vars_visitor = walk::default_visitor(); - vars_visitor = rec(visit_fn_pre=bind mk_fn_info(ccx,_,_,_) + vars_visitor = rec(visit_fn_pre=bind mk_fn_info(ccx,_,_,_,_) with vars_visitor); walk_crate(vars_visitor, *c); diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index ed52142f1ad7..1752fcaf2b13 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -138,9 +138,6 @@ import front::ast::stmt_expr; import front::ast::block; import front::ast::block_; -import middle::fold::span; -import middle::fold::respan; - import util::common::new_def_hash; import util::common::decl_lhs; import util::common::uistr; @@ -679,7 +676,7 @@ fn find_pre_post_fn(&fn_ctxt fcx, &_fn f) -> () { find_pre_post_block(fcx, f.body); } -fn fn_pre_post(crate_ctxt ccx, &_fn f, &ident i, &def_id id) -> () { +fn fn_pre_post(crate_ctxt ccx, &_fn f, &ident i, &def_id id, &ann a) -> () { assert (ccx.fm.contains_key(id)); auto fcx = rec(enclosing=ccx.fm.get(id), id=id, name=i, ccx=ccx); diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs index f838b760e624..5c0c5b3667f9 100644 --- a/src/comp/middle/walk.rs +++ b/src/comp/middle/walk.rs @@ -32,8 +32,10 @@ type ast_visitor = fn (&@ast::expr e) visit_expr_post, fn (&@ast::ty t) visit_ty_pre, fn (&@ast::ty t) visit_ty_post, - fn (&ast::_fn f, &ast::ident name, &ast::def_id d_id) visit_fn_pre, - fn (&ast::_fn f, &ast::ident name, &ast::def_id d_id) visit_fn_post); + fn (&ast::_fn f, &ast::ident name, + &ast::def_id d_id, &ast::ann a) visit_fn_pre, + fn (&ast::_fn f, &ast::ident name, + &ast::def_id d_id, &ast::ann a) visit_fn_post); fn walk_crate(&ast_visitor v, &ast::crate c) { if (!v.keep_going()) { ret; } @@ -93,8 +95,8 @@ fn walk_item(&ast_visitor v, @ast::item i) { walk_ty(v, t); walk_expr(v, e); } - case (ast::item_fn(?i, ?f, _, ?d, _)) { - walk_fn(v, f, i, d); + case (ast::item_fn(?i, ?f, _, ?d, ?a)) { + walk_fn(v, f, i, d, a); } case (ast::item_mod(_, ?m, _)) { walk_mod(v, m); @@ -118,13 +120,14 @@ fn walk_item(&ast_visitor v, @ast::item i) { } for (@ast::method m in ob.methods) { v.visit_method_pre(m); - walk_fn(v, m.node.meth, m.node.ident, m.node.id); + walk_fn(v, m.node.meth, m.node.ident, m.node.id, m.node.ann); v.visit_method_post(m); } alt (ob.dtor) { case (none[@ast::method]) {} case (some[@ast::method](?m)) { - walk_fn(v, m.node.meth, m.node.ident, m.node.id); + walk_fn(v, m.node.meth, m.node.ident, m.node.id, + m.node.ann); } } } @@ -229,12 +232,13 @@ fn walk_fn_decl(&ast_visitor v, &ast::fn_decl fd) { walk_ty(v, fd.output); } -fn walk_fn(&ast_visitor v, &ast::_fn f, &ast::ident i, &ast::def_id d) { +fn walk_fn(&ast_visitor v, &ast::_fn f, &ast::ident i, &ast::def_id d, + &ast::ann a) { if (!v.keep_going()) { ret; } - v.visit_fn_pre(f, i, d); + v.visit_fn_pre(f, i, d, a); walk_fn_decl(v, f.decl); walk_block(v, f.body); - v.visit_fn_post(f, i, d); + v.visit_fn_post(f, i, d, a); } fn walk_block(&ast_visitor v, &ast::block b) { @@ -459,7 +463,7 @@ fn def_visit_arm(&ast::arm a) { } fn def_visit_decl(&@ast::decl d) { } fn def_visit_expr(&@ast::expr e) { } fn def_visit_ty(&@ast::ty t) { } -fn def_visit_fn(&ast::_fn f, &ast::ident i, &ast::def_id d) { } +fn def_visit_fn(&ast::_fn f, &ast::ident i, &ast::def_id d, &ast::ann a) { } fn default_visitor() -> ast_visitor {