librustc: Eliminate most expressions of the form a.b() that are not method calls. rs=refactoring

This commit is contained in:
Patrick Walton 2012-11-29 17:51:16 -08:00
parent b38d7f6538
commit a0617eae68
43 changed files with 295 additions and 275 deletions

View file

@ -414,7 +414,7 @@ impl TaskBuilder {
mut notify_chan: move notify_chan, mut notify_chan: move notify_chan,
sched: x.opts.sched sched: x.opts.sched
}; };
spawn::spawn_raw(move opts, x.gen_body(move f)); spawn::spawn_raw(move opts, (x.gen_body)(move f));
} }
/// Runs a task, while transfering ownership of one argument to the child. /// Runs a task, while transfering ownership of one argument to the child.
fn spawn_with<A: Send>(arg: A, f: fn~(v: A)) { fn spawn_with<A: Send>(arg: A, f: fn~(v: A)) {

View file

@ -610,7 +610,7 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
flav: ~str) -> ~str { flav: ~str) -> ~str {
return mangle(ccx.sess, return mangle(ccx.sess,
vec::append_one(path, path_name(ccx.names(flav)))); vec::append_one(path, path_name((ccx.names)(flav))));
} }
fn mangle_internal_name_by_path(ccx: @crate_ctxt, path: path) -> ~str { fn mangle_internal_name_by_path(ccx: @crate_ctxt, path: path) -> ~str {
@ -618,7 +618,7 @@ fn mangle_internal_name_by_path(ccx: @crate_ctxt, path: path) -> ~str {
} }
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str { fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str {
return fmt!("%s_%u", flav, ccx.names(flav).repr); return fmt!("%s_%u", flav, (ccx.names)(flav).repr);
} }
// If the user wants an exe generated we need to invoke // If the user wants an exe generated we need to invoke

View file

@ -126,25 +126,25 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
} }
fn item_in_cfg(cx: ctxt, item: @ast::item) -> bool { fn item_in_cfg(cx: ctxt, item: @ast::item) -> bool {
return cx.in_cfg(item.attrs); return (cx.in_cfg)(item.attrs);
} }
fn foreign_item_in_cfg(cx: ctxt, item: @ast::foreign_item) -> bool { fn foreign_item_in_cfg(cx: ctxt, item: @ast::foreign_item) -> bool {
return cx.in_cfg(item.attrs); return (cx.in_cfg)(item.attrs);
} }
fn view_item_in_cfg(cx: ctxt, item: @ast::view_item) -> bool { fn view_item_in_cfg(cx: ctxt, item: @ast::view_item) -> bool {
return cx.in_cfg(item.attrs); return (cx.in_cfg)(item.attrs);
} }
fn method_in_cfg(cx: ctxt, meth: @ast::method) -> bool { fn method_in_cfg(cx: ctxt, meth: @ast::method) -> bool {
return cx.in_cfg(meth.attrs); return (cx.in_cfg)(meth.attrs);
} }
fn trait_method_in_cfg(cx: ctxt, meth: &ast::trait_method) -> bool { fn trait_method_in_cfg(cx: ctxt, meth: &ast::trait_method) -> bool {
match *meth { match *meth {
ast::required(ref meth) => cx.in_cfg(meth.attrs), ast::required(ref meth) => (cx.in_cfg)(meth.attrs),
ast::provided(@ref meth) => cx.in_cfg(meth.attrs) ast::provided(@ref meth) => (cx.in_cfg)(meth.attrs)
} }
} }

View file

@ -474,7 +474,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: Writer::Serializer,
encode_path(ecx, ebml_w, path, ast_map::path_name(ident)); encode_path(ecx, ebml_w, path, ast_map::path_name(ident));
match item { match item {
Some(it) => { Some(it) => {
ecx.encode_inlined_item(ecx, ebml_w, path, it); (ecx.encode_inlined_item)(ecx, ebml_w, path, it);
} }
None => { None => {
encode_symbol(ecx, ebml_w, id); encode_symbol(ecx, ebml_w, id);
@ -503,7 +503,7 @@ fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: Writer::Serializer,
encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident));
encode_self_type(ebml_w, m.self_ty.node); encode_self_type(ebml_w, m.self_ty.node);
if all_tps.len() > 0u || should_inline { if all_tps.len() > 0u || should_inline {
ecx.encode_inlined_item( (ecx.encode_inlined_item)(
ecx, ebml_w, impl_path, ecx, ebml_w, impl_path,
ii_method(local_def(parent_id), m)); ii_method(local_def(parent_id), m));
} else { } else {
@ -581,7 +581,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer,
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
encode_attributes(ebml_w, item.attrs); encode_attributes(ebml_w, item.attrs);
if tps.len() > 0u || should_inline(item.attrs) { if tps.len() > 0u || should_inline(item.attrs) {
ecx.encode_inlined_item(ecx, ebml_w, path, ii_item(item)); (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item));
} else { } else {
encode_symbol(ecx, ebml_w, item.id); encode_symbol(ecx, ebml_w, item.id);
} }
@ -623,7 +623,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer,
for enum_definition.variants.each |v| { for enum_definition.variants.each |v| {
encode_variant_id(ebml_w, local_def(v.node.id)); encode_variant_id(ebml_w, local_def(v.node.id));
} }
ecx.encode_inlined_item(ecx, ebml_w, path, ii_item(item)); (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item));
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
encode_region_param(ecx, ebml_w, item); encode_region_param(ecx, ebml_w, item);
} }
@ -851,8 +851,8 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: Writer::Serializer,
encode_type_param_bounds(ebml_w, ecx, tps); encode_type_param_bounds(ebml_w, ecx, tps);
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id));
if abi == foreign_abi_rust_intrinsic { if abi == foreign_abi_rust_intrinsic {
ecx.encode_inlined_item(ecx, ebml_w, path, (ecx.encode_inlined_item)(ecx, ebml_w, path,
ii_foreign(nitem)); ii_foreign(nitem));
} else { } else {
encode_symbol(ecx, ebml_w, nitem.id); encode_symbol(ecx, ebml_w, nitem.id);
} }

View file

