tidy tstate.collect_locals
This commit is contained in:
parent
c0f728712b
commit
a9bc6715e7
1 changed files with 3 additions and 28 deletions
|
|
@ -62,7 +62,7 @@ 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(&_fn f, &def_id f_id, &ident f_name) -> fn_info {
|
||||
fn mk_fn_info(&crate_ctxt ccx, &_fn f, &ident f_name, &def_id f_id) -> () {
|
||||
auto res = rec(vars=@new_def_hash[var_info](),
|
||||
cf=f.decl.cf);
|
||||
let uint next = 0u;
|
||||
|
|
@ -72,7 +72,6 @@ fn mk_fn_info(&_fn f, &def_id f_id, &ident f_name) -> fn_info {
|
|||
just collect locally declared vars */
|
||||
|
||||
let @vec[tup(ident,def_id)] locals = find_locals(f, f_name, f_id);
|
||||
// log (uistr(vec::len[tup(ident, def_id)](locals)) + " locals");
|
||||
for (tup(ident,def_id) p in *locals) {
|
||||
next = add_var(p._1, p._0, next, res);
|
||||
}
|
||||
|
|
@ -83,31 +82,7 @@ fn mk_fn_info(&_fn f, &def_id f_id, &ident f_name) -> fn_info {
|
|||
log(f_name + " has " + uistr(vec::len[tup(ident, def_id)](*locals))
|
||||
+ " locals");
|
||||
|
||||
ret res;
|
||||
}
|
||||
|
||||
/* FIXME: can do this with just one case -- for fn -- now */
|
||||
|
||||
/* extends mk_fn_info to an item, side-effecting the map fi from
|
||||
function IDs to fn_info maps
|
||||
only looks at function and object items. */
|
||||
fn mk_fn_info_item (&crate_ctxt ccx, &@item i) -> () {
|
||||
alt (i.node) {
|
||||
case (item_fn(?i,?f,?ty_params,?id,?a)) {
|
||||
auto f_inf = mk_fn_info(f, id, i);
|
||||
ccx.fm.insert(id, f_inf);
|
||||
}
|
||||
case (item_obj(?i,?o,?ty_params,?odid,?a)) {
|
||||
auto all_methods = vec::clone[@method](o.methods);
|
||||
plus_option[@method](all_methods, o.dtor);
|
||||
auto f_inf;
|
||||
for (@method m in all_methods) {
|
||||
f_inf = mk_fn_info(m.node.meth, m.node.id, m.node.ident);
|
||||
ccx.fm.insert(m.node.id, f_inf);
|
||||
}
|
||||
}
|
||||
case (_) { ret; }
|
||||
}
|
||||
ccx.fm.insert(f_id, res);
|
||||
}
|
||||
|
||||
/* initializes the global fn_info_map (mapping each function ID, including
|
||||
|
|
@ -115,7 +90,7 @@ fn mk_fn_info_item (&crate_ctxt ccx, &@item i) -> () {
|
|||
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_item_post=bind mk_fn_info_item(ccx,_)
|
||||
vars_visitor = rec(visit_fn_pre=bind mk_fn_info(ccx,_,_,_)
|
||||
with vars_visitor);
|
||||
|
||||
walk_crate(vars_visitor, *c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue