diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-08-07 16:08:09 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-08-07 16:09:08 -0700 |
| commit | 0f711e72f72cf69166902fe9df9c5063e5aa14ff (patch) | |
| tree | 6025c53bc18b4c615caf042dbc2d9fe68b7f1c03 /src/libsyntax/ast_map.rs | |
| parent | 1f0574e8f0d304afa6931f4fa1019c80a708b94d (diff) | |
libsyntax: Break struct definitions out of classes internally in a few more places
Diffstat (limited to 'src/libsyntax/ast_map.rs')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 0c3e99a3794..5c270c968f3 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -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| { |