@ -67,9 +67,9 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
// Do not emit node ids that map to unexported names. Those // Do not emit node ids that map to unexported names. Those
// are not helpful. // are not helpful.
if def_id.crate != local_crate || if def_id.crate != local_crate ||
cx.reachable(def_id.node) { (cx.reachable)(def_id.node) {
w.write_char('"'); w.write_char('"');
w.write_str(cx.ds(def_id)); w.write_str((cx.ds)(def_id));
w.write_char('|'); w.write_char('|');
} }
} }
@ -229,14 +229,14 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
} }
ty::ty_enum(def, substs) => { ty::ty_enum(def, substs) => {
w.write_str(&"t["); w.write_str(&"t[");
w.write_str(cx.ds(def)); w.write_str((cx.ds)(def));
w.write_char('|'); w.write_char('|');
enc_substs(w, cx, substs); enc_substs(w, cx, substs);
w.write_char(']'); w.write_char(']');
} }
ty::ty_trait(def, substs, vstore) => { ty::ty_trait(def, substs, vstore) => {
w.write_str(&"x["); w.write_str(&"x[");
w.write_str(cx.ds(def)); w.write_str((cx.ds)(def));
w.write_char('|'); w.write_char('|');
enc_substs(w, cx, substs); enc_substs(w, cx, substs);
enc_vstore(w, cx, vstore); enc_vstore(w, cx, vstore);
@ -293,7 +293,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
} }
ty::ty_param({idx: id, def_id: did}) => { ty::ty_param({idx: id, def_id: did}) => {
w.write_char('p'); w.write_char('p');
w.write_str(cx.ds(did)); w.write_str((cx.ds)(did));
w.write_char('|'); w.write_char('|');
w.write_str(uint::str(id)); w.write_str(uint::str(id));
} }
@ -309,7 +309,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
ty::ty_class(def, substs) => { ty::ty_class(def, substs) => {
debug!("~~~~ %s", ~"a["); debug!("~~~~ %s", ~"a[");
w.write_str(&"a["); w.write_str(&"a[");
let s = cx.ds(def); let s = (cx.ds)(def);
debug!("~~~~ %s", s); debug!("~~~~ %s", s);
w.write_str(s); w.write_str(s);
debug!("~~~~ %s", ~"|"); debug!("~~~~ %s", ~"|");

View file

@ -189,11 +189,11 @@ fn req_loans_in_expr(ex: @ast::expr,
ast::expr_while(cond, body) => { ast::expr_while(cond, body) => {
// during the condition, can only root for the condition // during the condition, can only root for the condition
self.root_ub = cond.id; self.root_ub = cond.id;
vt.visit_expr(cond, self, vt); (vt.visit_expr)(cond, self, vt);
// during body, can only root for the body // during body, can only root for the body
self.root_ub = body.node.id; self.root_ub = body.node.id;
vt.visit_block(body, self, vt); (vt.visit_block)(body, self, vt);
} }
// see explanation attached to the `root_ub` field: // see explanation attached to the `root_ub` field:

View file

@ -22,13 +22,13 @@ fn check_item(sess: Session, ast_map: ast_map::map,
it: @item, &&_is_const: bool, v: visit::vt<bool>) { it: @item, &&_is_const: bool, v: visit::vt<bool>) {
match it.node { match it.node {
item_const(_, ex) => { item_const(_, ex) => {
v.visit_expr(ex, true, v); (v.visit_expr)(ex, true, v);
check_item_recursion(sess, ast_map, def_map, it); check_item_recursion(sess, ast_map, def_map, it);
} }
item_enum(enum_definition, _) => { item_enum(enum_definition, _) => {
for enum_definition.variants.each |var| { for enum_definition.variants.each |var| {
do option::iter(&var.node.disr_expr) |ex| { do option::iter(&var.node.disr_expr) |ex| {
v.visit_expr(*ex, true, v); (v.visit_expr)(*ex, true, v);
} }
} }
} }
@ -46,10 +46,10 @@ fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
} }
match p.node { match p.node {
// Let through plain ~-string literals here // Let through plain ~-string literals here
pat_lit(a) => if !is_str(a) { v.visit_expr(a, true, v); }, pat_lit(a) => if !is_str(a) { (v.visit_expr)(a, true, v); },
pat_range(a, b) => { pat_range(a, b) => {
if !is_str(a) { v.visit_expr(a, true, v); } if !is_str(a) { (v.visit_expr)(a, true, v); }
if !is_str(b) { v.visit_expr(b, true, v); } if !is_str(b) { (v.visit_expr)(b, true, v); }
} }
_ => visit::visit_pat(p, false, v) _ => visit::visit_pat(p, false, v)
} }
@ -179,7 +179,7 @@ fn check_item_recursion(sess: Session, ast_map: ast_map::map,
visit_expr: visit_expr, visit_expr: visit_expr,
.. *visit::default_visitor() .. *visit::default_visitor()
}); });
visitor.visit_item(it, env, visitor); (visitor.visit_item)(it, env, visitor);
fn visit_item(it: @item, &&env: env, v: visit::vt<env>) { fn visit_item(it: @item, &&env: env, v: visit::vt<env>) {
if (*env.idstack).contains(&(it.id)) { if (*env.idstack).contains(&(it.id)) {
@ -197,7 +197,7 @@ fn check_item_recursion(sess: Session, ast_map: ast_map::map,
Some(def_const(def_id)) => { Some(def_const(def_id)) => {
match env.ast_map.get(def_id.node) { match env.ast_map.get(def_id.node) {
ast_map::node_item(it, _) => { ast_map::node_item(it, _) => {
v.visit_item(it, env, v); (v.visit_item)(it, env, v);
} }
_ => fail ~"const not bound to an item" _ => fail ~"const not bound to an item"
} }

View file

@ -4,29 +4,31 @@ use syntax::visit;
type ctx = {in_loop: bool, can_ret: bool}; type ctx = {in_loop: bool, can_ret: bool};
fn check_crate(tcx: ty::ctxt, crate: @crate) { fn check_crate(tcx: ty::ctxt, crate: @crate) {
visit::visit_crate(*crate, {in_loop: false,can_ret: true}, visit::mk_vt(@{ visit::visit_crate(*crate,
{in_loop: false, can_ret: true},
visit::mk_vt(@{
visit_item: |i, _cx, v| { visit_item: |i, _cx, v| {
visit::visit_item(i, {in_loop: false, can_ret: true}, v); visit::visit_item(i, {in_loop: false, can_ret: true}, v);
}, },
visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| { visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| {
match e.node { match e.node {
expr_while(e, b) => { expr_while(e, b) => {
v.visit_expr(e, cx, v); (v.visit_expr)(e, cx, v);
v.visit_block(b, {in_loop: true,.. cx}, v); (v.visit_block)(b, {in_loop: true,.. cx}, v);
} }
expr_loop(b, _) => { expr_loop(b, _) => {
v.visit_block(b, {in_loop: true,.. cx}, v); (v.visit_block)(b, {in_loop: true,.. cx}, v);
} }
expr_fn(_, _, _, _) => { expr_fn(_, _, _, _) => {
visit::visit_expr(e, {in_loop: false, can_ret: true}, v); visit::visit_expr(e, {in_loop: false, can_ret: true}, v);
} }
expr_fn_block(_, b, _) => { expr_fn_block(_, b, _) => {
v.visit_block(b, {in_loop: false, can_ret: false}, v); (v.visit_block)(b, {in_loop: false, can_ret: false}, v);
} }
expr_loop_body(@{node: expr_fn_block(_, b, _), _}) => { expr_loop_body(@{node: expr_fn_block(_, b, _), _}) => {
let proto = ty::ty_fn_proto(ty::expr_ty(tcx, e)); let proto = ty::ty_fn_proto(ty::expr_ty(tcx, e));
let blk = (proto == ProtoBorrowed); let blk = (proto == ProtoBorrowed);
v.visit_block(b, {in_loop: true, can_ret: blk}, v); (v.visit_block)(b, {in_loop: true, can_ret: blk}, v);
} }
expr_break(_) => { expr_break(_) => {
if !cx.in_loop { if !cx.in_loop {

View file

@ -76,7 +76,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk)
let v = visit::mk_vt(@{visit_item: ignore_item, visit_expr: walk_expr, let v = visit::mk_vt(@{visit_item: ignore_item, visit_expr: walk_expr,
.. *visit::default_visitor()}); .. *visit::default_visitor()});
v.visit_block(blk, 1, v); (v.visit_block)(blk, 1, v);
return @*refs; return @*refs;
} }

View file

@ -449,7 +449,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
visit_arm: check_arm, visit_arm: check_arm,
.. *visit::default_visitor() .. *visit::default_visitor()
}); });
check_vt.visit_block(body, lsets, check_vt); (check_vt.visit_block)(body, lsets, check_vt);
lsets.check_ret(id, sp, fk, entry_ln); lsets.check_ret(id, sp, fk, entry_ln);
lsets.warn_about_unused_args(decl, entry_ln); lsets.warn_about_unused_args(decl, entry_ln);
} }
@ -1512,7 +1512,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
expr_assign(l, r) => { expr_assign(l, r) => {
self.check_lvalue(l, vt); self.check_lvalue(l, vt);
vt.visit_expr(r, self, vt); (vt.visit_expr)(r, self, vt);
visit::visit_expr(expr, self, vt); visit::visit_expr(expr, self, vt);
} }

View file

@ -584,11 +584,13 @@ fn determine_rp_in_fn(fk: visit::fn_kind,
visitor: visit::vt<determine_rp_ctxt>) { visitor: visit::vt<determine_rp_ctxt>) {
do cx.with(cx.item_id, false) { do cx.with(cx.item_id, false) {
do cx.with_ambient_variance(rv_contravariant) { do cx.with_ambient_variance(rv_contravariant) {
for decl.inputs.each |a| { visitor.visit_ty(a.ty, cx, visitor); } for decl.inputs.each |a| {
(visitor.visit_ty)(a.ty, cx, visitor);
}
} }
visitor.visit_ty(decl.output, cx, visitor); (visitor.visit_ty)(decl.output, cx, visitor);
visitor.visit_ty_params(visit::tps_of_fn(fk), cx, visitor); (visitor.visit_ty_params)(visit::tps_of_fn(fk), cx, visitor);
visitor.visit_block(body, cx, visitor); (visitor.visit_block)(body, cx, visitor);
} }
} }
@ -695,7 +697,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
// type parameters are---for now, anyway---always invariant // type parameters are---for now, anyway---always invariant
do cx.with_ambient_variance(rv_invariant) { do cx.with_ambient_variance(rv_invariant) {
for path.types.each |tp| { for path.types.each |tp| {
visitor.visit_ty(*tp, cx, visitor); (visitor.visit_ty)(*tp, cx, visitor);
} }
} }
} }
@ -707,11 +709,11 @@ fn determine_rp_in_ty(ty: @ast::Ty,
// parameters are contravariant // parameters are contravariant
do cx.with_ambient_variance(rv_contravariant) { do cx.with_ambient_variance(rv_contravariant) {
for f.decl.inputs.each |a| { for f.decl.inputs.each |a| {
visitor.visit_ty(a.ty, cx, visitor); (visitor.visit_ty)(a.ty, cx, visitor);
} }
} }
visit::visit_ty_param_bounds(f.bounds, cx, visitor); visit::visit_ty_param_bounds(f.bounds, cx, visitor);
visitor.visit_ty(f.decl.output, cx, visitor); (visitor.visit_ty)(f.decl.output, cx, visitor);
} }
} }
@ -725,10 +727,10 @@ fn determine_rp_in_ty(ty: @ast::Ty,
// mutability is invariant // mutability is invariant
if mt.mutbl == ast::m_mutbl { if mt.mutbl == ast::m_mutbl {
do cx.with_ambient_variance(rv_invariant) { do cx.with_ambient_variance(rv_invariant) {
visitor.visit_ty(mt.ty, cx, visitor); (visitor.visit_ty)(mt.ty, cx, visitor);
} }
} else { } else {
visitor.visit_ty(mt.ty, cx, visitor); (visitor.visit_ty)(mt.ty, cx, visitor);
} }
} }
} }

View file

@ -1039,7 +1039,7 @@ fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
-> block { -> block {
let s = if cx.ccx.sess.opts.save_temps || cx.ccx.sess.opts.debuginfo { let s = if cx.ccx.sess.opts.save_temps || cx.ccx.sess.opts.debuginfo {
cx.ccx.names(name) (cx.ccx.names)(name)
} else { special_idents::invalid }; } else { special_idents::invalid };
let llbb: BasicBlockRef = str::as_c_str(cx.ccx.sess.str_of(s), |buf| { let llbb: BasicBlockRef = str::as_c_str(cx.ccx.sess.str_of(s), |buf| {
llvm::LLVMAppendBasicBlock(cx.llfn, buf) llvm::LLVMAppendBasicBlock(cx.llfn, buf)
@ -2067,7 +2067,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id,
None if substs.is_none() => { None if substs.is_none() => {
let s = mangle_exported_name( let s = mangle_exported_name(
ccx, ccx,
vec::append(path, ~[path_name(ccx.names(~"dtor"))]), vec::append(path, ~[path_name((ccx.names)(~"dtor"))]),
t); t);
ccx.item_symbols.insert(id, s); ccx.item_symbols.insert(id, s);
s s
@ -2081,7 +2081,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id,
mangle_exported_name( mangle_exported_name(
ccx, ccx,
vec::append(path, vec::append(path,
~[path_name(ccx.names(~"dtor"))]), ~[path_name((ccx.names)(~"dtor"))]),
mono_ty) mono_ty)
} }
None => { None => {
@ -2253,7 +2253,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
fn register_method(ccx: @crate_ctxt, id: ast::node_id, pth: @ast_map::path, fn register_method(ccx: @crate_ctxt, id: ast::node_id, pth: @ast_map::path,
m: @ast::method) -> ValueRef { m: @ast::method) -> ValueRef {
let mty = ty::node_id_to_type(ccx.tcx, id); let mty = ty::node_id_to_type(ccx.tcx, id);
let pth = vec::append(*pth, ~[path_name(ccx.names(~"meth")), let pth = vec::append(*pth, ~[path_name((ccx.names)(~"meth")),
path_name(m.ident)]); path_name(m.ident)]);
let llfn = register_fn_full(ccx, m.span, pth, id, mty); let llfn = register_fn_full(ccx, m.span, pth, id, mty);
set_inline_hint_if_appr(m.attrs, llfn); set_inline_hint_if_appr(m.attrs, llfn);

View file

@ -1049,7 +1049,7 @@ fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef {
llvm::LLVMConstString(buf, str::len(s) as c_uint, False) llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
}; };
let g = let g =
str::as_c_str(fmt!("str%u", cx.names(~"str").repr), str::as_c_str(fmt!("str%u", (cx.names)(~"str").repr),
|buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)); |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf));
llvm::LLVMSetInitializer(g, sc); llvm::LLVMSetInitializer(g, sc);
llvm::LLVMSetGlobalConstant(g, True); llvm::LLVMSetGlobalConstant(g, True);
@ -1111,7 +1111,7 @@ fn C_bytes_plus_null(bytes: ~[u8]) -> ValueRef unsafe {
fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef { fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef {
let llshape = C_bytes_plus_null(bytes); let llshape = C_bytes_plus_null(bytes);
let name = fmt!("shape%u", ccx.names(~"shape").repr); let name = fmt!("shape%u", (ccx.names)(~"shape").repr);
let llglobal = str::as_c_str(name, |buf| { let llglobal = str::as_c_str(name, |buf| {
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf)
}); });

View file

@ -395,7 +395,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field],
let file_node = create_file(cx, fname); let file_node = create_file(cx, fname);
let scx = create_structure(file_node, let scx = create_structure(file_node,
cx.sess.str_of( cx.sess.str_of(
cx.dbg_cx.get().names(~"rec")), (cx.dbg_cx.get().names)(~"rec")),
line_from_span(cx.sess.codemap, line_from_span(cx.sess.codemap,
span) as int); span) as int);
for fields.each |field| { for fields.each |field| {
@ -747,10 +747,10 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
ast_map::node_expr(expr) => { ast_map::node_expr(expr) => {
match expr.node { match expr.node {
ast::expr_fn(_, decl, _, _) => { ast::expr_fn(_, decl, _, _) => {
(dbg_cx.names(~"fn"), decl.output, expr.id) ((dbg_cx.names)(~"fn"), decl.output, expr.id)
} }
ast::expr_fn_block(decl, _, _) => { ast::expr_fn_block(decl, _, _) => {
(dbg_cx.names(~"fn"), decl.output, expr.id) ((dbg_cx.names)(~"fn"), decl.output, expr.id)
} }
_ => fcx.ccx.sess.span_bug(expr.span, _ => fcx.ccx.sess.span_bug(expr.span,
~"create_function: \ ~"create_function: \

View file

@ -605,7 +605,7 @@ fn declare_tydesc_addrspace(ccx: @crate_ctxt, t: ty::t) -> addrspace {
// already correctly tagged with addrspaces. // already correctly tagged with addrspaces.
return default_addrspace; return default_addrspace;
} else { } else {
return ccx.next_addrspace(); return (ccx.next_addrspace)();
} }
} }

View file

@ -607,7 +607,8 @@ fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin)
fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef { fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
let _icx = ccx.insn_ctxt("impl::make_vtable"); let _icx = ccx.insn_ctxt("impl::make_vtable");
let tbl = C_struct(ptrs); let tbl = C_struct(ptrs);
let vt_gvar = str::as_c_str(ccx.sess.str_of(ccx.names(~"vtable")), |buf| { let vt_gvar =
str::as_c_str(ccx.sess.str_of((ccx.names)(~"vtable")), |buf| {
llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf) llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl), buf)
}); });
llvm::LLVMSetInitializer(vt_gvar, tbl); llvm::LLVMSetInitializer(vt_gvar, tbl);

View file

@ -125,7 +125,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
ccx.monomorphizing.insert(fn_id, depth + 1); ccx.monomorphizing.insert(fn_id, depth + 1);
let pt = vec::append(*pt, let pt = vec::append(*pt,
~[path_name(ccx.names(ccx.sess.str_of(name)))]); ~[path_name((ccx.names)(ccx.sess.str_of(name)))]);
let s = mangle_exported_name(ccx, pt, mono_ty); let s = mangle_exported_name(ccx, pt, mono_ty);
let mk_lldecl = || { let mk_lldecl = || {

View file

@ -142,7 +142,7 @@ fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt<ctx>) {
None => { /* do nothing -- but should we fail here? */ } None => { /* do nothing -- but should we fail here? */ }
} }
for p.types.each |t| { for p.types.each |t| {
v.visit_ty(*t, cx, v); (v.visit_ty)(*t, cx, v);
} }
} }
_ => visit::visit_ty(ty, cx, v) _ => visit::visit_ty(ty, cx, v)

View file

@ -297,5 +297,5 @@ fn handle_body(cx: ctx, body: blk) {
visit_item: |_i, _cx, _v| { }, visit_item: |_i, _cx, _v| { },
..*visit::default_visitor() ..*visit::default_visitor()
}); });
v.visit_block(body, cx, v); (v.visit_block)(body, cx, v);
} }

View file

@ -415,7 +415,7 @@ fn check_fn(ccx: @crate_ctxt,
visit_block: visit_block, visit_block: visit_block,
.. *visit::default_visitor()}); .. *visit::default_visitor()});
visit.visit_block(body, (), visit); (visit.visit_block)(body, (), visit);
} }
} }

View file

@ -90,7 +90,7 @@ impl @rcx {
fn regionck_expr(fcx: @fn_ctxt, e: @ast::expr) { fn regionck_expr(fcx: @fn_ctxt, e: @ast::expr) {
let rcx = rcx_({fcx:fcx, mut errors_reported: 0}); let rcx = rcx_({fcx:fcx, mut errors_reported: 0});
let v = regionck_visitor(); let v = regionck_visitor();
v.visit_expr(e, @(move rcx), v); (v.visit_expr)(e, @(move rcx), v);
fcx.infcx().resolve_regions(); fcx.infcx().resolve_regions();
} }
@ -99,7 +99,7 @@ fn regionck_fn(fcx: @fn_ctxt,
blk: ast::blk) { blk: ast::blk) {
let rcx = rcx_({fcx:fcx, mut errors_reported: 0}); let rcx = rcx_({fcx:fcx, mut errors_reported: 0});
let v = regionck_visitor(); let v = regionck_visitor();
v.visit_block(blk, @(move rcx), v); (v.visit_block)(blk, @(move rcx), v);
fcx.infcx().resolve_regions(); fcx.infcx().resolve_regions();
} }
@ -132,7 +132,7 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
// ref pattern, the variable is created with a suitable lower // ref pattern, the variable is created with a suitable lower
// bound. // bound.
let e = rcx.errors_reported; let e = rcx.errors_reported;
v.visit_pat(l.node.pat, rcx, v); (v.visit_pat)(l.node.pat, rcx, v);
let def_map = rcx.fcx.ccx.tcx.def_map; let def_map = rcx.fcx.ccx.tcx.def_map;
do pat_bindings(def_map, l.node.pat) |_bm, id, sp, _path| { do pat_bindings(def_map, l.node.pat) |_bm, id, sp, _path| {
visit_node(id, sp, rcx); visit_node(id, sp, rcx);
@ -141,9 +141,9 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
return; // if decl has errors, skip initializer expr return; // if decl has errors, skip initializer expr
} }
v.visit_ty(l.node.ty, rcx, v); (v.visit_ty)(l.node.ty, rcx, v);
for l.node.init.each |i| { for l.node.init.each |i| {
v.visit_expr(*i, rcx, v); (v.visit_expr)(*i, rcx, v);
} }
} }

