about summary refs log tree commit diff
path: root/src/comp/metadata
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-01-26 17:33:12 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-26 18:58:35 +0100
commitc590bdeea41f5476f42c6a7cb067e162328bdbc2 (patch)
treec728974e1ceab0b3598b47e97811cf6201840322 /src/comp/metadata
parent6bead0e4ccfa65a89bee8db6d4587e297fba1a57 (diff)
Make re-exporting of impls work
Closes #1438
Diffstat (limited to 'src/comp/metadata')
-rw-r--r--src/comp/metadata/encoder.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs
index 31db8561dec..a3bc668ad9d 100644
--- a/src/comp/metadata/encoder.rs
+++ b/src/comp/metadata/encoder.rs
@@ -1,6 +1,6 @@
 // Metadata encoding
 
-import std::{io, ebml, map};
+import std::{io, ebml, map, list};
 import io::writer_util;
 import syntax::ast::*;
 import syntax::ast_util;
@@ -151,13 +151,14 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
 
 fn encode_reexport_paths(ebml_w: ebml::writer,
                          ecx: @encode_ctxt, &index: [entry<str>]) {
-    ecx.ccx.exp_map.items {|key, def|
-        let path = key.path;
-        index += [{val: path, pos: ebml_w.writer.tell()}];
-        ebml::start_tag(ebml_w, tag_paths_data_item);
-        encode_name(ebml_w, path);
-        encode_def_id(ebml_w, ast_util::def_id_of_def(def));
-        ebml::end_tag(ebml_w);
+    ecx.ccx.exp_map.items {|path, defs|
+        for def in *defs {
+            index += [{val: path, pos: ebml_w.writer.tell()}];
+            ebml::start_tag(ebml_w, tag_paths_data_item);
+            encode_name(ebml_w, path);
+            encode_def_id(ebml_w, ast_util::def_id_of_def(def));
+            ebml::end_tag(ebml_w);
+        }
     }
 }
 
@@ -258,23 +259,22 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
     }
 }
 
-fn encode_info_for_mod(ebml_w: ebml::writer, md: _mod,
+fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
                        id: node_id, name: ident) {
     ebml::start_tag(ebml_w, tag_items_data_item);
     encode_def_id(ebml_w, local_def(id));
     encode_family(ebml_w, 'm' as u8);
     encode_name(ebml_w, name);
-    for i in md.items {
-        alt i.node {
-          item_impl(_, _, _, _) {
+    alt ecx.ccx.impl_map.get(id) {
+      list::cons(impls, @list::nil) {
+        for i in *impls {
             if ast_util::is_exported(i.ident, md) {
                 ebml::start_tag(ebml_w, tag_mod_impl);
-                ebml_w.writer.write(str::bytes(def_to_str(local_def(i.id))));
+                ebml_w.writer.write(str::bytes(def_to_str(i.did)));
                 ebml::end_tag(ebml_w);
             }
-          }
-          _ {}
         }
+      }
     }
     ebml::end_tag(ebml_w);
 }
@@ -306,7 +306,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
         ebml::end_tag(ebml_w);
       }
       item_mod(m) {
-        encode_info_for_mod(ebml_w, m, item.id, item.ident);
+        encode_info_for_mod(ecx, ebml_w, m, item.id, item.ident);
       }
       item_native_mod(_) {
         ebml::start_tag(ebml_w, tag_items_data_item);
@@ -447,7 +447,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
     let index: [entry<int>] = [];
     ebml::start_tag(ebml_w, tag_items_data);
     index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
-    encode_info_for_mod(ebml_w, crate_mod, crate_node_id, "");
+    encode_info_for_mod(ecx, ebml_w, crate_mod, crate_node_id, "");
     ecx.ccx.ast_map.items {|key, val|
         alt val {
           middle::ast_map::node_item(i) {