libsyntax: Break struct definitions out of classes internally in a few more places

This commit is contained in:
Patrick Walton 2012-08-07 16:08:09 -07:00
parent 1f0574e8f0
commit 0f711e72f7
2 changed files with 94 additions and 83 deletions

View file

@ -217,19 +217,8 @@ fn map_item(i: @item, cx: ctx, v: vt) {
}
}
item_class(struct_def, _) => {
let (_, ms) = ast_util::split_class_items(struct_def.members);
// Map trait refs to their parent classes. This is
// so we can find the self_ty
for struct_def.traits.each |p| {
cx.map.insert(p.ref_id, node_item(i, item_path));
// This is so we can look up the right things when
// encoding/decoding
cx.map.insert(p.impl_id, node_item(i, item_path));
}
let d_id = ast_util::local_def(i.id);
let p = extend(cx, i.ident);
// only need to handle methods
do vec::iter(ms) |m| { map_method(d_id, p, m, cx); }
map_struct_def(struct_def, node_item(i, item_path), i.ident, i.id, cx,
v);
}
item_trait(tps, traits, methods) => {
// Map trait refs to their parent classes. This is
@ -258,6 +247,23 @@ fn map_item(i: @item, cx: ctx, v: vt) {
vec::pop(cx.path);
}
fn map_struct_def(struct_def: ast::struct_def, parent_node: ast_node,
ident: ast::ident, id: ast::node_id, cx: ctx, _v: vt) {
let (_, ms) = ast_util::split_class_items(struct_def.members);
// Map trait refs to their parent classes. This is
// so we can find the self_ty
for struct_def.traits.each |p| {
cx.map.insert(p.ref_id, parent_node);
// This is so we can look up the right things when
// encoding/decoding
cx.map.insert(p.impl_id, parent_node);
}
let d_id = ast_util::local_def(id);
let p = extend(cx, ident);
// only need to handle methods
do vec::iter(ms) |m| { map_method(d_id, p, m, cx); }
}
fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
match vi.node {
view_item_export(vps) => for vps.each |vp| {