mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Go back to a single visit_fn function in visit.rs
This commit is contained in:
parent
711ff657e2
commit
46cddffb8f
@ -61,7 +61,7 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
|
||||
copy_map: std::map::new_int_hash(),
|
||||
ref_map: std::map::new_int_hash(),
|
||||
mutable silent: false};
|
||||
let v = @{visit_fn_body: bind visit_fn_body(cx, _, _, _, _, _, _, _),
|
||||
let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _, _),
|
||||
visit_expr: bind visit_expr(cx, _, _, _),
|
||||
visit_block: bind visit_block(cx, _, _, _)
|
||||
with *visit::default_visitor::<scope>()};
|
||||
@ -71,9 +71,9 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
|
||||
ret (cx.copy_map, cx.ref_map);
|
||||
}
|
||||
|
||||
fn visit_fn_body(cx: @ctx, decl: ast::fn_decl, body: ast::blk,
|
||||
sp: span, _name: ast::fn_ident,
|
||||
id: ast::node_id, sc: scope, v: vt<scope>) {
|
||||
fn visit_fn(cx: @ctx, decl: ast::fn_decl, _ts: [ast::ty_param],
|
||||
body: ast::blk, sp: span, _name: ast::fn_ident,
|
||||
id: ast::node_id, sc: scope, v: vt<scope>) {
|
||||
visit::visit_fn_decl(decl, sc, v);
|
||||
let fty = ty::node_id_to_type(cx.tcx, id);
|
||||
let args = ty::ty_fn_args(cx.tcx, fty);
|
||||
|
@ -32,7 +32,7 @@ fn map_crate(c: crate) -> map {
|
||||
(@{visit_item: bind map_item(cx, _),
|
||||
visit_native_item: bind map_native_item(cx, _),
|
||||
visit_expr: bind map_expr(cx, _),
|
||||
visit_fn_body: bind map_fn_body(cx, _, _, _, _, _),
|
||||
visit_fn: bind map_fn(cx, _, _, _, _, _, _),
|
||||
visit_local: bind map_local(cx, _),
|
||||
visit_arm: bind map_arm(cx, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
@ -40,8 +40,8 @@ fn map_crate(c: crate) -> map {
|
||||
ret cx.map;
|
||||
}
|
||||
|
||||
fn map_fn_body(cx: ctx, decl: fn_decl, _body: blk,
|
||||
_sp: codemap::span, _n: fn_ident, _id: node_id) {
|
||||
fn map_fn(cx: ctx, decl: fn_decl, _tps: [ty_param], _body: blk,
|
||||
_sp: codemap::span, _n: fn_ident, _id: node_id) {
|
||||
for a in decl.inputs {
|
||||
cx.map.insert(a.id, node_arg(a, cx.local_id));
|
||||
cx.local_id += 1u;
|
||||
|
@ -82,15 +82,15 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) ->
|
||||
freevar_map {
|
||||
let freevars = new_int_hash();
|
||||
|
||||
let walk_fn_body = lambda (_decl: ast::fn_decl, blk: ast::blk,
|
||||
_sp: span, _nm: ast::fn_ident,
|
||||
nid: ast::node_id) {
|
||||
let walk_fn = lambda (_decl: ast::fn_decl, _tps: [ast::ty_param],
|
||||
blk: ast::blk, _sp: span, _nm: ast::fn_ident,
|
||||
nid: ast::node_id) {
|
||||
let vars = collect_freevars(def_map, blk);
|
||||
freevars.insert(nid, vars);
|
||||
};
|
||||
|
||||
let visitor =
|
||||
visit::mk_simple_visitor(@{visit_fn_body: walk_fn_body
|
||||
visit::mk_simple_visitor(@{visit_fn: walk_fn
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(*crate, (), visitor);
|
||||
|
||||
|
@ -43,7 +43,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map,
|
||||
let visit = visit::mk_vt(@{
|
||||
visit_expr: check_expr,
|
||||
visit_stmt: check_stmt,
|
||||
visit_fn_body: check_fn_body
|
||||
visit_fn: check_fn
|
||||
with *visit::default_visitor()
|
||||
});
|
||||
visit::visit_crate(*crate, ctx, visit);
|
||||
@ -66,8 +66,8 @@ fn with_closure_check_fn(cx: ctx, id: node_id,
|
||||
|
||||
// Check that the free variables used in a shared/sendable closure conform
|
||||
// to the copy/move kind bounds. Then recursively check the function body.
|
||||
fn check_fn_body(decl: fn_decl, body: blk, sp: span, i: fn_ident, id: node_id,
|
||||
cx: ctx, v: visit::vt<ctx>) {
|
||||
fn check_fn(decl: fn_decl, tps: [ty_param], body: blk, sp: span,
|
||||
i: fn_ident, id: node_id, cx: ctx, v: visit::vt<ctx>) {
|
||||
|
||||
// n.b.: This could be the body of either a fn decl or a fn expr. In the
|
||||
// former case, the prototype will be proto_bare and no check occurs. In
|
||||
@ -87,7 +87,7 @@ fn check_fn_body(decl: fn_decl, body: blk, sp: span, i: fn_ident, id: node_id,
|
||||
}
|
||||
}
|
||||
|
||||
visit::visit_fn_body(decl, body, sp, i, id, cx, v);
|
||||
visit::visit_fn(decl, tps, body, sp, i, id, cx, v);
|
||||
}
|
||||
|
||||
fn check_fn_cap_clause(cx: ctx,
|
||||
|
@ -43,7 +43,7 @@ type ctx = {last_uses: std::map::hashmap<node_id, bool>,
|
||||
fn find_last_uses(c: @crate, def_map: resolve::def_map,
|
||||
ref_map: alias::ref_map, tcx: ty::ctxt) -> last_uses {
|
||||
let v = visit::mk_vt(@{visit_expr: visit_expr,
|
||||
visit_fn_body: visit_fn_body
|
||||
visit_fn: visit_fn
|
||||
with *visit::default_visitor()});
|
||||
let cx = {last_uses: std::map::new_int_hash(),
|
||||
def_map: def_map,
|
||||
@ -153,19 +153,19 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_fn_body(decl: fn_decl, body: blk,
|
||||
sp: span, nm: fn_ident, id: node_id,
|
||||
cx: ctx, v: visit::vt<ctx>) {
|
||||
fn visit_fn(decl: fn_decl, tps: [ty_param], body: blk,
|
||||
sp: span, nm: fn_ident, id: node_id,
|
||||
cx: ctx, v: visit::vt<ctx>) {
|
||||
let fty = ty::node_id_to_type(cx.tcx, id);
|
||||
let proto = ty::ty_fn_proto(cx.tcx, fty);
|
||||
if proto == proto_block {
|
||||
visit_block(func, cx, {||
|
||||
visit::visit_fn_body(decl, body, sp, nm, id, cx, v);
|
||||
visit::visit_fn(decl, tps, body, sp, nm, id, cx, v);
|
||||
});
|
||||
} else {
|
||||
let old = nil;
|
||||
cx.blocks <-> old;
|
||||
visit::visit_fn_body(decl, body, sp, nm, id, cx, v);
|
||||
visit::visit_fn(decl, tps, body, sp, nm, id, cx, v);
|
||||
cx.blocks <-> old;
|
||||
leave_fn(cx);
|
||||
}
|
||||
|
@ -336,8 +336,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
||||
visit_expr: bind walk_expr(e, _, _, _),
|
||||
visit_ty: bind walk_ty(e, _, _, _),
|
||||
visit_constr: bind walk_constr(e, _, _, _, _, _),
|
||||
visit_fn_proto:
|
||||
bind visit_fn_proto_with_scope(e, _, _, _, _, _, _, _, _)
|
||||
visit_fn: bind visit_fn_with_scope(e, _, _, _, _, _, _, _, _)
|
||||
with *visit::default_visitor()};
|
||||
visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v));
|
||||
e.used_imports.track = false;
|
||||
@ -403,8 +402,8 @@ fn visit_item_with_scope(i: @ast::item, sc: scopes, v: vt<scopes>) {
|
||||
alt ifce { some(ty) { v.visit_ty(ty, sc, v); } _ {} }
|
||||
v.visit_ty(sty, sc, v);
|
||||
for m in methods {
|
||||
v.visit_fn_proto(m.decl, tps + m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, sc, v);
|
||||
v.visit_fn(m.decl, tps + m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, sc, v);
|
||||
}
|
||||
}
|
||||
_ { visit::visit_item(i, sc, v); }
|
||||
@ -416,9 +415,9 @@ fn visit_native_item_with_scope(ni: @ast::native_item, sc: scopes,
|
||||
visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v);
|
||||
}
|
||||
|
||||
fn visit_fn_proto_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param],
|
||||
body: ast::blk, sp: span, name: fn_ident,
|
||||
id: node_id, sc: scopes, v: vt<scopes>) {
|
||||
fn visit_fn_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param],
|
||||
body: ast::blk, sp: span, name: fn_ident,
|
||||
id: node_id, sc: scopes, v: vt<scopes>) {
|
||||
// is this a main fn declaration?
|
||||
alt name {
|
||||
some(nm) {
|
||||
@ -439,7 +438,7 @@ fn visit_fn_proto_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param],
|
||||
_ { scope_fn_expr(decl, id, tp) }
|
||||
};
|
||||
|
||||
visit::visit_fn_proto(decl, tp, body, sp, name, id, cons(scope, @sc), v);
|
||||
visit::visit_fn(decl, tp, body, sp, name, id, cons(scope, @sc), v);
|
||||
}
|
||||
|
||||
fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt<scopes>) {
|
||||
|
@ -56,8 +56,8 @@ fn visit_fn(ccx: crate_ctxt, num_constraints: uint, body: blk) {
|
||||
init_vecs(ccx, node_id_vec, num_constraints);
|
||||
}
|
||||
|
||||
fn annotate_in_fn_body(ccx: crate_ctxt, _decl: fn_decl, body: blk,
|
||||
_sp: span, _n: fn_ident, id: node_id) {
|
||||
fn annotate_in_fn(ccx: crate_ctxt, _decl: fn_decl, _ts: [ty_param], body: blk,
|
||||
_sp: span, _n: fn_ident, id: node_id) {
|
||||
let f_info = get_fn_info(ccx, id);
|
||||
visit_fn(ccx, num_constraints(f_info), body);
|
||||
}
|
||||
@ -65,7 +65,7 @@ fn annotate_in_fn_body(ccx: crate_ctxt, _decl: fn_decl, body: blk,
|
||||
fn annotate_crate(ccx: crate_ctxt, crate: crate) {
|
||||
let do_ann =
|
||||
visit::mk_simple_visitor(
|
||||
@{visit_fn_body: bind annotate_in_fn_body(ccx, _, _, _, _, _)
|
||||
@{visit_fn: bind annotate_in_fn(ccx, _, _, _, _, _, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(crate, (), do_ann);
|
||||
}
|
||||
|
@ -1008,7 +1008,7 @@ fn op_to_oper_ty(io: init_op) -> oper_type {
|
||||
}
|
||||
|
||||
// default function visitor
|
||||
fn do_nothing<T>(_decl: fn_decl, _body: blk,
|
||||
fn do_nothing<T>(_decl: fn_decl, _ts: [ty_param], _body: blk,
|
||||
_sp: span, _i: fn_ident, _id: node_id,
|
||||
_t: T, _v: visit::vt<T>) {
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ fn relax_precond_block(fcx: fn_ctxt, i: node_id, b: blk) {
|
||||
visit_stmt: relax_precond_stmt,
|
||||
visit_item:
|
||||
fn (_i: @item, _cx: relax_ctxt, _vt: visit::vt<relax_ctxt>) { },
|
||||
visit_fn_body: bind do_nothing(_, _, _, _, _, _, _)
|
||||
visit_fn: bind do_nothing(_, _, _, _, _, _, _, _)
|
||||
with *visitor};
|
||||
let v1 = visit::mk_vt(visitor);
|
||||
v1.visit_block(b, cx, v1);
|
||||
|
@ -106,9 +106,9 @@ fn check_states_against_conditions(fcx: fn_ctxt,
|
||||
let visitor = visit::mk_vt(
|
||||
@{visit_stmt: check_states_stmt,
|
||||
visit_expr: check_states_expr,
|
||||
visit_fn_body: bind do_nothing::<fn_ctxt>(_, _, _, _, _, _, _)
|
||||
visit_fn: bind do_nothing::<fn_ctxt>(_, _, _, _, _, _, _, _)
|
||||
with *visit::default_visitor::<fn_ctxt>()});
|
||||
visit::visit_fn_body(f_decl, f_body, sp, nm, id, fcx, visitor);
|
||||
visit::visit_fn(f_decl, [], f_body, sp, nm, id, fcx, visitor);
|
||||
|
||||
/* Check that the return value is initialized */
|
||||
let post = aux::block_poststate(fcx.ccx, f_body);
|
||||
@ -158,10 +158,10 @@ fn check_fn_states(fcx: fn_ctxt,
|
||||
check_states_against_conditions(fcx, f_decl, f_body, sp, nm, id);
|
||||
}
|
||||
|
||||
fn fn_states(f_decl: ast::fn_decl, f_body: ast::blk,
|
||||
fn fn_states(f_decl: ast::fn_decl, tps: [ast::ty_param], f_body: ast::blk,
|
||||
sp: span, i: ast::fn_ident, id: node_id,
|
||||
ccx: crate_ctxt, v: visit::vt<crate_ctxt>) {
|
||||
visit::visit_fn_body(f_decl, f_body, sp, i, id, ccx, v);
|
||||
visit::visit_fn(f_decl, tps, f_body, sp, i, id, ccx, v);
|
||||
/* Look up the var-to-bit-num map for this function */
|
||||
|
||||
assert (ccx.fm.contains_key(id));
|
||||
@ -182,13 +182,13 @@ fn check_crate(cx: ty::ctxt, crate: @crate) {
|
||||
/* Compute the pre and postcondition for every subexpression */
|
||||
|
||||
let vtor = visit::default_visitor::<crate_ctxt>();
|
||||
vtor = @{visit_fn_body: fn_pre_post with *vtor};
|
||||
vtor = @{visit_fn: fn_pre_post with *vtor};
|
||||
visit::visit_crate(*crate, ccx, visit::mk_vt(vtor));
|
||||
|
||||
/* Check the pre- and postcondition against the pre- and poststate
|
||||
for every expression */
|
||||
let vtor = visit::default_visitor::<crate_ctxt>();
|
||||
vtor = @{visit_fn_body: fn_states with *vtor};
|
||||
vtor = @{visit_fn: fn_states with *vtor};
|
||||
visit::visit_crate(*crate, ccx, visit::mk_vt(vtor));
|
||||
}
|
||||
//
|
||||
|
@ -46,6 +46,7 @@ fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) {
|
||||
|
||||
fn find_locals(tcx: ty::ctxt,
|
||||
f_decl: fn_decl,
|
||||
tps: [ty_param],
|
||||
f_body: blk,
|
||||
sp: span,
|
||||
n: fn_ident,
|
||||
@ -56,10 +57,10 @@ fn find_locals(tcx: ty::ctxt,
|
||||
visitor =
|
||||
@{visit_local: collect_local,
|
||||
visit_expr: collect_pred,
|
||||
visit_fn_body: bind do_nothing(_, _, _, _, _, _, _)
|
||||
visit_fn: bind do_nothing(_, _, _, _, _, _, _, _)
|
||||
with *visitor};
|
||||
visit::visit_fn_body(f_decl, f_body, sp,
|
||||
n, id, cx, visit::mk_vt(visitor));
|
||||
visit::visit_fn(f_decl, tps, f_body, sp,
|
||||
n, id, cx, visit::mk_vt(visitor));
|
||||
ret cx;
|
||||
}
|
||||
|
||||
@ -98,6 +99,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
|
||||
to a bit number in the precondition/postcondition vectors */
|
||||
fn mk_fn_info(ccx: crate_ctxt,
|
||||
f_decl: fn_decl,
|
||||
tps: [ty_param],
|
||||
f_body: blk,
|
||||
f_sp: span,
|
||||
f_name: fn_ident,
|
||||
@ -106,7 +108,8 @@ fn mk_fn_info(ccx: crate_ctxt,
|
||||
let res_map = @new_def_hash::<constraint>();
|
||||
let next: uint = 0u;
|
||||
|
||||
let cx: ctxt = find_locals(ccx.tcx, f_decl, f_body, f_sp, f_name, id);
|
||||
let cx: ctxt = find_locals(ccx.tcx, f_decl, tps, f_body, f_sp,
|
||||
f_name, id);
|
||||
/* now we have to add bit nums for both the constraints
|
||||
and the variables... */
|
||||
|
||||
@ -163,8 +166,8 @@ fn mk_fn_info(ccx: crate_ctxt,
|
||||
to bit number) */
|
||||
fn mk_f_to_fn_info(ccx: crate_ctxt, c: @crate) {
|
||||
let visitor =
|
||||
visit::mk_simple_visitor(@{visit_fn_body:
|
||||
bind mk_fn_info(ccx, _, _, _, _, _)
|
||||
visit::mk_simple_visitor(@{visit_fn:
|
||||
bind mk_fn_info(ccx, _, _, _, _, _, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(*c, (), visitor);
|
||||
}
|
||||
|
@ -727,10 +727,10 @@ fn find_pre_post_fn(fcx: fn_ctxt, body: blk) {
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_pre_post(decl: fn_decl, body: blk, sp: span,
|
||||
fn fn_pre_post(decl: fn_decl, tps: [ty_param], body: blk, sp: span,
|
||||
i: fn_ident, id: node_id,
|
||||
ccx: crate_ctxt, v: visit::vt<crate_ctxt>) {
|
||||
visit::visit_fn_body(decl, body, sp, i, id, ccx, v);
|
||||
visit::visit_fn(decl, tps, body, sp, i, id, ccx, v);
|
||||
assert (ccx.fm.contains_key(id));
|
||||
let fcx =
|
||||
{enclosing: ccx.fm.get(id),
|
||||
|
@ -1124,16 +1124,16 @@ fn gather_locals(ccx: @crate_ctxt,
|
||||
};
|
||||
|
||||
// Don't descend into fns and items
|
||||
fn visit_fn_body<T>(_decl: ast::fn_decl, _body: ast::blk,
|
||||
_sp: span, _nm: ast::fn_ident, _id: ast::node_id,
|
||||
_t: T, _v: visit::vt<T>) {
|
||||
fn visit_fn<T>(_decl: ast::fn_decl, _ts: [ast::ty_param], _body: ast::blk,
|
||||
_sp: span, _nm: ast::fn_ident, _id: ast::node_id,
|
||||
_t: T, _v: visit::vt<T>) {
|
||||
}
|
||||
fn visit_item<E>(_i: @ast::item, _e: E, _v: visit::vt<E>) { }
|
||||
|
||||
let visit =
|
||||
@{visit_local: visit_local,
|
||||
visit_pat: visit_pat,
|
||||
visit_fn_body: bind visit_fn_body(_, _, _, _, _, _, _),
|
||||
visit_fn: bind visit_fn(_, _, _, _, _, _, _, _),
|
||||
visit_item: bind visit_item(_, _, _)
|
||||
with *visit::default_visitor()};
|
||||
|
||||
|
@ -31,14 +31,8 @@ type visitor<E> =
|
||||
visit_expr: fn@(@expr, E, vt<E>),
|
||||
visit_ty: fn@(@ty, E, vt<E>),
|
||||
visit_constr: fn@(@path, span, node_id, E, vt<E>),
|
||||
|
||||
// A function with a fully specified prototype:
|
||||
visit_fn_proto: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id,
|
||||
E, vt<E>),
|
||||
|
||||
// Invoked by both visit_fn_proto above.
|
||||
// Intended to be a common flow point for all fn decls in AST.
|
||||
visit_fn_body: fn@(fn_decl, blk, span, fn_ident, node_id, E, vt<E>)};
|
||||
visit_fn: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id,
|
||||
E, vt<E>)};
|
||||
|
||||
fn default_visitor<E>() -> visitor<E> {
|
||||
ret @{visit_mod: bind visit_mod::<E>(_, _, _, _),
|
||||
@ -54,8 +48,7 @@ fn default_visitor<E>() -> visitor<E> {
|
||||
visit_expr: bind visit_expr::<E>(_, _, _),
|
||||
visit_ty: bind skip_ty::<E>(_, _, _),
|
||||
visit_constr: bind visit_constr::<E>(_, _, _, _, _),
|
||||
visit_fn_proto: bind visit_fn_proto::<E>(_, _, _, _, _, _, _, _),
|
||||
visit_fn_body: bind visit_fn_body::<E>(_, _, _, _, _, _, _)};
|
||||
visit_fn: bind visit_fn::<E>(_, _, _, _, _, _, _, _)};
|
||||
}
|
||||
|
||||
fn visit_crate<E>(c: crate, e: E, v: vt<E>) {
|
||||
@ -92,7 +85,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
||||
alt i.node {
|
||||
item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); }
|
||||
item_fn(decl, tp, body) {
|
||||
v.visit_fn_proto(decl, tp, body, i.span, some(i.ident), i.id, e, v);
|
||||
v.visit_fn(decl, tp, body, i.span, some(i.ident), i.id, e, v);
|
||||
}
|
||||
item_mod(m) { v.visit_mod(m, i.span, e, v); }
|
||||
item_native_mod(nm) {
|
||||
@ -101,8 +94,8 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
||||
}
|
||||
item_ty(t, _) { v.visit_ty(t, e, v); }
|
||||
item_res(decl, tps, body, dtor_id, _) {
|
||||
v.visit_fn_proto(decl, tps, body, i.span, some(i.ident), dtor_id,
|
||||
e, v);
|
||||
v.visit_fn(decl, tps, body, i.span, some(i.ident), dtor_id,
|
||||
e, v);
|
||||
}
|
||||
item_tag(variants, _) {
|
||||
for vr: variant in variants {
|
||||
@ -112,16 +105,16 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
||||
item_obj(ob, _, _) {
|
||||
for f: obj_field in ob.fields { v.visit_ty(f.ty, e, v); }
|
||||
for m: @method in ob.methods {
|
||||
v.visit_fn_proto(m.decl, m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, e, v);
|
||||
v.visit_fn(m.decl, m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, e, v);
|
||||
}
|
||||
}
|
||||
item_impl(_, ifce, ty, methods) {
|
||||
alt ifce { some(ty) { v.visit_ty(ty, e, v); } _ {} }
|
||||
v.visit_ty(ty, e, v);
|
||||
for m in methods {
|
||||
v.visit_fn_proto(m.decl, m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, e, v);
|
||||
v.visit_fn(m.decl, m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, e, v);
|
||||
}
|
||||
}
|
||||
item_iface(_, methods) {
|
||||
@ -211,14 +204,8 @@ fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) {
|
||||
v.visit_ty(fd.output, e, v);
|
||||
}
|
||||
|
||||
fn visit_fn_proto<E>(decl: fn_decl, _tp: [ty_param], body: blk, sp: span,
|
||||
i: fn_ident, id: node_id, e: E, v: vt<E>) {
|
||||
v.visit_fn_body(decl, body, sp, i, id, e, v);
|
||||
}
|
||||
|
||||
fn visit_fn_body<E>(decl: fn_decl, body: blk, _sp: span,
|
||||
_name: fn_ident, _id: node_id,
|
||||
e: E, v: vt<E>) {
|
||||
fn visit_fn<E>(decl: fn_decl, _tp: [ty_param], body: blk, _sp: span,
|
||||
_i: fn_ident, _id: node_id, e: E, v: vt<E>) {
|
||||
visit_fn_decl(decl, e, v);
|
||||
v.visit_block(body, e, v);
|
||||
}
|
||||
@ -309,10 +296,10 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
for a: arm in arms { v.visit_arm(a, e, v); }
|
||||
}
|
||||
expr_fn(decl, body, _) {
|
||||
v.visit_fn_proto(decl, [], body, ex.span, none, ex.id, e, v);
|
||||
v.visit_fn(decl, [], body, ex.span, none, ex.id, e, v);
|
||||
}
|
||||
expr_fn_block(decl, body) {
|
||||
v.visit_fn_proto(decl, [], body, ex.span, none, ex.id, e, v);
|
||||
v.visit_fn(decl, [], body, ex.span, none, ex.id, e, v);
|
||||
}
|
||||
expr_block(b) { v.visit_block(b, e, v); }
|
||||
expr_assign(a, b) { v.visit_expr(b, e, v); v.visit_expr(a, e, v); }
|
||||
@ -355,8 +342,8 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
some(ex) { v.visit_expr(ex, e, v); }
|
||||
}
|
||||
for m: @method in anon_obj.methods {
|
||||
v.visit_fn_proto(m.decl, m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, e, v);
|
||||
v.visit_fn(m.decl, m.tps, m.body, m.span,
|
||||
some(m.ident), m.id, e, v);
|
||||
}
|
||||
}
|
||||
expr_mac(mac) { visit_mac(mac, e, v); }
|
||||
@ -388,8 +375,7 @@ type simple_visitor =
|
||||
visit_expr: fn@(@expr),
|
||||
visit_ty: fn@(@ty),
|
||||
visit_constr: fn@(@path, span, node_id),
|
||||
visit_fn_proto: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id),
|
||||
visit_fn_body: fn@(fn_decl, blk, span, fn_ident, node_id)};
|
||||
visit_fn: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id)};
|
||||
|
||||
fn simple_ignore_ty(_t: @ty) {}
|
||||
|
||||
@ -407,12 +393,8 @@ fn default_simple_visitor() -> simple_visitor {
|
||||
visit_expr: fn(_e: @expr) { },
|
||||
visit_ty: simple_ignore_ty,
|
||||
visit_constr: fn(_p: @path, _sp: span, _id: node_id) { },
|
||||
visit_fn_proto:
|
||||
fn(_d: fn_decl, _tps: [ty_param], _b: blk, _sp: span,
|
||||
_ident: fn_ident, _id: node_id) { },
|
||||
visit_fn_body:
|
||||
fn(_f: fn_decl, _b: blk, _sp: span,
|
||||
_nm: fn_ident, _node_id: node_id) { }
|
||||
visit_fn: fn(_d: fn_decl, _tps: [ty_param], _b: blk, _sp: span,
|
||||
_ident: fn_ident, _id: node_id) { }
|
||||
};
|
||||
}
|
||||
|
||||
@ -475,14 +457,7 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
decl: fn_decl, tps: [ty_param], body: blk, sp: span,
|
||||
ident: fn_ident, id: node_id, &&e: (), v: vt<()>) {
|
||||
f(decl, tps, body, sp, ident, id);
|
||||
visit_fn_proto(decl, tps, body, sp, ident, id, e, v);
|
||||
}
|
||||
fn v_fn_body(f: fn@(fn_decl, blk, span, fn_ident, node_id),
|
||||
fn_decl: fn_decl, blk: blk,
|
||||
sp: span, name: fn_ident, node_id: node_id,
|
||||
&&e: (), v: vt<()>) {
|
||||
f(fn_decl, blk, sp, name, node_id);
|
||||
visit_fn_body(fn_decl, blk, sp, name, node_id, e, v);
|
||||
visit_fn(decl, tps, body, sp, ident, id, e, v);
|
||||
}
|
||||
let visit_ty = if v.visit_ty == simple_ignore_ty {
|
||||
bind skip_ty(_, _, _)
|
||||
@ -503,10 +478,7 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
visit_expr: bind v_expr(v.visit_expr, _, _, _),
|
||||
visit_ty: visit_ty,
|
||||
visit_constr: bind v_constr(v.visit_constr, _, _, _, _, _),
|
||||
visit_fn_proto:
|
||||
bind v_fn(v.visit_fn_proto, _, _, _, _, _, _, _, _),
|
||||
visit_fn_body:
|
||||
bind v_fn_body(v.visit_fn_body, _, _, _, _, _, _, _),
|
||||
visit_fn: bind v_fn(v.visit_fn, _, _, _, _, _, _, _, _)
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user