diff options
| author | Patrick Walton <[email protected]> | 2011-03-29 14:46:42 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-29 14:46:42 -0700 |
| commit | 94c061729b66adc777cf346417ab236a5d7d8410 (patch) | |
| tree | eadcdc9c3d3846df0a936ca30d99b37f7ebcaf62 /src | |
| parent | Rename trans_native to trans_native_call, for clarity. (diff) | |
| download | rust-94c061729b66adc777cf346417ab236a5d7d8410.tar.xz rust-94c061729b66adc777cf346417ab236a5d7d8410.zip | |
rustc: Resolve external modules and native modules to definition IDs as well
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/front/creader.rs | 13 | ||||
| -rw-r--r-- | src/comp/middle/metadata.rs | 20 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/comp/front/creader.rs b/src/comp/front/creader.rs index 735dbcb4..a08de2ab 100644 --- a/src/comp/front/creader.rs +++ b/src/comp/front/creader.rs @@ -360,6 +360,7 @@ impure fn move_to_item(&ebml.reader ebml_r, int item_id) { } log #fmt("move_to_item: item not found: %d", item_id); + fail; } // Looks up an item in the given metadata and returns an EBML reader pointing @@ -559,11 +560,13 @@ fn lookup_def(session.session sess, &span sp, int cnum, vec[ast.ident] path) did = tup(cnum, did._1); // FIXME: It'd be great if we had u8 char literals. - if (kind_ch == ('c' as u8)) { ret ast.def_const(did); } - else if (kind_ch == ('f' as u8)) { ret ast.def_fn(did); } - else if (kind_ch == ('y' as u8)) { ret ast.def_ty(did); } - else if (kind_ch == ('o' as u8)) { ret ast.def_obj(did); } - else if (kind_ch == ('t' as u8)) { ret ast.def_ty(did); } + if (kind_ch == ('c' as u8)) { ret ast.def_const(did); } + else if (kind_ch == ('f' as u8)) { ret ast.def_fn(did); } + else if (kind_ch == ('y' as u8)) { ret ast.def_ty(did); } + else if (kind_ch == ('o' as u8)) { ret ast.def_obj(did); } + else if (kind_ch == ('t' as u8)) { ret ast.def_ty(did); } + else if (kind_ch == ('m' as u8)) { ret ast.def_mod(did); } + else if (kind_ch == ('n' as u8)) { ret ast.def_native_mod(did); } else if (kind_ch == ('v' as u8)) { auto tid = get_variant_tag_id(ebml_r); tid = tup(cnum, tid._1); diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs index 7a9838d7..a55fb848 100644 --- a/src/comp/middle/metadata.rs +++ b/src/comp/middle/metadata.rs @@ -210,15 +210,17 @@ fn encode_module_item_paths(&ebml.writer ebml_w, &ast._mod module) { encode_def_id(ebml_w, did); ebml.end_tag(ebml_w); } - case (ast.item_mod(?id, ?_mod, _)) { + case (ast.item_mod(?id, ?_mod, ?did)) { ebml.start_tag(ebml_w, tag_paths_mod); encode_name(ebml_w, id); + encode_def_id(ebml_w, did); encode_module_item_paths(ebml_w, _mod); ebml.end_tag(ebml_w); } - case (ast.item_native_mod(?id, ?nmod, _)) { + case (ast.item_native_mod(?id, ?nmod, ?did)) { ebml.start_tag(ebml_w, tag_paths_mod); encode_name(ebml_w, id); + encode_def_id(ebml_w, did); encode_native_module_item_paths(ebml_w, nmod); ebml.end_tag(ebml_w); } @@ -336,11 +338,17 @@ fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w, encode_symbol(cx, ebml_w, did); ebml.end_tag(ebml_w); } - case (ast.item_mod(_, _, _)) { - // nothing to do + case (ast.item_mod(_, _, ?did)) { + ebml.start_tag(ebml_w, tag_items_item); + encode_def_id(ebml_w, did); + encode_kind(ebml_w, 'm' as u8); + ebml.end_tag(ebml_w); } - case (ast.item_native_mod(_, _, _)) { - // nothing to do + case (ast.item_native_mod(_, _, ?did)) { + ebml.start_tag(ebml_w, tag_items_item); + encode_def_id(ebml_w, did); + encode_kind(ebml_w, 'n' as u8); + ebml.end_tag(ebml_w); } case (ast.item_ty(?id, _, ?tps, ?did, ?ann)) { ebml.start_tag(ebml_w, tag_items_item); |