Skip to content

Commit bd97576

Browse files
catamorphismgraydon
authored andcommitted
---
yaml --- r: 2641 b: refs/heads/master c: 2cd769e h: refs/heads/master i: 2639: 40c60a2 v: v3
1 parent af6986a commit bd97576

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ef5473deb1c6a9f80534fb40de88291de308d1f5
2+
refs/heads/master: 2cd769e35898df0a84c797c610748a59034a9b93

trunk/src/comp/middle/tstate/annotate.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ import front::ast::block;
7373
import front::ast::block_;
7474
import front::ast::method;
7575

76-
import middle::fold;
77-
import middle::fold::respan;
7876
import middle::ty::expr_ann;
7977

8078
import util::common::uistr;
@@ -129,14 +127,14 @@ fn collect_ids_decl(&@decl d, @vec[uint] res) -> () {
129127
}
130128
}
131129

132-
fn node_ids_in_fn(&_fn f, &def_id d, @vec[uint] res) -> () {
130+
fn node_ids_in_fn(&_fn f, &ident i, &def_id d, @vec[uint] res) -> () {
133131
auto collect_ids = walk::default_visitor();
134132
collect_ids = rec(visit_expr_pre = bind collect_ids_expr(_,res),
135133
visit_block_pre = bind collect_ids_block(_,res),
136134
visit_stmt_pre = bind collect_ids_stmt(_,res),
137135
visit_decl_pre = bind collect_ids_decl(_,res)
138136
with collect_ids);
139-
walk::walk_fn(collect_ids, f, d);
137+
walk::walk_fn(collect_ids, f, i, d);
140138
}
141139

142140
fn init_vecs(&crate_ctxt ccx, @vec[uint] node_ids, uint len) -> () {
@@ -146,22 +144,22 @@ fn init_vecs(&crate_ctxt ccx, @vec[uint] node_ids, uint len) -> () {
146144
}
147145
}
148146

149-
fn visit_fn(&crate_ctxt ccx, uint num_locals, &_fn f, &def_id d) -> () {
150-
147+
fn visit_fn(&crate_ctxt ccx, uint num_locals, &_fn f, &ident i,
148+
&def_id d) -> () {
151149
let vec[uint] node_ids_ = [];
152150
let @vec[uint] node_ids = @node_ids_;
153-
node_ids_in_fn(f, d, node_ids);
151+
node_ids_in_fn(f, i, d, node_ids);
154152
init_vecs(ccx, node_ids, num_locals);
155153
}
156154

157-
fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &def_id f_id) -> () {
155+
fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &ident i, &def_id f_id) -> () {
158156
auto f_info = get_fn_info(ccx, f_id);
159-
visit_fn(ccx, num_locals(f_info), f, f_id);
157+
visit_fn(ccx, num_locals(f_info), f, i, f_id);
160158
}
161159

162160
fn annotate_crate(&crate_ctxt ccx, &crate crate) -> () {
163161
auto do_ann = walk::default_visitor();
164-
do_ann = rec(visit_fn_pre = bind annotate_in_fn(ccx, _, _)
162+
do_ann = rec(visit_fn_pre = bind annotate_in_fn(ccx, _, _, _)
165163
with do_ann);
166164
walk::walk_crate(do_ann, crate);
167165
}

trunk/src/comp/middle/tstate/collect_locals.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import front::ast::decl_local;
2020
import front::ast::def_id;
2121
import front::ast::ident;
2222

23-
import middle::fold::span;
24-
import middle::fold::respan;
2523
import middle::walk::walk_crate;
2624
import middle::walk::walk_fn;
2725
import middle::walk::ast_visitor;
@@ -47,13 +45,11 @@ fn collect_local(&@vec[tup(ident, def_id)] vars, &@decl d) -> () {
4745
}
4846
}
4947

50-
fn find_locals(_fn f, def_id d) -> @vec[tup(ident,def_id)] {
48+
fn find_locals(&_fn f, &ident i, &def_id d) -> @vec[tup(ident,def_id)] {
5149
auto res = @vec::alloc[tup(ident,def_id)](0u);
52-
5350
auto visitor = walk::default_visitor();
5451
visitor = rec(visit_decl_pre=bind collect_local(res,_) with visitor);
55-
walk_fn(visitor, f, d);
56-
52+
walk_fn(visitor, f, i, d);
5753
ret res;
5854
}
5955

@@ -66,7 +62,7 @@ fn add_var(def_id v, ident nm, uint next, fn_info tbl) -> uint {
6662

6763
/* builds a table mapping each local var defined in f
6864
to a bit number in the precondition/postcondition vectors */
69-
fn mk_fn_info(_fn f, def_id f_id, ident f_name) -> fn_info {
65+
fn mk_fn_info(&_fn f, &def_id f_id, &ident f_name) -> fn_info {
7066
auto res = rec(vars=@new_def_hash[var_info](),
7167
cf=f.decl.cf);
7268
let uint next = 0u;
@@ -75,7 +71,7 @@ fn mk_fn_info(_fn f, def_id f_id, ident f_name) -> fn_info {
7571
/* ignore args, which we know are initialized;
7672
just collect locally declared vars */
7773

78-
let @vec[tup(ident,def_id)] locals = find_locals(f, f_id);
74+
let @vec[tup(ident,def_id)] locals = find_locals(f, f_name, f_id);
7975
// log (uistr(vec::len[tup(ident, def_id)](locals)) + " locals");
8076
for (tup(ident,def_id) p in *locals) {
8177
next = add_var(p._1, p._0, next, res);
@@ -90,6 +86,8 @@ fn mk_fn_info(_fn f, def_id f_id, ident f_name) -> fn_info {
9086
ret res;
9187
}
9288

89+
/* FIXME: can do this with just one case -- for fn -- now */
90+
9391
/* extends mk_fn_info to an item, side-effecting the map fi from
9492
function IDs to fn_info maps
9593
only looks at function and object items. */

trunk/src/comp/middle/walk.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ type ast_visitor =
3232
fn (&@ast::expr e) visit_expr_post,
3333
fn (&@ast::ty t) visit_ty_pre,
3434
fn (&@ast::ty t) visit_ty_post,
35-
fn (&ast::_fn f, &ast::def_id d_id) visit_fn_pre,
36-
fn (&ast::_fn f, &ast::def_id d_id) visit_fn_post);
35+
fn (&ast::_fn f, &ast::ident name, &ast::def_id d_id) visit_fn_pre,
36+
fn (&ast::_fn f, &ast::ident name, &ast::def_id d_id) visit_fn_post);
3737

3838
fn walk_crate(&ast_visitor v, &ast::crate c) {
3939
if (!v.keep_going()) { ret; }
@@ -93,8 +93,8 @@ fn walk_item(&ast_visitor v, @ast::item i) {
9393
walk_ty(v, t);
9494
walk_expr(v, e);
9595
}
96-
case (ast::item_fn(_, ?f, _, ?d, _)) {
97-
walk_fn(v, f, d);
96+
case (ast::item_fn(?i, ?f, _, ?d, _)) {
97+
walk_fn(v, f, i, d);
9898
}
9999
case (ast::item_mod(_, ?m, _)) {
100100
walk_mod(v, m);
@@ -118,13 +118,13 @@ fn walk_item(&ast_visitor v, @ast::item i) {
118118
}
119119
for (@ast::method m in ob.methods) {
120120
v.visit_method_pre(m);
121-
walk_fn(v, m.node.meth, m.node.id);
121+
walk_fn(v, m.node.meth, m.node.ident, m.node.id);
122122
v.visit_method_post(m);
123123
}
124124
alt (ob.dtor) {
125125
case (none[@ast::method]) {}
126126
case (some[@ast::method](?m)) {
127-
walk_fn(v, m.node.meth, m.node.id);
127+
walk_fn(v, m.node.meth, m.node.ident, m.node.id);
128128
}
129129
}
130130
}
@@ -229,12 +229,12 @@ fn walk_fn_decl(&ast_visitor v, &ast::fn_decl fd) {
229229
walk_ty(v, fd.output);
230230
}
231231

232-
fn walk_fn(&ast_visitor v, &ast::_fn f, &ast::def_id d) {
232+
fn walk_fn(&ast_visitor v, &ast::_fn f, &ast::ident i, &ast::def_id d) {
233233
if (!v.keep_going()) { ret; }
234-
v.visit_fn_pre(f, d);
234+
v.visit_fn_pre(f, i, d);
235235
walk_fn_decl(v, f.decl);
236236
walk_block(v, f.body);
237-
v.visit_fn_post(f, d);
237+
v.visit_fn_post(f, i, d);
238238
}
239239

240240
fn walk_block(&ast_visitor v, &ast::block b) {
@@ -459,7 +459,7 @@ fn def_visit_arm(&ast::arm a) { }
459459
fn def_visit_decl(&@ast::decl d) { }
460460
fn def_visit_expr(&@ast::expr e) { }
461461
fn def_visit_ty(&@ast::ty t) { }
462-
fn def_visit_fn(&ast::_fn f, &ast::def_id d) { }
462+
fn def_visit_fn(&ast::_fn f, &ast::ident i, &ast::def_id d) { }
463463

464464
fn default_visitor() -> ast_visitor {
465465

0 commit comments

Comments
 (0)