From 94c061729b66adc777cf346417ab236a5d7d8410 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 29 Mar 2011 14:46:42 -0700 Subject: [PATCH] rustc: Resolve external modules and native modules to definition IDs as well --- src/comp/front/creader.rs | 13 ++++++++----- 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 735dbcb4ae5..a08de2ab439 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 7a9838d74a1..a55fb848543 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);