Skip to content

Incoming #2545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions src/libsyntax/ast_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ type path = [path_elt];
fn path_to_str_with_sep(p: path, sep: str) -> str {
let strs = vec::map(p) {|e|
alt e {
path_mod(s) { s }
path_name(s) { s }
path_mod(s) { /* FIXME: bad */ copy s }
path_name(s) { /* FIXME: bad */ copy s }
}
};
str::connect(strs, sep)
}

fn path_ident_to_str(p: path, i: ident) -> str {
if vec::is_empty(p) {
i
/* FIXME: bad */ copy i
} else {
#fmt["%s::%s", path_to_str(p), i]
}
Expand Down Expand Up @@ -59,7 +59,7 @@ type ctx = {map: map, mut path: path,
mut local_id: uint, diag: span_handler};
type vt = visit::vt<ctx>;

fn extend(cx: ctx, elt: str) -> @path {
fn extend(cx: ctx, +elt: str) -> @path {
@(cx.path + [path_name(elt)])
}

Expand Down Expand Up @@ -89,15 +89,15 @@ fn map_crate(diag: span_handler, c: crate) -> map {
// crate. The `path` should be the path to the item but should not include
// the item itself.
fn map_decoded_item(diag: span_handler,
map: map, path: path, ii: inlined_item) {
map: map, +path: path, ii: inlined_item) {
// I believe it is ok for the local IDs of inlined items from other crates
// to overlap with the local ids from this crate, so just generate the ids
// starting from 0. (In particular, I think these ids are only used in
// alias analysis, which we will not be running on the inlined items, and
// even if we did I think it only needs an ordering between local
// variables that are simultaneously in scope).
let cx = {map: map,
mut path: path,
mut path: /* FIXME: bad */ copy path,
mut local_id: 0u,
diag: diag};
let v = mk_ast_map_visitor();
Expand All @@ -123,21 +123,27 @@ 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 {
visit::fk_ctor(nm, tps, self_id, parent_id) {
let ct = @{node: {id: id, self_id: self_id,
dec: decl, body: body},
let ct = @{node: {id: id,
self_id: self_id,
dec: /* FIXME: bad */ copy decl,
body: /* FIXME: bad */ copy body},
span: sp};
cx.map.insert(id, node_ctor(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));
}

_ {}
Expand All @@ -146,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);
}

Expand Down Expand Up @@ -180,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) {
Expand All @@ -207,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, _) {
Expand All @@ -217,17 +229,17 @@ 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); }
}
_ { }
}
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);
Expand All @@ -238,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))
}
Expand Down
26 changes: 15 additions & 11 deletions src/libsyntax/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
for variants.each {|v|
if v.node.name == i {
local = true;
parent_enum = some(it.ident);
parent_enum = some(/* FIXME: bad */ copy it.ident);
}
}
}
Expand Down Expand Up @@ -247,12 +247,12 @@ fn block_from_expr(e: @expr) -> blk {
ret {node: blk_, span: e.span};
}

fn default_block(stmts1: [@stmt], expr1: option<@expr>, id1: node_id) ->
fn default_block(+stmts1: [@stmt], expr1: option<@expr>, id1: node_id) ->
blk_ {
{view_items: [], stmts: stmts1, expr: expr1, id: id1, rules: default_blk}
}

fn ident_to_path(s: span, i: ident) -> @path {
fn ident_to_path(s: span, +i: ident) -> @path {
@{span: s, global: false, idents: [i],
rp: none, types: []}
}
Expand All @@ -265,7 +265,7 @@ pure fn is_unguarded(&&a: arm) -> bool {
}

pure fn unguarded_pat(a: arm) -> option<[@pat]> {
if is_unguarded(a) { some(a.pats) } else { none }
if is_unguarded(a) { some(/* FIXME: bad */ copy a.pats) } else { none }
}

// Provides an extra node_id to hang callee information on, in case the
Expand All @@ -275,8 +275,8 @@ fn op_expr_callee_id(e: @expr) -> node_id { e.id - 1 }

pure fn class_item_ident(ci: @class_member) -> ident {
alt ci.node {
instance_var(i,_,_,_,_) { i }
class_method(it) { it.ident }
instance_var(i,_,_,_,_) { /* FIXME: bad */ copy i }
class_method(it) { /* FIXME: bad */ copy it.ident }
}
}

Expand All @@ -294,7 +294,11 @@ fn split_class_items(cs: [@class_member]) -> ([ivar], [@method]) {
for cs.each {|c|
alt c.node {
instance_var(i, t, cm, id, vis) {
vs += [{ident: i, ty: t, cm: cm, id: id, vis: vis}];
vs += [{ident: /* FIXME: bad */ copy i,
ty: t,
cm: cm,
id: id,
vis: vis}];
}
class_method(m) { ms += [m]; }
}
Expand All @@ -312,10 +316,10 @@ pure fn class_member_visibility(ci: @class_member) -> visibility {
impl inlined_item_methods for inlined_item {
fn ident() -> ident {
alt self {
ii_item(i) { i.ident }
ii_native(i) { i.ident }
ii_method(_, m) { m.ident }
ii_ctor(_, nm, _, _) { nm }
ii_item(i) { /* FIXME: bad */ copy i.ident }
ii_native(i) { /* FIXME: bad */ copy i.ident }
ii_method(_, m) { /* FIXME: bad */ copy m.ident }
ii_ctor(_, nm, _, _) { /* FIXME: bad */ copy nm }
}
}

Expand Down
Loading