rustc: Resolve external modules and native modules to definition IDs as well

This commit is contained in:
Patrick Walton 2011-03-29 14:46:42 -07:00
parent 77f85460e6
commit 94c061729b
2 changed files with 22 additions and 11 deletions

View File

@ -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);

View File

@ -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);