Write impl data to crate library files

(No one is actually reading it yet.)

Issue #1227
This commit is contained in:
Marijn Haverbeke 2011-12-16 14:17:52 +01:00
parent d529757515
commit 0a3626161d
2 changed files with 41 additions and 1 deletions

View File

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

View File

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