Skip to content

Commit 0a36261

Browse files
committed
Write impl data to crate library files
(No one is actually reading it yet.) Issue #1227
1 parent d529757 commit 0a36261

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/comp/metadata/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ const tag_items_data_item_inlineness: uint = 0x27u;
6666

6767
const tag_crate_hash: uint = 0x28u;
6868

69+
const tag_mod_impl: uint = 0x30u;
70+
71+
const tag_impl_method: uint = 0x31u;
72+
6973
// djb's cdb hashes.
7074
fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
7175

src/comp/metadata/encoder.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, module: _mod, path: [str],
137137
encode_def_id(ebml_w, local_def(it.id));
138138
ebml::end_tag(ebml_w);
139139
}
140+
item_impl(_, _, _) {}
140141
}
141142
}
142143
}
@@ -278,10 +279,20 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
278279
encode_symbol(ecx, ebml_w, item.id);
279280
ebml::end_tag(ebml_w);
280281
}
281-
item_mod(_) {
282+
item_mod(m) {
282283
ebml::start_tag(ebml_w, tag_items_data_item);
283284
encode_def_id(ebml_w, local_def(item.id));
284285
encode_family(ebml_w, 'm' as u8);
286+
for i in m.items {
287+
alt i.node {
288+
item_impl(_, _, _) {
289+
ebml::start_tag(ebml_w, tag_mod_impl);
290+
ebml_w.writer.write(str::bytes(def_to_str(local_def(i.id))));
291+
ebml::end_tag(ebml_w);
292+
}
293+
_ {}
294+
}
295+
}
285296
ebml::end_tag(ebml_w);
286297
}
287298
item_native_mod(_) {
@@ -349,6 +360,31 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
349360
encode_symbol(ecx, ebml_w, ctor_id);
350361
ebml::end_tag(ebml_w);
351362
}
363+
item_impl(tps, _, methods) {
364+
ebml::start_tag(ebml_w, tag_items_data_item);
365+
encode_def_id(ebml_w, local_def(item.id));
366+
encode_family(ebml_w, 'I' as u8);
367+
encode_type_param_kinds(ebml_w, tps);
368+
encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
369+
for m in methods {
370+
ebml::start_tag(ebml_w, tag_impl_method);
371+
ebml_w.writer.write(str::bytes(def_to_str(local_def(m.node.id))));
372+
ebml::end_tag(ebml_w);
373+
}
374+
ebml::end_tag(ebml_w);
375+
376+
for m in methods {
377+
index += [{val: m.node.id, pos: ebml_w.writer.tell()}];
378+
ebml::start_tag(ebml_w, tag_items_data_item);
379+
encode_def_id(ebml_w, local_def(m.node.id));
380+
encode_family(ebml_w, 'i' as u8);
381+
encode_type_param_kinds(ebml_w, tps + m.node.tps);
382+
encode_type(ecx, ebml_w,
383+
node_id_to_monotype(ecx.ccx.tcx, m.node.id));
384+
encode_symbol(ecx, ebml_w, m.node.id);
385+
ebml::end_tag(ebml_w);
386+
}
387+
}
352388
}
353389
}
354390

0 commit comments

Comments
 (0)