syntax: Add a lot of copy keywords
This commit is contained in:
@@ -123,7 +123,7 @@ fn map_decoded_item(diag: span_handler,
|
|||||||
fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
||||||
sp: codemap::span, id: node_id, cx: ctx, v: vt) {
|
sp: codemap::span, id: node_id, cx: ctx, v: vt) {
|
||||||
for decl.inputs.each {|a|
|
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;
|
cx.local_id += 1u;
|
||||||
}
|
}
|
||||||
alt fk {
|
alt fk {
|
||||||
@@ -133,13 +133,17 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
|||||||
dec: /* FIXME: bad */ copy decl,
|
dec: /* FIXME: bad */ copy decl,
|
||||||
body: /* FIXME: bad */ copy body},
|
body: /* FIXME: bad */ copy body},
|
||||||
span: sp};
|
span: sp};
|
||||||
cx.map.insert(id, node_ctor(/* FIXME: bad */ copy nm, tps,
|
cx.map.insert(id, node_ctor(/* FIXME: bad */ copy nm,
|
||||||
class_ctor(ct, parent_id), @cx.path));
|
/* FIXME: bad */ copy tps,
|
||||||
|
class_ctor(ct, parent_id),
|
||||||
|
@/* FIXME: bad */ copy cx.path));
|
||||||
}
|
}
|
||||||
visit::fk_dtor(tps, self_id, parent_id) {
|
visit::fk_dtor(tps, self_id, parent_id) {
|
||||||
let dt = @{node: {id: id, self_id: self_id, body: body},
|
let dt = @{node: {id: id, self_id: self_id,
|
||||||
span: sp};
|
body: /* FIXME: bad */ copy body}, span: sp};
|
||||||
cx.map.insert(id, node_dtor(tps, dt, parent_id, @cx.path));
|
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) {
|
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);
|
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) {
|
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));
|
cx.map.insert(i.id, node_item(i, item_path));
|
||||||
alt i.node {
|
alt i.node {
|
||||||
item_impl(_, _, _, _, ms) {
|
item_impl(_, _, _, _, ms) {
|
||||||
let impl_did = ast_util::local_def(i.id);
|
let impl_did = ast_util::local_def(i.id);
|
||||||
for ms.each {|m|
|
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, _) {
|
item_res(decl, tps, _, dtor_id, ctor_id, _) {
|
||||||
cx.map.insert(ctor_id, node_ctor(i.ident, tps,
|
cx.map.insert(ctor_id, node_ctor(/* FIXME: bad */ copy i.ident,
|
||||||
res_ctor(decl, ctor_id, i.span),
|
/* FIXME: bad */ copy tps,
|
||||||
|
res_ctor(/* FIXME: bad */ copy decl,
|
||||||
|
ctor_id, i.span),
|
||||||
item_path));
|
item_path));
|
||||||
cx.map.insert(dtor_id, node_item(i, item_path));
|
cx.map.insert(dtor_id, node_item(i, item_path));
|
||||||
}
|
}
|
||||||
item_enum(vs, _, _) {
|
item_enum(vs, _, _) {
|
||||||
for vs.each {|v|
|
for vs.each {|v|
|
||||||
cx.map.insert(v.node.id, node_variant(
|
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) {
|
item_native_mod(nm) {
|
||||||
@@ -209,7 +217,9 @@ fn map_item(i: @item, cx: ctx, v: vt) {
|
|||||||
either::right(abi) { abi }
|
either::right(abi) { abi }
|
||||||
};
|
};
|
||||||
for nm.items.each {|nitem|
|
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, _) {
|
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,
|
vec::iter(ifces) {|p| cx.map.insert(p.id,
|
||||||
node_item(i, item_path)); };
|
node_item(i, item_path)); };
|
||||||
let d_id = ast_util::local_def(i.id);
|
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
|
// only need to handle methods
|
||||||
vec::iter(ms) {|m| map_method(d_id, p, m, cx); }
|
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 {
|
alt i.node {
|
||||||
item_mod(_) | item_native_mod(_) {
|
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);
|
visit::visit_item(i, cx, v);
|
||||||
vec::pop(cx.path);
|
vec::pop(cx.path);
|
||||||
@@ -240,7 +250,7 @@ fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
|
|||||||
view_item_export(vps) {
|
view_item_export(vps) {
|
||||||
for vps.each {|vp|
|
for vps.each {|vp|
|
||||||
let (id, name) = alt vp.node {
|
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) {
|
view_path_glob(pth, id) | view_path_list(pth, _, id) {
|
||||||
(id, path_to_ident(pth))
|
(id, path_to_ident(pth))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ fn mk_name_value_item_str(+name: ast::ident, +value: str) -> @ast::meta_item {
|
|||||||
ret mk_name_value_item(name, value_lit);
|
ret mk_name_value_item(name, value_lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_name_value_item(+name: ast::ident, +value: ast::lit) -> @ast::meta_item {
|
fn mk_name_value_item(+name: ast::ident, +value: ast::lit)
|
||||||
|
-> @ast::meta_item {
|
||||||
ret @dummy_spanned(ast::meta_name_value(name, value));
|
ret @dummy_spanned(ast::meta_name_value(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,10 +88,11 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
|
|||||||
meta_word(id) { meta_word(fld.fold_ident(id)) }
|
meta_word(id) { meta_word(fld.fold_ident(id)) }
|
||||||
meta_list(id, mis) {
|
meta_list(id, mis) {
|
||||||
let fold_meta_item = bind fold_meta_item_(_, fld);
|
let fold_meta_item = bind fold_meta_item_(_, fld);
|
||||||
meta_list(id, vec::map(mis, fold_meta_item))
|
meta_list(/* FIXME: bad */ copy id,
|
||||||
|
vec::map(mis, fold_meta_item))
|
||||||
}
|
}
|
||||||
meta_name_value(id, s) {
|
meta_name_value(id, s) {
|
||||||
meta_name_value(fld.fold_ident(id), s)
|
meta_name_value(fld.fold_ident(id), /* FIXME: bad */ copy s)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
span: fld.new_span(mi.span)};
|
span: fld.new_span(mi.span)};
|
||||||
@@ -121,8 +122,8 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
|||||||
mac_embed_type(ty) { mac_embed_type(fld.fold_ty(ty)) }
|
mac_embed_type(ty) { mac_embed_type(fld.fold_ty(ty)) }
|
||||||
mac_embed_block(blk) { mac_embed_block(fld.fold_block(blk)) }
|
mac_embed_block(blk) { mac_embed_block(fld.fold_block(blk)) }
|
||||||
mac_ellipsis { mac_ellipsis }
|
mac_ellipsis { mac_ellipsis }
|
||||||
mac_aq(_,_) { /* fixme */ m.node }
|
mac_aq(_,_) { /* FIXME: bad */ copy m.node }
|
||||||
mac_var(_) { /* fixme */ m.node }
|
mac_var(_) { /* FIXME: bad */ copy m.node }
|
||||||
},
|
},
|
||||||
span: fld.new_span(m.span)};
|
span: fld.new_span(m.span)};
|
||||||
}
|
}
|
||||||
@@ -143,7 +144,7 @@ fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty_param(tp: ty_param, fld: ast_fold) -> ty_param {
|
fn fold_ty_param(tp: ty_param, fld: ast_fold) -> ty_param {
|
||||||
{ident: tp.ident,
|
{ident: /* FIXME: bad */ copy tp.ident,
|
||||||
id: fld.new_id(tp.id),
|
id: fld.new_id(tp.id),
|
||||||
bounds: @vec::map(*tp.bounds, fold_ty_param_bound(_, fld))}
|
bounds: @vec::map(*tp.bounds, fold_ty_param_bound(_, fld))}
|
||||||
}
|
}
|
||||||
@@ -166,19 +167,20 @@ fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) ->
|
|||||||
crate_directive_ {
|
crate_directive_ {
|
||||||
ret alt cd {
|
ret alt cd {
|
||||||
cdir_src_mod(id, attrs) {
|
cdir_src_mod(id, attrs) {
|
||||||
cdir_src_mod(fld.fold_ident(id), attrs)
|
cdir_src_mod(fld.fold_ident(id), /* FIXME: bad */ copy attrs)
|
||||||
}
|
}
|
||||||
cdir_dir_mod(id, cds, attrs) {
|
cdir_dir_mod(id, cds, attrs) {
|
||||||
cdir_dir_mod(fld.fold_ident(id),
|
cdir_dir_mod(fld.fold_ident(id),
|
||||||
vec::map(cds, fld.fold_crate_directive), attrs)
|
vec::map(cds, fld.fold_crate_directive),
|
||||||
|
/* FIXME: bad */ copy attrs)
|
||||||
}
|
}
|
||||||
cdir_view_item(vi) { cdir_view_item(fld.fold_view_item(vi)) }
|
cdir_view_item(vi) { cdir_view_item(fld.fold_view_item(vi)) }
|
||||||
cdir_syntax(_) { cd }
|
cdir_syntax(_) { copy cd }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
|
fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
|
||||||
ret vi;
|
ret /* FIXME: bad */ copy vi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -220,7 +222,8 @@ fn noop_fold_class_item(&&ci: @class_member, fld: ast_fold)
|
|||||||
-> @class_member {
|
-> @class_member {
|
||||||
@{node: alt ci.node {
|
@{node: alt ci.node {
|
||||||
instance_var(ident, t, cm, id, p) {
|
instance_var(ident, t, cm, id, p) {
|
||||||
instance_var(ident, fld.fold_ty(t), cm, id, p)
|
instance_var(/* FIXME: bad */ copy ident, fld.fold_ty(t), cm, id,
|
||||||
|
p)
|
||||||
}
|
}
|
||||||
class_method(m) { class_method(fld.fold_method(m)) }
|
class_method(m) { class_method(fld.fold_method(m)) }
|
||||||
},
|
},
|
||||||
@@ -256,7 +259,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
|||||||
id: dtor_id with dtor.node}
|
id: dtor_id with dtor.node}
|
||||||
with dtor}};
|
with dtor}};
|
||||||
item_class(
|
item_class(
|
||||||
typms,
|
/* FIXME: bad */ copy typms,
|
||||||
vec::map(ifaces, {|p| fold_iface_ref(p, fld) }),
|
vec::map(ifaces, {|p| fold_iface_ref(p, fld) }),
|
||||||
vec::map(items, fld.fold_class_item),
|
vec::map(items, fld.fold_class_item),
|
||||||
{node: {body: ctor_body,
|
{node: {body: ctor_body,
|
||||||
@@ -274,7 +277,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
|||||||
item_iface(tps, rp, methods) {
|
item_iface(tps, rp, methods) {
|
||||||
item_iface(fold_ty_params(tps, fld),
|
item_iface(fold_ty_params(tps, fld),
|
||||||
rp,
|
rp,
|
||||||
methods)
|
/* FIXME: bad */ copy methods)
|
||||||
}
|
}
|
||||||
item_res(decl, typms, body, did, cid, rp) {
|
item_res(decl, typms, body, did, cid, rp) {
|
||||||
item_res(fold_fn_decl(decl, fld),
|
item_res(fold_fn_decl(decl, fld),
|
||||||
@@ -293,7 +296,7 @@ fn fold_iface_ref(&&p: @iface_ref, fld: ast_fold) -> @iface_ref {
|
|||||||
|
|
||||||
fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
||||||
ret @{ident: fld.fold_ident(m.ident),
|
ret @{ident: fld.fold_ident(m.ident),
|
||||||
attrs: m.attrs,
|
attrs: /* FIXME: bad */ copy m.attrs,
|
||||||
tps: fold_ty_params(m.tps, fld),
|
tps: fold_ty_params(m.tps, fld),
|
||||||
decl: fold_fn_decl(m.decl, fld),
|
decl: fold_fn_decl(m.decl, fld),
|
||||||
body: fld.fold_block(m.body),
|
body: fld.fold_block(m.body),
|
||||||
@@ -328,7 +331,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
|
|||||||
|
|
||||||
fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||||
ret alt p {
|
ret alt p {
|
||||||
pat_wild { p }
|
pat_wild { pat_wild }
|
||||||
pat_ident(pth, sub) {
|
pat_ident(pth, sub) {
|
||||||
pat_ident(fld.fold_path(pth), option::map(sub, fld.fold_pat))
|
pat_ident(fld.fold_path(pth), option::map(sub, fld.fold_pat))
|
||||||
}
|
}
|
||||||
@@ -340,7 +343,8 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
|||||||
pat_rec(fields, etc) {
|
pat_rec(fields, etc) {
|
||||||
let mut fs = [];
|
let mut fs = [];
|
||||||
for fields.each {|f|
|
for fields.each {|f|
|
||||||
fs += [{ident: f.ident, pat: fld.fold_pat(f.pat)}];
|
fs += [{ident: /* FIXME: bad */ copy f.ident,
|
||||||
|
pat: fld.fold_pat(f.pat)}];
|
||||||
}
|
}
|
||||||
pat_rec(fs, etc)
|
pat_rec(fs, etc)
|
||||||
}
|
}
|
||||||
@@ -410,7 +414,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
|||||||
}
|
}
|
||||||
expr_unary(binop, ohs) { expr_unary(binop, fld.fold_expr(ohs)) }
|
expr_unary(binop, ohs) { expr_unary(binop, fld.fold_expr(ohs)) }
|
||||||
expr_loop_body(f) { expr_loop_body(fld.fold_expr(f)) }
|
expr_loop_body(f) { expr_loop_body(fld.fold_expr(f)) }
|
||||||
expr_lit(_) { e }
|
expr_lit(_) { copy e }
|
||||||
expr_cast(expr, ty) { expr_cast(fld.fold_expr(expr), ty) }
|
expr_cast(expr, ty) { expr_cast(fld.fold_expr(expr), ty) }
|
||||||
expr_addr_of(m, ohs) { expr_addr_of(m, fld.fold_expr(ohs)) }
|
expr_addr_of(m, ohs) { expr_addr_of(m, fld.fold_expr(ohs)) }
|
||||||
expr_if(cond, tr, fl) {
|
expr_if(cond, tr, fl) {
|
||||||
@@ -462,7 +466,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
|||||||
}
|
}
|
||||||
expr_path(pth) { expr_path(fld.fold_path(pth)) }
|
expr_path(pth) { expr_path(fld.fold_path(pth)) }
|
||||||
expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) }
|
expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) }
|
||||||
expr_break | expr_cont { e }
|
expr_break | expr_cont { copy e }
|
||||||
expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) }
|
expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) }
|
||||||
expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv),
|
expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv),
|
||||||
fld.fold_expr(e)) }
|
fld.fold_expr(e)) }
|
||||||
@@ -487,7 +491,7 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
|||||||
span: fld.new_span(f.span)}
|
span: fld.new_span(f.span)}
|
||||||
}
|
}
|
||||||
alt t {
|
alt t {
|
||||||
ty_nil | ty_bot {t}
|
ty_nil | ty_bot | ty_infer {copy t}
|
||||||
ty_box(mt) {ty_box(fold_mt(mt, fld))}
|
ty_box(mt) {ty_box(fold_mt(mt, fld))}
|
||||||
ty_uniq(mt) {ty_uniq(fold_mt(mt, fld))}
|
ty_uniq(mt) {ty_uniq(fold_mt(mt, fld))}
|
||||||
ty_vec(mt) {ty_vec(fold_mt(mt, fld))}
|
ty_vec(mt) {ty_vec(fold_mt(mt, fld))}
|
||||||
@@ -501,17 +505,18 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
|||||||
vec::map(constrs, fld.fold_ty_constr))}
|
vec::map(constrs, fld.fold_ty_constr))}
|
||||||
ty_vstore(t, vs) {ty_vstore(fld.fold_ty(t), vs)}
|
ty_vstore(t, vs) {ty_vstore(fld.fold_ty(t), vs)}
|
||||||
ty_mac(mac) {ty_mac(fold_mac(mac))}
|
ty_mac(mac) {ty_mac(fold_mac(mac))}
|
||||||
ty_infer {t}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_constr(c: constr_, fld: ast_fold) -> constr_ {
|
fn noop_fold_constr(c: constr_, fld: ast_fold) -> constr_ {
|
||||||
{path: fld.fold_path(c.path), args: c.args, id: fld.new_id(c.id)}
|
{path: fld.fold_path(c.path), args: /* FIXME: bad */ copy c.args,
|
||||||
|
id: fld.new_id(c.id)}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_ty_constr(c: ty_constr_, fld: ast_fold) -> ty_constr_ {
|
fn noop_fold_ty_constr(c: ty_constr_, fld: ast_fold) -> ty_constr_ {
|
||||||
let rslt: ty_constr_ =
|
let rslt: ty_constr_ =
|
||||||
{path: fld.fold_path(c.path), args: c.args, id: fld.new_id(c.id)};
|
{path: fld.fold_path(c.path), args: /* FIXME: bad */ copy c.args,
|
||||||
|
id: fld.new_id(c.id)};
|
||||||
rslt
|
rslt
|
||||||
}
|
}
|
||||||
// ...nor do modules
|
// ...nor do modules
|
||||||
@@ -539,14 +544,16 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
|||||||
some(e) {some(fld.fold_expr(e))}
|
some(e) {some(fld.fold_expr(e))}
|
||||||
none {none}
|
none {none}
|
||||||
};
|
};
|
||||||
ret {name: v.name,
|
ret {name: /* FIXME: bad */ copy v.name,
|
||||||
attrs: attrs,
|
attrs: attrs,
|
||||||
args: args, id: fld.new_id(v.id),
|
args: args, id: fld.new_id(v.id),
|
||||||
disr_expr: de,
|
disr_expr: de,
|
||||||
vis: v.vis};
|
vis: v.vis};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { ret i; }
|
fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident {
|
||||||
|
ret /* FIXME: bad */ copy i;
|
||||||
|
}
|
||||||
|
|
||||||
fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
|
fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
|
||||||
ret {span: fld.new_span(p.span), global: p.global,
|
ret {span: fld.new_span(p.span), global: p.global,
|
||||||
@@ -639,8 +646,8 @@ impl of ast_fold for ast_fold_precursor {
|
|||||||
fn fold_class_item(&&ci: @class_member) -> @class_member {
|
fn fold_class_item(&&ci: @class_member) -> @class_member {
|
||||||
@{node: alt ci.node {
|
@{node: alt ci.node {
|
||||||
instance_var(nm, t, mt, id, p) {
|
instance_var(nm, t, mt, id, p) {
|
||||||
instance_var(nm, (self as ast_fold).fold_ty(t),
|
instance_var(/* FIXME: bad */ copy nm,
|
||||||
mt, id, p)
|
(self as ast_fold).fold_ty(t), mt, id, p)
|
||||||
}
|
}
|
||||||
class_method(m) {
|
class_method(m) {
|
||||||
class_method(self.fold_method(m, self as ast_fold))
|
class_method(self.fold_method(m, self as ast_fold))
|
||||||
|
|||||||
@@ -209,6 +209,9 @@ impl parser_common for parser {
|
|||||||
ret v;
|
ret v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: A lot of callers go through here, only to copy out the T and
|
||||||
|
// discard the spanned<> wrapper. I feel as though there should be a
|
||||||
|
// version of this that does not return a spanned result.
|
||||||
fn parse_seq<T: copy>(bra: token::token, ket: token::token, sep: seq_sep,
|
fn parse_seq<T: copy>(bra: token::token, ket: token::token, sep: seq_sep,
|
||||||
f: fn(parser) -> T) -> spanned<[T]> {
|
f: fn(parser) -> T) -> spanned<[T]> {
|
||||||
let lo = self.span.lo;
|
let lo = self.span.lo;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ optional suffix then adding the .rs extension.
|
|||||||
fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
|
fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
|
||||||
-> ([@ast::view_item], [@ast::item], [ast::attribute]) {
|
-> ([@ast::view_item], [@ast::item], [ast::attribute]) {
|
||||||
|
|
||||||
fn companion_file(prefix: str, suffix: option<str>) -> str {
|
fn companion_file(+prefix: str, suffix: option<str>) -> str {
|
||||||
ret alt suffix {
|
ret alt suffix {
|
||||||
option::some(s) { path::connect(prefix, s) }
|
option::some(s) { path::connect(prefix, s) }
|
||||||
option::none { prefix }
|
option::none { prefix }
|
||||||
@@ -66,8 +66,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
|
|||||||
#debug("found companion mod");
|
#debug("found companion mod");
|
||||||
let p0 = new_parser_from_file(cx.sess, cx.cfg, modpath, SOURCE_FILE);
|
let p0 = new_parser_from_file(cx.sess, cx.cfg, modpath, SOURCE_FILE);
|
||||||
let inner_attrs = p0.parse_inner_attrs_and_next();
|
let inner_attrs = p0.parse_inner_attrs_and_next();
|
||||||
let first_item_outer_attrs = inner_attrs.next;
|
let m0 = p0.parse_mod_items(token::EOF, inner_attrs.next);
|
||||||
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
|
|
||||||
cx.sess.chpos = p0.reader.chpos;
|
cx.sess.chpos = p0.reader.chpos;
|
||||||
cx.sess.byte_pos = cx.sess.byte_pos + p0.reader.pos;
|
cx.sess.byte_pos = cx.sess.byte_pos + p0.reader.pos;
|
||||||
ret (m0.view_items, m0.items, inner_attrs.inner);
|
ret (m0.view_items, m0.items, inner_attrs.inner);
|
||||||
@@ -102,7 +101,8 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
|
|||||||
let first_item_outer_attrs = inner_attrs.next;
|
let first_item_outer_attrs = inner_attrs.next;
|
||||||
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
|
let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
|
||||||
|
|
||||||
let i = p0.mk_item(cdir.span.lo, cdir.span.hi, id,
|
let i = p0.mk_item(cdir.span.lo, cdir.span.hi,
|
||||||
|
/* FIXME: bad */ copy id,
|
||||||
ast::item_mod(m0), ast::public, mod_attrs);
|
ast::item_mod(m0), ast::public, mod_attrs);
|
||||||
// Thread defids, chpos and byte_pos through the parsers
|
// Thread defids, chpos and byte_pos through the parsers
|
||||||
cx.sess.chpos = p0.reader.chpos;
|
cx.sess.chpos = p0.reader.chpos;
|
||||||
@@ -118,7 +118,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
|
|||||||
let (m0, a0) = eval_crate_directives_to_mod(
|
let (m0, a0) = eval_crate_directives_to_mod(
|
||||||
cx, cdirs, full_path, none);
|
cx, cdirs, full_path, none);
|
||||||
let i =
|
let i =
|
||||||
@{ident: id,
|
@{ident: /* FIXME: bad */ copy id,
|
||||||
attrs: attrs + a0,
|
attrs: attrs + a0,
|
||||||
id: cx.sess.next_id,
|
id: cx.sess.next_id,
|
||||||
node: ast::item_mod(m0),
|
node: ast::item_mod(m0),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ enum fn_kind {
|
|||||||
fn name_of_fn(fk: fn_kind) -> ident {
|
fn name_of_fn(fk: fn_kind) -> ident {
|
||||||
alt fk {
|
alt fk {
|
||||||
fk_item_fn(name, _) | fk_method(name, _, _) | fk_res(name, _, _)
|
fk_item_fn(name, _) | fk_method(name, _, _) | fk_res(name, _, _)
|
||||||
| fk_ctor(name, _, _, _) { name }
|
| fk_ctor(name, _, _, _) { /* FIXME: bad */ copy name }
|
||||||
fk_anon(*) | fk_fn_block(*) { "anon" }
|
fk_anon(*) | fk_fn_block(*) { "anon" }
|
||||||
fk_dtor(*) { "drop" }
|
fk_dtor(*) { "drop" }
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,9 @@ fn name_of_fn(fk: fn_kind) -> ident {
|
|||||||
fn tps_of_fn(fk: fn_kind) -> [ty_param] {
|
fn tps_of_fn(fk: fn_kind) -> [ty_param] {
|
||||||
alt fk {
|
alt fk {
|
||||||
fk_item_fn(_, tps) | fk_method(_, tps, _) | fk_res(_, tps, _)
|
fk_item_fn(_, tps) | fk_method(_, tps, _) | fk_res(_, tps, _)
|
||||||
| fk_ctor(_, tps, _, _) | fk_dtor(tps, _, _) { tps }
|
| fk_ctor(_, tps, _, _) | fk_dtor(tps, _, _) {
|
||||||
|
/* FIXME: bad */ copy tps
|
||||||
|
}
|
||||||
fk_anon(*) | fk_fn_block(*) { [] }
|
fk_anon(*) | fk_fn_block(*) { [] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,9 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
|||||||
alt i.node {
|
alt 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, tp, body) {
|
item_fn(decl, tp, body) {
|
||||||
v.visit_fn(fk_item_fn(i.ident, tp), decl, body, i.span, i.id, e, v);
|
v.visit_fn(fk_item_fn(/* FIXME: bad */ copy i.ident,
|
||||||
|
/* FIXME: bad */ copy tp), decl, body,
|
||||||
|
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_native_mod(nm) {
|
item_native_mod(nm) {
|
||||||
@@ -127,8 +131,10 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
|||||||
v.visit_ty_params(tps, e, v);
|
v.visit_ty_params(tps, e, v);
|
||||||
}
|
}
|
||||||
item_res(decl, tps, body, dtor_id, _, rp) {
|
item_res(decl, tps, body, dtor_id, _, rp) {
|
||||||
v.visit_fn(fk_res(i.ident, tps, rp), decl, body, i.span,
|
v.visit_fn(fk_res(/* FIXME: bad */ copy i.ident,
|
||||||
dtor_id, e, v);
|
/* FIXME: bad */ copy tps,
|
||||||
|
rp),
|
||||||
|
decl, body, i.span, dtor_id, e, v);
|
||||||
}
|
}
|
||||||
item_enum(variants, tps, _) {
|
item_enum(variants, tps, _) {
|
||||||
v.visit_ty_params(tps, e, v);
|
v.visit_ty_params(tps, e, v);
|
||||||
@@ -281,22 +287,23 @@ 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(m.ident, m.tps, m), m.decl, m.body, m.span,
|
v.visit_fn(fk_method(/* FIXME: bad */ copy m.ident,
|
||||||
m.id, e, v);
|
/* FIXME: bad */ copy m.tps, m),
|
||||||
|
m.decl, m.body, m.span, m.id, e, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar logic to the comment on visit_method_helper - Tim
|
// Similar logic to the comment on visit_method_helper - Tim
|
||||||
fn visit_class_ctor_helper<E>(ctor: class_ctor, nm: ident, tps: [ty_param],
|
fn visit_class_ctor_helper<E>(ctor: class_ctor, nm: ident, 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_ctor(nm, tps, ctor.node.self_id,
|
v.visit_fn(fk_ctor(/* FIXME: bad */ copy nm, /* FIXME: bad */ copy tps,
|
||||||
parent_id), ctor.node.dec,
|
ctor.node.self_id, parent_id), ctor.node.dec,
|
||||||
ctor.node.body, ctor.span, ctor.node.id, e, v)
|
ctor.node.body, ctor.span, ctor.node.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(tps, dtor.node.self_id,
|
v.visit_fn(fk_dtor(/* FIXME: bad */ copy tps, dtor.node.self_id,
|
||||||
parent_id), ast_util::dtor_dec(),
|
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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user