diff options
Diffstat (limited to 'src/comp/middle/ast_map.rs')
| -rw-r--r-- | src/comp/middle/ast_map.rs | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/comp/middle/ast_map.rs b/src/comp/middle/ast_map.rs index aad8afe0b0c..79410158ad5 100644 --- a/src/comp/middle/ast_map.rs +++ b/src/comp/middle/ast_map.rs @@ -37,11 +37,8 @@ type map = std::map::map<node_id, ast_node>; type ctx = {map: map, mutable path: path, mutable local_id: uint}; type vt = visit::vt<ctx>; -fn map_crate(c: crate) -> map { - let cx = {map: std::map::new_int_hash(), - mutable path: [], - mutable local_id: 0u}; - visit::visit_crate(c, cx, visit::mk_vt(@{ +fn mk_ast_map_visitor() -> vt { + ret visit::mk_vt(@{ visit_item: map_item, visit_native_item: map_native_item, visit_expr: map_expr, @@ -49,10 +46,33 @@ fn map_crate(c: crate) -> map { visit_local: map_local, visit_arm: map_arm with *visit::default_visitor() - })); + }); +} + +fn map_crate(c: crate) -> map { + let cx = {map: std::map::new_int_hash(), + mutable path: [], + mutable local_id: 0u}; + visit::visit_crate(c, cx, mk_ast_map_visitor()); ret cx.map; } +// Used for items loaded from external crate that are being inlined into this +// crate: +fn map_decoded_item(map: map, path: path, i: @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, + mutable path: path, + mutable local_id: 0u}; + let v = mk_ast_map_visitor(); + v.visit_item(i, cx, v); +} + fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: codemap::span, id: node_id, cx: ctx, v: vt) { for a in decl.inputs { |