View file

@ -217,7 +217,7 @@ fn mk_visitor() -> visit::vt<wb_ctxt> {
fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
let wbcx = {fcx: fcx, mut success: true}; let wbcx = {fcx: fcx, mut success: true};
let visit = mk_visitor(); let visit = mk_visitor();
visit.visit_expr(e, wbcx, visit); (visit.visit_expr)(e, wbcx, visit);
return wbcx.success; return wbcx.success;
} }
@ -227,7 +227,7 @@ fn resolve_type_vars_in_fn(fcx: @fn_ctxt,
self_info: Option<self_info>) -> bool { self_info: Option<self_info>) -> bool {
let wbcx = {fcx: fcx, mut success: true}; let wbcx = {fcx: fcx, mut success: true};
let visit = mk_visitor(); let visit = mk_visitor();
visit.visit_block(blk, wbcx, visit); (visit.visit_block)(blk, wbcx, visit);
for self_info.each |self_info| { for self_info.each |self_info| {
if self_info.explicit_self.node == ast::sty_static { break; } if self_info.explicit_self.node == ast::sty_static { break; }
resolve_type_vars_for_node(wbcx, self_info.explicit_self.span, resolve_type_vars_for_node(wbcx, self_info.explicit_self.span,

View file

@ -31,7 +31,7 @@ fn run(
fold_impl: fold_impl, fold_impl: fold_impl,
.. *fold::default_any_fold(srv) .. *fold::default_any_fold(srv)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_crate( fn fold_crate(

View file

@ -24,7 +24,7 @@ fn run(
fold_impl: fold_impl, fold_impl: fold_impl,
.. *fold::default_any_fold(()) .. *fold::default_any_fold(())
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc { fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {

View file

@ -144,7 +144,7 @@ pub fn default_seq_fold_doc<T>(fold: &Fold<T>, +doc: doc::Doc) -> doc::Doc {
pages: do vec::map(doc.pages) |page| { pages: do vec::map(doc.pages) |page| {
match *page { match *page {
doc::CratePage(doc) => { doc::CratePage(doc) => {
doc::CratePage(fold.fold_crate(fold, doc)) doc::CratePage((fold.fold_crate)(fold, doc))
} }
doc::ItemPage(doc) => { doc::ItemPage(doc) => {
doc::ItemPage(fold_ItemTag(fold, doc)) doc::ItemPage(fold_ItemTag(fold, doc))
@ -160,7 +160,7 @@ pub fn default_seq_fold_crate<T>(
+doc: doc::CrateDoc +doc: doc::CrateDoc
) -> doc::CrateDoc { ) -> doc::CrateDoc {
{ {
topmod: fold.fold_mod(fold, doc.topmod) topmod: (fold.fold_mod)(fold, doc.topmod)
} }
} }
@ -177,7 +177,7 @@ pub fn default_any_fold_mod<T:Send Clone>(
) -> doc::ModDoc { ) -> doc::ModDoc {
let fold_copy = fold.clone(); let fold_copy = fold.clone();
doc::ModDoc_({ doc::ModDoc_({
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
items: par::map(doc.items, |ItemTag, move fold_copy| { items: par::map(doc.items, |ItemTag, move fold_copy| {
fold_ItemTag(&fold_copy, *ItemTag) fold_ItemTag(&fold_copy, *ItemTag)
}), }),
@ -190,7 +190,7 @@ pub fn default_seq_fold_mod<T>(
+doc: doc::ModDoc +doc: doc::ModDoc
) -> doc::ModDoc { ) -> doc::ModDoc {
doc::ModDoc_({ doc::ModDoc_({
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
items: vec::map(doc.items, |ItemTag| { items: vec::map(doc.items, |ItemTag| {
fold_ItemTag(fold, *ItemTag) fold_ItemTag(fold, *ItemTag)
}), }),
@ -204,7 +204,7 @@ pub fn default_par_fold_mod<T:Send Clone>(
) -> doc::ModDoc { ) -> doc::ModDoc {
let fold_copy = fold.clone(); let fold_copy = fold.clone();
doc::ModDoc_({ doc::ModDoc_({
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
items: par::map(doc.items, |ItemTag, move fold_copy| { items: par::map(doc.items, |ItemTag, move fold_copy| {
fold_ItemTag(&fold_copy, *ItemTag) fold_ItemTag(&fold_copy, *ItemTag)
}), }),
@ -218,9 +218,9 @@ pub fn default_any_fold_nmod<T:Send Clone>(
) -> doc::NmodDoc { ) -> doc::NmodDoc {
let fold_copy = fold.clone(); let fold_copy = fold.clone();
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
fns: par::map(doc.fns, |FnDoc, move fold_copy| { fns: par::map(doc.fns, |FnDoc, move fold_copy| {
fold_copy.fold_fn(&fold_copy, *FnDoc) (fold_copy.fold_fn)(&fold_copy, *FnDoc)
}), }),
.. doc .. doc
} }
@ -231,9 +231,9 @@ pub fn default_seq_fold_nmod<T>(
+doc: doc::NmodDoc +doc: doc::NmodDoc
) -> doc::NmodDoc { ) -> doc::NmodDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
fns: vec::map(doc.fns, |FnDoc| { fns: vec::map(doc.fns, |FnDoc| {
fold.fold_fn(fold, *FnDoc) (fold.fold_fn)(fold, *FnDoc)
}), }),
.. doc .. doc
} }
@ -245,9 +245,9 @@ pub fn default_par_fold_nmod<T:Send Clone>(
) -> doc::NmodDoc { ) -> doc::NmodDoc {
let fold_copy = fold.clone(); let fold_copy = fold.clone();
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
fns: par::map(doc.fns, |FnDoc, move fold_copy| { fns: par::map(doc.fns, |FnDoc, move fold_copy| {
fold_copy.fold_fn(&fold_copy, *FnDoc) (fold_copy.fold_fn)(&fold_copy, *FnDoc)
}), }),
.. doc .. doc
} }
@ -256,31 +256,31 @@ pub fn default_par_fold_nmod<T:Send Clone>(
pub fn fold_ItemTag<T>(fold: &Fold<T>, +doc: doc::ItemTag) -> doc::ItemTag { pub fn fold_ItemTag<T>(fold: &Fold<T>, +doc: doc::ItemTag) -> doc::ItemTag {
match doc { match doc {
doc::ModTag(ModDoc) => { doc::ModTag(ModDoc) => {
doc::ModTag(fold.fold_mod(fold, ModDoc)) doc::ModTag((fold.fold_mod)(fold, ModDoc))
} }
doc::NmodTag(nModDoc) => { doc::NmodTag(nModDoc) => {
doc::NmodTag(fold.fold_nmod(fold, nModDoc)) doc::NmodTag((fold.fold_nmod)(fold, nModDoc))
} }
doc::FnTag(FnDoc) => { doc::FnTag(FnDoc) => {
doc::FnTag(fold.fold_fn(fold, FnDoc)) doc::FnTag((fold.fold_fn)(fold, FnDoc))
} }
doc::ConstTag(ConstDoc) => { doc::ConstTag(ConstDoc) => {
doc::ConstTag(fold.fold_const(fold, ConstDoc)) doc::ConstTag((fold.fold_const)(fold, ConstDoc))
} }
doc::EnumTag(EnumDoc) => { doc::EnumTag(EnumDoc) => {
doc::EnumTag(fold.fold_enum(fold, EnumDoc)) doc::EnumTag((fold.fold_enum)(fold, EnumDoc))
} }
doc::TraitTag(TraitDoc) => { doc::TraitTag(TraitDoc) => {
doc::TraitTag(fold.fold_trait(fold, TraitDoc)) doc::TraitTag((fold.fold_trait)(fold, TraitDoc))
} }
doc::ImplTag(ImplDoc) => { doc::ImplTag(ImplDoc) => {
doc::ImplTag(fold.fold_impl(fold, ImplDoc)) doc::ImplTag((fold.fold_impl)(fold, ImplDoc))
} }
doc::TyTag(TyDoc) => { doc::TyTag(TyDoc) => {
doc::TyTag(fold.fold_type(fold, TyDoc)) doc::TyTag((fold.fold_type)(fold, TyDoc))
} }
doc::StructTag(StructDoc) => { doc::StructTag(StructDoc) => {
doc::StructTag(fold.fold_struct(fold, StructDoc)) doc::StructTag((fold.fold_struct)(fold, StructDoc))
} }
} }
} }
@ -290,7 +290,7 @@ pub fn default_seq_fold_fn<T>(
+doc: doc::FnDoc +doc: doc::FnDoc
) -> doc::FnDoc { ) -> doc::FnDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -300,7 +300,7 @@ pub fn default_seq_fold_const<T>(
+doc: doc::ConstDoc +doc: doc::ConstDoc
) -> doc::ConstDoc { ) -> doc::ConstDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -310,7 +310,7 @@ pub fn default_seq_fold_enum<T>(
+doc: doc::EnumDoc +doc: doc::EnumDoc
) -> doc::EnumDoc { ) -> doc::EnumDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -320,7 +320,7 @@ pub fn default_seq_fold_trait<T>(
+doc: doc::TraitDoc +doc: doc::TraitDoc
) -> doc::TraitDoc { ) -> doc::TraitDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -330,7 +330,7 @@ pub fn default_seq_fold_impl<T>(
+doc: doc::ImplDoc +doc: doc::ImplDoc
) -> doc::ImplDoc { ) -> doc::ImplDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -340,7 +340,7 @@ pub fn default_seq_fold_type<T>(
+doc: doc::TyDoc +doc: doc::TyDoc
) -> doc::TyDoc { ) -> doc::TyDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -350,7 +350,7 @@ pub fn default_seq_fold_struct<T>(
+doc: doc::StructDoc +doc: doc::StructDoc
) -> doc::StructDoc { ) -> doc::StructDoc {
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }
@ -361,7 +361,7 @@ fn default_fold_should_produce_same_doc() {
let ast = parse::from_str(source); let ast = parse::from_str(source);
let doc = extract::extract(ast, ~""); let doc = extract::extract(ast, ~"");
let fld = default_seq_fold(()); let fld = default_seq_fold(());
let folded = fld.fold_doc(&fld, doc); let folded = (fld.fold_doc)(&fld, doc);
assert doc == folded; assert doc == folded;
} }
@ -371,7 +371,7 @@ fn default_fold_should_produce_same_consts() {
let ast = parse::from_str(source); let ast = parse::from_str(source);
let doc = extract::extract(ast, ~""); let doc = extract::extract(ast, ~"");
let fld = default_seq_fold(()); let fld = default_seq_fold(());
let folded = fld.fold_doc(&fld, doc); let folded = (fld.fold_doc)(&fld, doc);
assert doc == folded; assert doc == folded;
} }
@ -381,7 +381,7 @@ fn default_fold_should_produce_same_enums() {
let ast = parse::from_str(source); let ast = parse::from_str(source);
let doc = extract::extract(ast, ~""); let doc = extract::extract(ast, ~"");
let fld = default_seq_fold(()); let fld = default_seq_fold(());
let folded = fld.fold_doc(&fld, doc); let folded = (fld.fold_doc)(&fld, doc);
assert doc == folded; assert doc == folded;
} }
@ -391,6 +391,6 @@ fn default_parallel_fold_should_produce_same_doc() {
let ast = parse::from_str(source); let ast = parse::from_str(source);
let doc = extract::extract(ast, ~""); let doc = extract::extract(ast, ~"");
let fld = default_par_fold(()); let fld = default_par_fold(());
let folded = fld.fold_doc(&fld, doc); let folded = (fld.fold_doc)(&fld, doc);
assert doc == folded; assert doc == folded;
} }

View file

@ -21,7 +21,7 @@ fn run(
fold_nmod: fold_nmod, fold_nmod: fold_nmod,
.. *fold::default_any_fold(config) .. *fold::default_any_fold(config)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_mod( fn fold_mod(

View file

@ -38,9 +38,9 @@ fn run(
// Sort the items so mods come last. All mods will be // Sort the items so mods come last. All mods will be
// output at the same header level so sorting mods last // output at the same header level so sorting mods last
// makes the headers come out nested correctly. // makes the headers come out nested correctly.
let sorted_doc = sort_pass::mk_pass( let sorted_doc = (sort_pass::mk_pass(
~"mods last", mods_last ~"mods last", mods_last
).f(srv, doc); ).f)(srv, doc);
write_markdown(sorted_doc, move writer_factory); write_markdown(sorted_doc, move writer_factory);

View file

@ -64,7 +64,7 @@ fn find_pages(doc: doc::Doc, page_chan: PageChan) {
fold_nmod: fold_nmod, fold_nmod: fold_nmod,
.. *fold::default_any_fold(NominalOp { op: page_chan }) .. *fold::default_any_fold(NominalOp { op: page_chan })
}); });
fold.fold_doc(&fold, doc); (fold.fold_doc)(&fold, doc);
comm::send(page_chan, None); comm::send(page_chan, None);
} }

View file

@ -15,7 +15,7 @@ pub fn run_passes(
passno += 1; passno += 1;
log(debug, doc); log(debug, doc);
do time(pass.name) { do time(pass.name) {
pass.f(srv, doc) (pass.f)(srv, doc)
} }
} }
} }

View file

@ -31,7 +31,7 @@ fn run(srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
fold_nmod: fold_nmod, fold_nmod: fold_nmod,
.. *fold::default_any_fold(move ctxt) .. *fold::default_any_fold(move ctxt)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_item(fold: &fold::Fold<Ctxt>, +doc: doc::ItemDoc) -> doc::ItemDoc { fn fold_item(fold: &fold::Fold<Ctxt>, +doc: doc::ItemDoc) -> doc::ItemDoc {
@ -50,7 +50,7 @@ fn fold_mod(fold: &fold::Fold<Ctxt>, +doc: doc::ModDoc) -> doc::ModDoc {
if !is_topmod { fold.ctxt.path.pop(); } if !is_topmod { fold.ctxt.path.pop(); }
doc::ModDoc_({ doc::ModDoc_({
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. *doc .. *doc
}) })
} }
@ -61,7 +61,7 @@ fn fold_nmod(fold: &fold::Fold<Ctxt>, +doc: doc::NmodDoc) -> doc::NmodDoc {
fold.ctxt.path.pop(); fold.ctxt.path.pop();
{ {
item: fold.fold_item(fold, doc.item), item: (fold.fold_item)(fold, doc.item),
.. doc .. doc
} }
} }

View file

@ -15,7 +15,7 @@ fn run(srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
fold_mod: fold_mod, fold_mod: fold_mod,
.. *fold::default_any_fold(srv) .. *fold::default_any_fold(srv)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_mod( fn fold_mod(

View file

@ -16,7 +16,7 @@ fn run(srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
fold_mod: fold_mod, fold_mod: fold_mod,
.. *fold::default_any_fold(srv) .. *fold::default_any_fold(srv)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_mod( fn fold_mod(

View file

@ -16,7 +16,7 @@ fn run(_srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
fold_impl: fold_impl, fold_impl: fold_impl,
.. *fold::default_any_fold(()) .. *fold::default_any_fold(())
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc { fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {

View file

@ -27,7 +27,7 @@ fn run(
fold_mod: fold_mod, fold_mod: fold_mod,
.. *fold::default_any_fold(move lteq) .. *fold::default_any_fold(move lteq)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]

View file

@ -30,11 +30,11 @@ fn run(
fold_impl: fold_impl, fold_impl: fold_impl,
.. *fold::default_any_fold(move op) .. *fold::default_any_fold(move op)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn maybe_apply_op(op: NominalOp<Op>, s: Option<~str>) -> Option<~str> { fn maybe_apply_op(op: NominalOp<Op>, s: Option<~str>) -> Option<~str> {
s.map(|s| op.op(*s) ) s.map(|s| (op.op)(*s) )
} }
fn fold_item( fn fold_item(
@ -56,8 +56,8 @@ fn apply_to_sections(
sections: ~[doc::Section] sections: ~[doc::Section]
) -> ~[doc::Section] { ) -> ~[doc::Section] {
par::map(sections, |section, copy op| { par::map(sections, |section, copy op| {
header: op.op(section.header), header: (op.op)(section.header),
body: op.op(section.body) body: (op.op)(section.body)
}) })
} }

View file

@ -28,7 +28,7 @@ fn run(
fold_struct: fold_struct, fold_struct: fold_struct,
.. *fold::default_any_fold(srv) .. *fold::default_any_fold(srv)
}); });
fold.fold_doc(&fold, doc) (fold.fold_doc)(&fold, doc)
} }
fn fold_fn( fn fold_fn(

View file

@ -1059,7 +1059,7 @@ extern fn tcp_lfc_on_connection_cb(handle: *uv::ll::uv_tcp_t,
let kill_ch = (*server_data_ptr).kill_ch; let kill_ch = (*server_data_ptr).kill_ch;
if (*server_data_ptr).active { if (*server_data_ptr).active {
match status { match status {
0i32 => (*server_data_ptr).on_connect_cb(handle), 0i32 => ((*server_data_ptr).on_connect_cb)(handle),
_ => { _ => {
let loop_ptr = uv::ll::get_loop_for_uv_handle(handle); let loop_ptr = uv::ll::get_loop_for_uv_handle(handle);
core::comm::send(kill_ch, core::comm::send(kill_ch,

View file

@ -369,8 +369,8 @@ impl inlined_item: inlined_item_utils {
fn accept<E>(e: E, v: visit::vt<E>) { fn accept<E>(e: E, v: visit::vt<E>) {
match self { match self {
ii_item(i) => v.visit_item(i, e, v), ii_item(i) => (v.visit_item)(i, e, v),
ii_foreign(i) => v.visit_foreign_item(i, e, v), ii_foreign(i) => (v.visit_foreign_item)(i, e, v),
ii_method(_, m) => visit::visit_method_helper(m, e, v), ii_method(_, m) => visit::visit_method_helper(m, e, v),
ii_dtor(dtor, _, tps, parent_id) => { ii_dtor(dtor, _, tps, parent_id) => {
visit::visit_class_dtor_helper(dtor, tps, parent_id, e, v); visit::visit_class_dtor_helper(dtor, tps, parent_id, e, v);

View file

@ -74,11 +74,11 @@ impl codemap_t: span_handler {
impl handler_t: handler { impl handler_t: handler {
fn fatal(msg: &str) -> ! { fn fatal(msg: &str) -> ! {
self.emit(None, msg, fatal); (self.emit)(None, msg, fatal);
fail; fail;
} }
fn err(msg: &str) { fn err(msg: &str) {
self.emit(None, msg, error); (self.emit)(None, msg, error);
self.bump_err_count(); self.bump_err_count();
} }
fn bump_err_count() { fn bump_err_count() {
@ -98,17 +98,17 @@ impl handler_t: handler {
self.fatal(s); self.fatal(s);
} }
fn warn(msg: &str) { fn warn(msg: &str) {
self.emit(None, msg, warning); (self.emit)(None, msg, warning);
} }
fn note(msg: &str) { fn note(msg: &str) {
self.emit(None, msg, note); (self.emit)(None, msg, note);
} }
fn bug(msg: &str) -> ! { fn bug(msg: &str) -> ! {
self.fatal(ice_msg(msg)); self.fatal(ice_msg(msg));
} }
fn unimpl(msg: &str) -> ! { self.bug(~"unimplemented " + msg); } fn unimpl(msg: &str) -> ! { self.bug(~"unimplemented " + msg); }
fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) { fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) {
self.emit(cmsp, msg, lvl); (self.emit)(cmsp, msg, lvl);
} }
} }

View file

@ -235,7 +235,7 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
given '%s'", *extname, given '%s'", *extname,
*cx.parse_sess().interner.get(it.ident))); *cx.parse_sess().interner.get(it.ident)));
} }
(expand.expander(cx, it.span, tts), expand.span) ((expand.expander)(cx, it.span, tts), expand.span)
} }
Some(item_tt(expand)) => { Some(item_tt(expand)) => {
if it.ident == parse::token::special_idents::invalid { if it.ident == parse::token::special_idents::invalid {
@ -243,7 +243,7 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
fmt!("macro %s! expects an ident argument", fmt!("macro %s! expects an ident argument",
*extname)); *extname));
} }
(expand.expander(cx, it.span, it.ident, tts), expand.span) ((expand.expander)(cx, it.span, it.ident, tts), expand.span)
} }
_ => cx.span_fatal( _ => cx.span_fatal(
it.span, fmt!("%s! is not legal in item position", *extname)) it.span, fmt!("%s! is not legal in item position", *extname))

View file

@ -645,100 +645,100 @@ fn default_ast_fold() -> ast_fold_precursor {
impl ast_fold_precursor: ast_fold { impl ast_fold_precursor: ast_fold {
/* naturally, a macro to write these would be nice */ /* naturally, a macro to write these would be nice */
fn fold_crate(c: crate) -> crate { fn fold_crate(c: crate) -> crate {
let (n, s) = self.fold_crate(c.node, c.span, self as ast_fold); let (n, s) = (self.fold_crate)(c.node, c.span, self as ast_fold);
return {node: n, span: self.new_span(s)}; return {node: n, span: (self.new_span)(s)};
} }
fn fold_view_item(&&x: @view_item) -> fn fold_view_item(&&x: @view_item) ->
@view_item { @view_item {
return @{node: self.fold_view_item(x.node, self as ast_fold), return @{node: (self.fold_view_item)(x.node, self as ast_fold),
attrs: vec::map(x.attrs, |a| attrs: vec::map(x.attrs, |a|
fold_attribute_(*a, self as ast_fold)), fold_attribute_(*a, self as ast_fold)),
vis: x.vis, vis: x.vis,
span: self.new_span(x.span)}; span: (self.new_span)(x.span)};
} }
fn fold_foreign_item(&&x: @foreign_item) fn fold_foreign_item(&&x: @foreign_item)
-> @foreign_item { -> @foreign_item {
return self.fold_foreign_item(x, self as ast_fold); return (self.fold_foreign_item)(x, self as ast_fold);
} }
fn fold_item(&&i: @item) -> Option<@item> { fn fold_item(&&i: @item) -> Option<@item> {
return self.fold_item(i, self as ast_fold); return (self.fold_item)(i, self as ast_fold);
} }
fn fold_struct_field(&&sf: @struct_field) -> @struct_field { fn fold_struct_field(&&sf: @struct_field) -> @struct_field {
@{node: {kind: copy sf.node.kind, @{node: {kind: copy sf.node.kind,
id: sf.node.id, id: sf.node.id,
ty: (self as ast_fold).fold_ty(sf.node.ty)}, ty: (self as ast_fold).fold_ty(sf.node.ty)},
span: self.new_span(sf.span)} span: (self.new_span)(sf.span)}
} }
fn fold_item_underscore(i: item_) -> fn fold_item_underscore(i: item_) ->
item_ { item_ {
return self.fold_item_underscore(i, self as ast_fold); return (self.fold_item_underscore)(i, self as ast_fold);
} }
fn fold_method(&&x: @method) fn fold_method(&&x: @method)
-> @method { -> @method {
return self.fold_method(x, self as ast_fold); return (self.fold_method)(x, self as ast_fold);
} }
fn fold_block(x: blk) -> blk { fn fold_block(x: blk) -> blk {
let (n, s) = self.fold_block(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_block)(x.node, x.span, self as ast_fold);
return {node: n, span: self.new_span(s)}; return {node: n, span: (self.new_span)(s)};
} }
fn fold_stmt(&&x: @stmt) -> @stmt { fn fold_stmt(&&x: @stmt) -> @stmt {
let (n, s) = self.fold_stmt(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_stmt)(x.node, x.span, self as ast_fold);
return @{node: n, span: self.new_span(s)}; return @{node: n, span: (self.new_span)(s)};
} }
fn fold_arm(x: arm) -> arm { fn fold_arm(x: arm) -> arm {
return self.fold_arm(x, self as ast_fold); return (self.fold_arm)(x, self as ast_fold);
} }
fn fold_pat(&&x: @pat) -> @pat { fn fold_pat(&&x: @pat) -> @pat {
let (n, s) = self.fold_pat(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_pat)(x.node, x.span, self as ast_fold);
return @{id: self.new_id(x.id), return @{id: (self.new_id)(x.id),
node: n, node: n,
span: self.new_span(s)}; span: (self.new_span)(s)};
} }
fn fold_decl(&&x: @decl) -> @decl { fn fold_decl(&&x: @decl) -> @decl {
let (n, s) = self.fold_decl(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_decl)(x.node, x.span, self as ast_fold);
return @{node: n, span: self.new_span(s)}; return @{node: n, span: (self.new_span)(s)};
} }
fn fold_expr(&&x: @expr) -> @expr { fn fold_expr(&&x: @expr) -> @expr {
let (n, s) = self.fold_expr(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_expr)(x.node, x.span, self as ast_fold);
return @{id: self.new_id(x.id), return @{id: (self.new_id)(x.id),
callee_id: self.new_id(x.callee_id), callee_id: (self.new_id)(x.callee_id),
node: n, node: n,
span: self.new_span(s)}; span: (self.new_span)(s)};
} }
fn fold_ty(&&x: @Ty) -> @Ty { fn fold_ty(&&x: @Ty) -> @Ty {
let (n, s) = self.fold_ty(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_ty)(x.node, x.span, self as ast_fold);
return @{id: self.new_id(x.id), node: n, span: self.new_span(s)}; return @{id: (self.new_id)(x.id), node: n, span: (self.new_span)(s)};
} }
fn fold_mod(x: _mod) -> _mod { fn fold_mod(x: _mod) -> _mod {
return self.fold_mod(x, self as ast_fold); return (self.fold_mod)(x, self as ast_fold);
} }
fn fold_foreign_mod(x: foreign_mod) -> fn fold_foreign_mod(x: foreign_mod) ->
foreign_mod { foreign_mod {
return self.fold_foreign_mod(x, self as ast_fold); return (self.fold_foreign_mod)(x, self as ast_fold);
} }
fn fold_variant(x: variant) -> fn fold_variant(x: variant) ->
variant { variant {
let (n, s) = self.fold_variant(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_variant)(x.node, x.span, self as ast_fold);
return {node: n, span: self.new_span(s)}; return {node: n, span: (self.new_span)(s)};
} }
fn fold_ident(&&x: ident) -> ident { fn fold_ident(&&x: ident) -> ident {
return self.fold_ident(x, self as ast_fold); return (self.fold_ident)(x, self as ast_fold);
} }
fn fold_path(&&x: @path) -> @path { fn fold_path(&&x: @path) -> @path {
@self.fold_path(*x, self as ast_fold) @(self.fold_path)(*x, self as ast_fold)
} }
fn fold_local(&&x: @local) -> @local { fn fold_local(&&x: @local) -> @local {
let (n, s) = self.fold_local(x.node, x.span, self as ast_fold); let (n, s) = (self.fold_local)(x.node, x.span, self as ast_fold);
return @{node: n, span: self.new_span(s)}; return @{node: n, span: (self.new_span)(s)};
} }
fn map_exprs(f: fn@(&&v: @expr) -> @expr, e: ~[@expr]) -> ~[@expr] { fn map_exprs(f: fn@(&&v: @expr) -> @expr, e: ~[@expr]) -> ~[@expr] {
self.map_exprs(f, e) (self.map_exprs)(f, e)
} }
fn new_id(node_id: ast::node_id) -> node_id { fn new_id(node_id: ast::node_id) -> node_id {
self.new_id(node_id) (self.new_id)(node_id)
} }
fn new_span(span: span) -> span { fn new_span(span: span) -> span {
self.new_span(span) (self.new_span)(span)
} }
} }

View file

@ -453,7 +453,7 @@ fn print_item(s: ps, &&item: @ast::item) {
maybe_print_comment(s, item.span.lo); maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs); print_outer_attributes(s, item.attrs);
let ann_node = node_item(s, item); let ann_node = node_item(s, item);
s.ann.pre(ann_node); (s.ann.pre)(ann_node);
match item.node { match item.node {
ast::item_const(ty, expr) => { ast::item_const(ty, expr) => {
head(s, visibility_qualified(item.vis, ~"const")); head(s, visibility_qualified(item.vis, ~"const"));
@ -581,7 +581,7 @@ fn print_item(s: ps, &&item: @ast::item) {
fail ~"invalid item-position syntax bit" fail ~"invalid item-position syntax bit"
} }
} }
s.ann.post(ann_node); (s.ann.post)(ann_node);
} }
fn print_enum_def(s: ps, enum_definition: ast::enum_def, fn print_enum_def(s: ps, enum_definition: ast::enum_def,
@ -928,7 +928,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
} }
maybe_print_comment(s, blk.span.lo); maybe_print_comment(s, blk.span.lo);
let ann_node = node_block(s, blk); let ann_node = node_block(s, blk);
s.ann.pre(ann_node); (s.ann.pre)(ann_node);
match embedded { match embedded {
block_block_fn => end(s), block_block_fn => end(s),
block_normal => bopen(s) block_normal => bopen(s)
@ -949,7 +949,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
_ => () _ => ()
} }
bclose_maybe_open(s, blk.span, indented, close_box); bclose_maybe_open(s, blk.span, indented, close_box);
s.ann.post(ann_node); (s.ann.post)(ann_node);
} }
fn print_if(s: ps, test: @ast::expr, blk: ast::blk, fn print_if(s: ps, test: @ast::expr, blk: ast::blk,
@ -1055,7 +1055,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
maybe_print_comment(s, expr.span.lo); maybe_print_comment(s, expr.span.lo);
ibox(s, indent_unit); ibox(s, indent_unit);
let ann_node = node_expr(s, expr); let ann_node = node_expr(s, expr);
s.ann.pre(ann_node); (s.ann.pre)(ann_node);
match expr.node { match expr.node {
ast::expr_vstore(e, v) => match v { ast::expr_vstore(e, v) => match v {
ast::expr_vstore_fixed(_) => { ast::expr_vstore_fixed(_) => {
@ -1415,7 +1415,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
pclose(s); pclose(s);
} }
} }
s.ann.post(ann_node); (s.ann.post)(ann_node);
end(s); end(s);
} }
@ -1500,7 +1500,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) {
fn print_pat(s: ps, &&pat: @ast::pat) { fn print_pat(s: ps, &&pat: @ast::pat) {
maybe_print_comment(s, pat.span.lo); maybe_print_comment(s, pat.span.lo);
let ann_node = node_pat(s, pat); let ann_node = node_pat(s, pat);
s.ann.pre(ann_node); (s.ann.pre)(ann_node);
/* Pat isn't normalized, but the beauty of it /* Pat isn't normalized, but the beauty of it
is that it doesn't matter */ is that it doesn't matter */
match pat.node { match pat.node {
@ -1590,7 +1590,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
print_expr(s, end); print_expr(s, end);
} }
} }
s.ann.post(ann_node); (s.ann.post)(ann_node);
} }
// Returns whether it printed anything // Returns whether it printed anything

View file

@ -90,66 +90,69 @@ fn default_visitor<E>() -> visitor<E> {
} }
fn visit_crate<E>(c: crate, e: E, v: vt<E>) { fn visit_crate<E>(c: crate, e: E, v: vt<E>) {
v.visit_mod(c.node.module, c.span, crate_node_id, e, v); (v.visit_mod)(c.node.module, c.span, crate_node_id, e, v);
} }
fn visit_mod<E>(m: _mod, _sp: span, _id: node_id, e: E, v: vt<E>) { fn visit_mod<E>(m: _mod, _sp: span, _id: node_id, e: E, v: vt<E>) {
for m.view_items.each |vi| { v.visit_view_item(*vi, e, v); } for m.view_items.each |vi| { (v.visit_view_item)(*vi, e, v); }
for m.items.each |i| { v.visit_item(*i, e, v); } for m.items.each |i| { (v.visit_item)(*i, e, v); }
} }
fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { } fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { }
fn visit_local<E>(loc: @local, e: E, v: vt<E>) { fn visit_local<E>(loc: @local, e: E, v: vt<E>) {
v.visit_pat(loc.node.pat, e, v); (v.visit_pat)(loc.node.pat, e, v);
v.visit_ty(loc.node.ty, e, v); (v.visit_ty)(loc.node.ty, e, v);
match loc.node.init { match loc.node.init {
None => (), None => (),
Some(ex) => v.visit_expr(ex, e, v) Some(ex) => (v.visit_expr)(ex, e, v)
} }
} }
fn visit_item<E>(i: @item, e: E, v: vt<E>) { fn visit_item<E>(i: @item, e: E, v: vt<E>) {
match i.node { match i.node {
item_const(t, ex) => { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); } item_const(t, ex) => {
(v.visit_ty)(t, e, v);
(v.visit_expr)(ex, e, v);
}
item_fn(decl, purity, tp, body) => { item_fn(decl, purity, tp, body) => {
v.visit_fn(fk_item_fn(/* FIXME (#2543) */ copy i.ident, (v.visit_fn)(fk_item_fn(/* FIXME (#2543) */ copy i.ident,
/* FIXME (#2543) */ copy tp, /* FIXME (#2543) */ copy tp,
purity), decl, body, purity), decl, body,
i.span, i.id, e, v); i.span, i.id, e, v);
} }
item_mod(m) => v.visit_mod(m, i.span, i.id, e, v), item_mod(m) => (v.visit_mod)(m, i.span, i.id, e, v),
item_foreign_mod(nm) => { item_foreign_mod(nm) => {
for nm.view_items.each |vi| { v.visit_view_item(*vi, e, v); } for nm.view_items.each |vi| { (v.visit_view_item)(*vi, e, v); }
for nm.items.each |ni| { v.visit_foreign_item(*ni, e, v); } for nm.items.each |ni| { (v.visit_foreign_item)(*ni, e, v); }
} }
item_ty(t, tps) => { item_ty(t, tps) => {
v.visit_ty(t, e, v); (v.visit_ty)(t, e, v);
v.visit_ty_params(tps, e, v); (v.visit_ty_params)(tps, e, v);
} }
item_enum(enum_definition, tps) => { item_enum(enum_definition, tps) => {
v.visit_ty_params(tps, e, v); (v.visit_ty_params)(tps, e, v);
visit_enum_def(enum_definition, tps, e, v); visit_enum_def(enum_definition, tps, e, v);
} }
item_impl(tps, traits, ty, methods) => { item_impl(tps, traits, ty, methods) => {
v.visit_ty_params(tps, e, v); (v.visit_ty_params)(tps, e, v);
for traits.each |p| { for traits.each |p| {
visit_path(p.path, e, v); visit_path(p.path, e, v);
} }
v.visit_ty(ty, e, v); (v.visit_ty)(ty, e, v);
for methods.each |m| { for methods.each |m| {
visit_method_helper(*m, e, v) visit_method_helper(*m, e, v)
} }
} }
item_class(struct_def, tps) => { item_class(struct_def, tps) => {
v.visit_ty_params(tps, e, v); (v.visit_ty_params)(tps, e, v);
v.visit_struct_def(struct_def, i.ident, tps, i.id, e, v); (v.visit_struct_def)(struct_def, i.ident, tps, i.id, e, v);
} }
item_trait(tps, traits, methods) => { item_trait(tps, traits, methods) => {
v.visit_ty_params(tps, e, v); (v.visit_ty_params)(tps, e, v);
for traits.each |p| { visit_path(p.path, e, v); } for traits.each |p| { visit_path(p.path, e, v); }
for methods.each |m| { for methods.each |m| {
v.visit_trait_method(*m, e, v); (v.visit_trait_method)(*m, e, v);
} }
} }
item_mac(m) => visit_mac(m, e, v) item_mac(m) => visit_mac(m, e, v)
@ -161,10 +164,10 @@ fn visit_enum_def<E>(enum_definition: ast::enum_def, tps: ~[ast::ty_param],
for enum_definition.variants.each |vr| { for enum_definition.variants.each |vr| {
match vr.node.kind { match vr.node.kind {
tuple_variant_kind(variant_args) => { tuple_variant_kind(variant_args) => {
for variant_args.each |va| { v.visit_ty(va.ty, e, v); } for variant_args.each |va| { (v.visit_ty)(va.ty, e, v); }
} }
struct_variant_kind(struct_def) => { struct_variant_kind(struct_def) => {
v.visit_struct_def(struct_def, vr.node.name, tps, (v.visit_struct_def)(struct_def, vr.node.name, tps,
vr.node.id, e, v); vr.node.id, e, v);
} }
enum_variant_kind(enum_definition) => { enum_variant_kind(enum_definition) => {
@ -172,7 +175,7 @@ fn visit_enum_def<E>(enum_definition: ast::enum_def, tps: ~[ast::ty_param],
} }
} }
// Visit the disr expr if it exists // Visit the disr expr if it exists
vr.node.disr_expr.iter(|ex| v.visit_expr(*ex, e, v)); vr.node.disr_expr.iter(|ex| (v.visit_expr)(*ex, e, v));
} }
} }
@ -182,21 +185,21 @@ fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) {
match t.node { match t.node {
ty_box(mt) | ty_uniq(mt) | ty_box(mt) | ty_uniq(mt) |
ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => {
v.visit_ty(mt.ty, e, v); (v.visit_ty)(mt.ty, e, v);
} }
ty_rec(flds) => for flds.each |f| { ty_rec(flds) => for flds.each |f| {
v.visit_ty(f.node.mt.ty, e, v); (v.visit_ty)(f.node.mt.ty, e, v);
}, },
ty_tup(ts) => for ts.each |tt| { ty_tup(ts) => for ts.each |tt| {
v.visit_ty(*tt, e, v); (v.visit_ty)(*tt, e, v);
}, },
ty_fn(f) => { ty_fn(f) => {
for f.decl.inputs.each |a| { v.visit_ty(a.ty, e, v); } for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
visit_ty_param_bounds(f.bounds, e, v); visit_ty_param_bounds(f.bounds, e, v);
v.visit_ty(f.decl.output, e, v); (v.visit_ty)(f.decl.output, e, v);
} }
ty_path(p, _) => visit_path(p, e, v), ty_path(p, _) => visit_path(p, e, v),
ty_fixed_length_vec(mt, _) => v.visit_ty(mt.ty, e, v), ty_fixed_length_vec(mt, _) => (v.visit_ty)(mt.ty, e, v),
ty_nil | ty_nil |
ty_bot | ty_bot |
ty_mac(_) | ty_mac(_) |
@ -205,7 +208,7 @@ fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) {
} }
fn visit_path<E>(p: @path, e: E, v: vt<E>) { fn visit_path<E>(p: @path, e: E, v: vt<E>) {
for p.types.each |tp| { v.visit_ty(*tp, e, v); } for p.types.each |tp| { (v.visit_ty)(*tp, e, v); }
} }
fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
@ -213,28 +216,31 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
pat_enum(path, children) => { pat_enum(path, children) => {
visit_path(path, e, v); visit_path(path, e, v);
do option::iter(&children) |children| { do option::iter(&children) |children| {
for children.each |child| { v.visit_pat(*child, e, v); }} for children.each |child| { (v.visit_pat)(*child, e, v); }}
} }
pat_rec(fields, _) => for fields.each |f| { pat_rec(fields, _) => for fields.each |f| {
v.visit_pat(f.pat, e, v) (v.visit_pat)(f.pat, e, v)
}, },
pat_struct(path, fields, _) => { pat_struct(path, fields, _) => {
visit_path(path, e, v); visit_path(path, e, v);
for fields.each |f| { for fields.each |f| {
v.visit_pat(f.pat, e, v); (v.visit_pat)(f.pat, e, v);
} }
} }
pat_tup(elts) => for elts.each |elt| { pat_tup(elts) => for elts.each |elt| {
v.visit_pat(*elt, e, v) (v.visit_pat)(*elt, e, v)
}, },
pat_box(inner) | pat_uniq(inner) | pat_region(inner) => pat_box(inner) | pat_uniq(inner) | pat_region(inner) =>
v.visit_pat(inner, e, v), (v.visit_pat)(inner, e, v),
pat_ident(_, path, inner) => { pat_ident(_, path, inner) => {
visit_path(path, e, v); visit_path(path, e, v);
do option::iter(&inner) |subpat| { v.visit_pat(*subpat, e, v)}; do option::iter(&inner) |subpat| { (v.visit_pat)(*subpat, e, v)};
}
pat_lit(ex) => (v.visit_expr)(ex, e, v),
pat_range(e1, e2) => {
(v.visit_expr)(e1, e, v);
(v.visit_expr)(e2, e, v);
} }
pat_lit(ex) => v.visit_expr(ex, e, v),
pat_range(e1, e2) => { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); }
pat_wild => () pat_wild => ()
} }
} }
@ -242,18 +248,18 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) { fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
match ni.node { match ni.node {
foreign_item_fn(fd, _, tps) => { foreign_item_fn(fd, _, tps) => {
v.visit_ty_params(tps, e, v); (v.visit_ty_params)(tps, e, v);
visit_fn_decl(fd, e, v); visit_fn_decl(fd, e, v);
} }
foreign_item_const(t) => { foreign_item_const(t) => {
v.visit_ty(t, e, v); (v.visit_ty)(t, e, v);
} }
} }
} }
fn visit_ty_param_bounds<E>(bounds: @~[ty_param_bound], e: E, v: vt<E>) { fn visit_ty_param_bounds<E>(bounds: @~[ty_param_bound], e: E, v: vt<E>) {
for vec::each(*bounds) |bound| { for vec::each(*bounds) |bound| {
v.visit_ty(**bound, e, v) (v.visit_ty)(**bound, e, v)
} }
} }
@ -265,10 +271,10 @@ fn visit_ty_params<E>(tps: ~[ty_param], e: E, v: vt<E>) {
fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) { fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) {
for fd.inputs.each |a| { for fd.inputs.each |a| {
v.visit_pat(a.pat, e, v); (v.visit_pat)(a.pat, e, v);
v.visit_ty(a.ty, e, v); (v.visit_ty)(a.ty, e, v);
} }
v.visit_ty(fd.output, e, v); (v.visit_ty)(fd.output, e, v);
} }
// Note: there is no visit_method() method in the visitor, instead override // Note: there is no visit_method() method in the visitor, instead override
@ -276,14 +282,14 @@ fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) {
// because it is not a default impl of any method, though I doubt that really // because it is not a default impl of any method, though I doubt that really
// clarifies anything. - Niko // clarifies anything. - Niko
fn visit_method_helper<E>(m: @method, e: E, v: vt<E>) { fn visit_method_helper<E>(m: @method, e: E, v: vt<E>) {
v.visit_fn(fk_method(/* FIXME (#2543) */ copy m.ident, (v.visit_fn)(fk_method(/* FIXME (#2543) */ copy m.ident,
/* FIXME (#2543) */ copy m.tps, m), /* FIXME (#2543) */ copy m.tps, m),
m.decl, m.body, m.span, m.id, e, v); m.decl, m.body, m.span, m.id, e, v);
} }
fn visit_class_dtor_helper<E>(dtor: class_dtor, tps: ~[ty_param], fn visit_class_dtor_helper<E>(dtor: class_dtor, tps: ~[ty_param],
parent_id: def_id, e: E, v: vt<E>) { parent_id: def_id, e: E, v: vt<E>) {
v.visit_fn(fk_dtor(/* FIXME (#2543) */ copy tps, dtor.node.attrs, (v.visit_fn)(fk_dtor(/* FIXME (#2543) */ copy tps, dtor.node.attrs,
dtor.node.self_id, parent_id), ast_util::dtor_dec(), dtor.node.self_id, parent_id), ast_util::dtor_dec(),
dtor.node.body, dtor.span, dtor.node.id, e, v) dtor.node.body, dtor.span, dtor.node.id, e, v)
@ -292,19 +298,19 @@ fn visit_class_dtor_helper<E>(dtor: class_dtor, tps: ~[ty_param],
fn visit_fn<E>(fk: fn_kind, decl: fn_decl, body: blk, _sp: span, fn visit_fn<E>(fk: fn_kind, decl: fn_decl, body: blk, _sp: span,
_id: node_id, e: E, v: vt<E>) { _id: node_id, e: E, v: vt<E>) {
visit_fn_decl(decl, e, v); visit_fn_decl(decl, e, v);
v.visit_ty_params(tps_of_fn(fk), e, v); (v.visit_ty_params)(tps_of_fn(fk), e, v);
v.visit_block(body, e, v); (v.visit_block)(body, e, v);
} }
fn visit_ty_method<E>(m: ty_method, e: E, v: vt<E>) { fn visit_ty_method<E>(m: ty_method, e: E, v: vt<E>) {
for m.decl.inputs.each |a| { v.visit_ty(a.ty, e, v); } for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
v.visit_ty_params(m.tps, e, v); (v.visit_ty_params)(m.tps, e, v);
v.visit_ty(m.decl.output, e, v); (v.visit_ty)(m.decl.output, e, v);
} }
fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) { fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) {
match m { match m {
required(ty_m) => v.visit_ty_method(ty_m, e, v), required(ty_m) => (v.visit_ty_method)(ty_m, e, v),
provided(m) => visit_method_helper(m, e, v) provided(m) => visit_method_helper(m, e, v)
} }
} }
@ -312,10 +318,10 @@ fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) {
fn visit_struct_def<E>(sd: @struct_def, _nm: ast::ident, tps: ~[ty_param], fn visit_struct_def<E>(sd: @struct_def, _nm: ast::ident, tps: ~[ty_param],
id: node_id, e: E, v: vt<E>) { id: node_id, e: E, v: vt<E>) {
for sd.fields.each |f| { for sd.fields.each |f| {
v.visit_struct_field(*f, e, v); (v.visit_struct_field)(*f, e, v);
} }
for sd.methods.each |m| { for sd.methods.each |m| {
v.visit_struct_method(*m, e, v); (v.visit_struct_method)(*m, e, v);
} }
for sd.traits.each |p| { for sd.traits.each |p| {
visit_path(p.path, e, v); visit_path(p.path, e, v);
@ -326,7 +332,7 @@ fn visit_struct_def<E>(sd: @struct_def, _nm: ast::ident, tps: ~[ty_param],
} }
fn visit_struct_field<E>(sf: @struct_field, e: E, v: vt<E>) { fn visit_struct_field<E>(sf: @struct_field, e: E, v: vt<E>) {
v.visit_ty(sf.node.ty, e, v); (v.visit_ty)(sf.node.ty, e, v);
} }
fn visit_struct_method<E>(m: @method, e: E, v: vt<E>) { fn visit_struct_method<E>(m: @method, e: E, v: vt<E>) {
@ -335,19 +341,19 @@ fn visit_struct_method<E>(m: @method, e: E, v: vt<E>) {
fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) { fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) {
for b.node.view_items.each |vi| { for b.node.view_items.each |vi| {
v.visit_view_item(*vi, e, v); (v.visit_view_item)(*vi, e, v);
} }
for b.node.stmts.each |s| { for b.node.stmts.each |s| {
v.visit_stmt(*s, e, v); (v.visit_stmt)(*s, e, v);
} }
visit_expr_opt(b.node.expr, e, v); visit_expr_opt(b.node.expr, e, v);
} }
fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) { fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
match s.node { match s.node {
stmt_decl(d, _) => v.visit_decl(d, e, v), stmt_decl(d, _) => (v.visit_decl)(d, e, v),
stmt_expr(ex, _) => v.visit_expr(ex, e, v), stmt_expr(ex, _) => (v.visit_expr)(ex, e, v),
stmt_semi(ex, _) => v.visit_expr(ex, e, v), stmt_semi(ex, _) => (v.visit_expr)(ex, e, v),
stmt_mac(mac, _) => visit_mac(mac, e, v) stmt_mac(mac, _) => visit_mac(mac, e, v)
} }
} }
@ -355,24 +361,24 @@ fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { fn visit_decl<E>(d: @decl, e: E, v: vt<E>) {
match d.node { match d.node {
decl_local(locs) => for locs.each |loc| { decl_local(locs) => for locs.each |loc| {
v.visit_local(*loc, e, v) (v.visit_local)(*loc, e, v)
}, },
decl_item(it) => v.visit_item(it, e, v) decl_item(it) => (v.visit_item)(it, e, v)
} }
} }
fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) { fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) {
match eo { None => (), Some(ex) => v.visit_expr(ex, e, v) } match eo { None => (), Some(ex) => (v.visit_expr)(ex, e, v) }
} }
fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
for exprs.each |ex| { v.visit_expr(*ex, e, v); } for exprs.each |ex| { (v.visit_expr)(*ex, e, v); }
} }
fn visit_mac<E>(m: mac, e: E, v: vt<E>) { fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
match m.node { match m.node {
ast::mac_invoc(_, arg, _) => { ast::mac_invoc(_, arg, _) => {
option::map(&arg, |arg| v.visit_expr(*arg, e, v)); } option::map(&arg, |arg| (v.visit_expr)(*arg, e, v)); }
ast::mac_invoc_tt(*) => { /* no user-serviceable parts inside */ } ast::mac_invoc_tt(*) => { /* no user-serviceable parts inside */ }
ast::mac_ellipsis => (), ast::mac_ellipsis => (),
ast::mac_aq(*) => { /* FIXME: maybe visit (Issue #2340) */ } ast::mac_aq(*) => { /* FIXME: maybe visit (Issue #2340) */ }
@ -382,86 +388,95 @@ fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
match ex.node { match ex.node {
expr_vstore(x, _) => v.visit_expr(x, e, v), expr_vstore(x, _) => (v.visit_expr)(x, e, v),
expr_vec(es, _) => visit_exprs(es, e, v), expr_vec(es, _) => visit_exprs(es, e, v),
expr_repeat(element, count, _) => { expr_repeat(element, count, _) => {
v.visit_expr(element, e, v); (v.visit_expr)(element, e, v);
v.visit_expr(count, e, v); (v.visit_expr)(count, e, v);
} }
expr_rec(flds, base) => { expr_rec(flds, base) => {
for flds.each |f| { v.visit_expr(f.node.expr, e, v); } for flds.each |f| { (v.visit_expr)(f.node.expr, e, v); }
visit_expr_opt(base, e, v); visit_expr_opt(base, e, v);
} }
expr_struct(p, flds, base) => { expr_struct(p, flds, base) => {
visit_path(p, e, v); visit_path(p, e, v);
for flds.each |f| { v.visit_expr(f.node.expr, e, v); } for flds.each |f| { (v.visit_expr)(f.node.expr, e, v); }
visit_expr_opt(base, e, v); visit_expr_opt(base, e, v);
} }
expr_tup(elts) => for elts.each |el| { v.visit_expr(*el, e, v); }, expr_tup(elts) => for elts.each |el| { (v.visit_expr)(*el, e, v); },
expr_call(callee, args, _) => { expr_call(callee, args, _) => {
visit_exprs(args, e, v); visit_exprs(args, e, v);
v.visit_expr(callee, e, v); (v.visit_expr)(callee, e, v);
} }
expr_binary(_, a, b) => { expr_binary(_, a, b) => {
v.visit_expr(a, e, v); v.visit_expr(b, e, v); (v.visit_expr)(a, e, v); (v.visit_expr)(b, e, v);
} }
expr_addr_of(_, x) | expr_unary(_, x) | expr_addr_of(_, x) | expr_unary(_, x) |
expr_loop_body(x) | expr_do_body(x) | expr_loop_body(x) | expr_do_body(x) |
expr_assert(x) => v.visit_expr(x, e, v), expr_assert(x) => (v.visit_expr)(x, e, v),
expr_lit(_) => (), expr_lit(_) => (),
expr_cast(x, t) => { v.visit_expr(x, e, v); v.visit_ty(t, e, v); } expr_cast(x, t) => { (v.visit_expr)(x, e, v); (v.visit_ty)(t, e, v); }
expr_if(x, b, eo) => { expr_if(x, b, eo) => {
v.visit_expr(x, e, v); (v.visit_expr)(x, e, v);
v.visit_block(b, e, v); (v.visit_block)(b, e, v);
visit_expr_opt(eo, e, v); visit_expr_opt(eo, e, v);
} }
expr_while(x, b) => { v.visit_expr(x, e, v); v.visit_block(b, e, v); } expr_while(x, b) => {
expr_loop(b, _) => v.visit_block(b, e, v), (v.visit_expr)(x, e, v);
(v.visit_block)(b, e, v);
}
expr_loop(b, _) => (v.visit_block)(b, e, v),
expr_match(x, arms) => { expr_match(x, arms) => {
v.visit_expr(x, e, v); (v.visit_expr)(x, e, v);
for arms.each |a| { v.visit_arm(*a, e, v); } for arms.each |a| { (v.visit_arm)(*a, e, v); }
} }
expr_fn(proto, decl, body, cap_clause) => { expr_fn(proto, decl, body, cap_clause) => {
v.visit_fn(fk_anon(proto, cap_clause), decl, body, (v.visit_fn)(fk_anon(proto, cap_clause), decl, body,
ex.span, ex.id, e, v); ex.span, ex.id, e, v);
} }
expr_fn_block(decl, body, cap_clause) => { expr_fn_block(decl, body, cap_clause) => {
v.visit_fn(fk_fn_block(cap_clause), decl, body, (v.visit_fn)(fk_fn_block(cap_clause), decl, body,
ex.span, ex.id, e, v); ex.span, ex.id, e, v);
} }
expr_block(b) => v.visit_block(b, 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); } expr_assign(a, b) => {
expr_copy(a) => v.visit_expr(a, e, v), (v.visit_expr)(b, e, v);
expr_unary_move(a) => v.visit_expr(a, e, v), (v.visit_expr)(a, e, v);
expr_swap(a, b) => { v.visit_expr(a, e, v); v.visit_expr(b, e, v); } }
expr_copy(a) => (v.visit_expr)(a, e, v),
expr_unary_move(a) => (v.visit_expr)(a, e, v),
expr_swap(a, b) => { (v.visit_expr)(a, e, v); (v.visit_expr)(b, e, v); }
expr_assign_op(_, a, b) => { expr_assign_op(_, a, b) => {
v.visit_expr(b, e, v); (v.visit_expr)(b, e, v);
v.visit_expr(a, e, v); (v.visit_expr)(a, e, v);
} }
expr_field(x, _, tys) => { expr_field(x, _, tys) => {
v.visit_expr(x, e, v); (v.visit_expr)(x, e, v);
for tys.each |tp| { v.visit_ty(*tp, e, v); } for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
}
expr_index(a, b) => {
(v.visit_expr)(a, e, v);
(v.visit_expr)(b, e, v);
} }
expr_index(a, b) => { v.visit_expr(a, e, v); v.visit_expr(b, e, v); }
expr_path(p) => visit_path(p, e, v), expr_path(p) => visit_path(p, e, v),
expr_fail(eo) => visit_expr_opt(eo, e, v), expr_fail(eo) => visit_expr_opt(eo, e, v),
expr_break(_) => (), expr_break(_) => (),
expr_again(_) => (), expr_again(_) => (),
expr_ret(eo) => visit_expr_opt(eo, e, v), expr_ret(eo) => visit_expr_opt(eo, e, v),
expr_log(_, lv, x) => { expr_log(_, lv, x) => {
v.visit_expr(lv, e, v); (v.visit_expr)(lv, e, v);
v.visit_expr(x, e, v); (v.visit_expr)(x, e, v);
} }
expr_mac(mac) => visit_mac(mac, e, v), expr_mac(mac) => visit_mac(mac, e, v),
expr_paren(x) => v.visit_expr(x, e, v), expr_paren(x) => (v.visit_expr)(x, e, v),
} }
v.visit_expr_post(ex, e, v); (v.visit_expr_post)(ex, e, v);
} }
fn visit_arm<E>(a: arm, e: E, v: vt<E>) { fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
for a.pats.each |p| { v.visit_pat(*p, e, v); } for a.pats.each |p| { (v.visit_pat)(*p, e, v); }
visit_expr_opt(a.guard, e, v); visit_expr_opt(a.guard, e, v);
v.visit_block(a.body, e, v); (v.visit_block)(a.body, e, v);
} }
// Simpler, non-context passing interface. Always walks the whole tree, simply // Simpler, non-context passing interface. Always walks the whole tree, simply