From 0a3626161d5ebb1d2c6839773b0e533d3ec4589c Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 16 Dec 2011 14:17:52 +0100 Subject: [PATCH] Write impl data to crate library files (No one is actually reading it yet.) Issue #1227 --- src/comp/metadata/common.rs | 4 ++++ src/comp/metadata/encoder.rs | 38 +++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/comp/metadata/common.rs b/src/comp/metadata/common.rs index 60b1236398e..4376a50e9b4 100644 --- a/src/comp/metadata/common.rs +++ b/src/comp/metadata/common.rs @@ -66,6 +66,10 @@ const tag_items_data_item_inlineness: uint = 0x27u; const tag_crate_hash: uint = 0x28u; +const tag_mod_impl: uint = 0x30u; + +const tag_impl_method: uint = 0x31u; + // djb's cdb hashes. fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); } diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index c013ec614ed..8b716f8a444 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -137,6 +137,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, module: _mod, path: [str], encode_def_id(ebml_w, local_def(it.id)); ebml::end_tag(ebml_w); } + item_impl(_, _, _) {} } } } @@ -278,10 +279,20 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_symbol(ecx, ebml_w, item.id); ebml::end_tag(ebml_w); } - item_mod(_) { + item_mod(m) { ebml::start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, local_def(item.id)); encode_family(ebml_w, 'm' as u8); + for i in m.items { + alt i.node { + item_impl(_, _, _) { + ebml::start_tag(ebml_w, tag_mod_impl); + ebml_w.writer.write(str::bytes(def_to_str(local_def(i.id)))); + ebml::end_tag(ebml_w); + } + _ {} + } + } ebml::end_tag(ebml_w); } item_native_mod(_) { @@ -349,6 +360,31 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_symbol(ecx, ebml_w, ctor_id); ebml::end_tag(ebml_w); } + item_impl(tps, _, methods) { + ebml::start_tag(ebml_w, tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'I' as u8); + encode_type_param_kinds(ebml_w, tps); + encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id)); + for m in methods { + ebml::start_tag(ebml_w, tag_impl_method); + ebml_w.writer.write(str::bytes(def_to_str(local_def(m.node.id)))); + ebml::end_tag(ebml_w); + } + ebml::end_tag(ebml_w); + + for m in methods { + index += [{val: m.node.id, pos: ebml_w.writer.tell()}]; + ebml::start_tag(ebml_w, tag_items_data_item); + encode_def_id(ebml_w, local_def(m.node.id)); + encode_family(ebml_w, 'i' as u8); + encode_type_param_kinds(ebml_w, tps + m.node.tps); + encode_type(ecx, ebml_w, + node_id_to_monotype(ecx.ccx.tcx, m.node.id)); + encode_symbol(ecx, ebml_w, m.node.id); + ebml::end_tag(ebml_w); + } + } } }