syntax: Add a lot of copy keywords

This commit is contained in:
Patrick Walton
2012-06-07 21:53:47 -07:00
parent 847c5e4e98
commit 26faa37305
6 changed files with 87 additions and 59 deletions

View File

@@ -123,7 +123,7 @@ fn map_decoded_item(diag: span_handler,
fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
sp: codemap::span, id: node_id, cx: ctx, v: vt) {
for decl.inputs.each {|a|
cx.map.insert(a.id, node_arg(a, cx.local_id));
cx.map.insert(a.id, node_arg(/* FIXME: bad */ copy a, cx.local_id));
cx.local_id += 1u;
}
alt fk {
@@ -133,13 +133,17 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
dec: /* FIXME: bad */ copy decl,
body: /* FIXME: bad */ copy body},
span: sp};
cx.map.insert(id, node_ctor(/* FIXME: bad */ copy nm, tps,
class_ctor(ct, parent_id), @cx.path));
cx.map.insert(id, node_ctor(/* FIXME: bad */ copy nm,
/* FIXME: bad */ copy tps,
class_ctor(ct, parent_id),
@/* FIXME: bad */ copy cx.path));
}
visit::fk_dtor(tps, self_id, parent_id) {
let dt = @{node: {id: id, self_id: self_id, body: body},
span: sp};
cx.map.insert(id, node_dtor(tps, dt, parent_id, @cx.path));
let dt = @{node: {id: id, self_id: self_id,
body: /* FIXME: bad */ copy body}, span: sp};
cx.map.insert(id, node_dtor(/* FIXME: bad */ copy tps, dt,
parent_id,
@/* FIXME: bad */ copy cx.path));
}
_ {}
@@ -148,7 +152,7 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
}
fn map_block(b: blk, cx: ctx, v: vt) {
cx.map.insert(b.node.id, node_block(b));
cx.map.insert(b.node.id, node_block(/* FIXME: bad */ copy b));
visit::visit_block(b, cx, v);
}
@@ -182,25 +186,29 @@ fn map_method(impl_did: def_id, impl_path: @path,
}
fn map_item(i: @item, cx: ctx, v: vt) {
let item_path = @cx.path;
let item_path = @/* FIXME: bad */ copy cx.path;
cx.map.insert(i.id, node_item(i, item_path));
alt i.node {
item_impl(_, _, _, _, ms) {
let impl_did = ast_util::local_def(i.id);
for ms.each {|m|
map_method(impl_did, extend(cx, i.ident), m, cx);
map_method(impl_did, extend(cx, /* FIXME: bad */ copy i.ident), m,
cx);
}
}
item_res(decl, tps, _, dtor_id, ctor_id, _) {
cx.map.insert(ctor_id, node_ctor(i.ident, tps,
res_ctor(decl, ctor_id, i.span),
cx.map.insert(ctor_id, node_ctor(/* FIXME: bad */ copy i.ident,
/* FIXME: bad */ copy tps,
res_ctor(/* FIXME: bad */ copy decl,
ctor_id, i.span),
item_path));
cx.map.insert(dtor_id, node_item(i, item_path));
}
item_enum(vs, _, _) {
for vs.each {|v|
cx.map.insert(v.node.id, node_variant(
v, i, extend(cx, i.ident)));
/* FIXME: bad */ copy v, i,
extend(cx, /* FIXME: bad */ copy i.ident)));
}
}
item_native_mod(nm) {
@@ -209,7 +217,9 @@ fn map_item(i: @item, cx: ctx, v: vt) {
either::right(abi) { abi }
};
for nm.items.each {|nitem|
cx.map.insert(nitem.id, node_native_item(nitem, abi, @cx.path));
cx.map.insert(nitem.id,
node_native_item(nitem, abi,
@/* FIXME: bad */ copy cx.path));
}
}
item_class(tps, ifces, items, ctor, dtor, _) {
@@ -219,7 +229,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
vec::iter(ifces) {|p| cx.map.insert(p.id,
node_item(i, item_path)); };
let d_id = ast_util::local_def(i.id);
let p = extend(cx, i.ident);
let p = extend(cx, /* FIXME: bad */ copy i.ident);
// only need to handle methods
vec::iter(ms) {|m| map_method(d_id, p, m, cx); }
}
@@ -227,9 +237,9 @@ fn map_item(i: @item, cx: ctx, v: vt) {
}
alt i.node {
item_mod(_) | item_native_mod(_) {
cx.path += [path_mod(i.ident)];
cx.path += [path_mod(/* FIXME: bad */ copy i.ident)];
}
_ { cx.path += [path_name(i.ident)]; }
_ { cx.path += [path_name(/* FIXME: bad */ copy i.ident)]; }
}
visit::visit_item(i, cx, v);
vec::pop(cx.path);
@@ -240,7 +250,7 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
view_item_export(vps) {
for vps.each {|vp|
let (id, name) = alt vp.node {
view_path_simple(nm, _, id) { (id, nm) }
view_path_simple(nm, _, id) { (id, /* FIXME: bad */ copy nm) }
view_path_glob(pth, id) | view_path_list(pth, _, id) {
(id, path_to_ident(pth))
}