about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-01-05 13:57:27 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-05 14:17:31 +0100
commit3a20dda7eacf84faa64be0031c67e2169928962f (patch)
tree60d68fa16d378d7c7122a943f63964a835b49187
parent38c3bd9057b4fe0dace2da9d8925038fc1aaf5b4 (diff)
downloadrust-3a20dda7eacf84faa64be0031c67e2169928962f.tar.gz
rust-3a20dda7eacf84faa64be0031c67e2169928962f.zip
Get external interfaces / impls working
Issue #1227
-rw-r--r--src/comp/metadata/common.rs3
-rw-r--r--src/comp/metadata/csearch.rs30
-rw-r--r--src/comp/metadata/decoder.rs121
-rw-r--r--src/comp/metadata/encoder.rs54
-rw-r--r--src/comp/metadata/tydecode.rs25
-rw-r--r--src/comp/metadata/tyencode.rs7
-rw-r--r--src/comp/middle/resolve.rs2
-rw-r--r--src/comp/middle/trans.rs5
-rw-r--r--src/comp/middle/trans_impl.rs12
-rw-r--r--src/comp/middle/ty.rs2
10 files changed, 152 insertions, 109 deletions
diff --git a/src/comp/metadata/common.rs b/src/comp/metadata/common.rs
index 2e732aea249..db415d5d31a 100644
--- a/src/comp/metadata/common.rs
+++ b/src/comp/metadata/common.rs
@@ -66,8 +66,9 @@ const tag_crate_hash: uint = 0x28u;
 
 const tag_mod_impl: uint = 0x30u;
 
-const tag_impl_method: uint = 0x31u;
+const tag_item_method: uint = 0x31u;
 const tag_impl_iface: uint = 0x32u;
+const tag_impl_iface_did: uint = 0x33u;
 
 // djb's cdb hashes.
 fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
diff --git a/src/comp/metadata/csearch.rs b/src/comp/metadata/csearch.rs
index 2e57e4e97e9..364dd7aef21 100644
--- a/src/comp/metadata/csearch.rs
+++ b/src/comp/metadata/csearch.rs
@@ -10,7 +10,7 @@ export get_type_param_count;
 export lookup_defs;
 export get_tag_variants;
 export get_impls_for_mod;
-export get_impl_methods;
+export get_iface_methods;
 export get_type;
 export get_item_name;
 export get_impl_iface;
@@ -66,33 +66,23 @@ fn get_tag_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {
 
 fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id,
                      name: option::t<ast::ident>)
-    -> [@middle::resolve::_impl] {
+    -> @[@middle::resolve::_impl] {
     let cdata = cstore::get_crate_data(cstore, def.crate).data;
-    let result = [];
-    for did in decoder::get_impls_for_mod(cdata, def.node, def.crate) {
-        let nm = decoder::lookup_item_name(cdata, did.node);
-        if alt name { some(n) { n == nm } none. { true } } {
-            result += [@{did: did,
-                         iface_did: none::<ast::def_id>, // FIXME[impl]
-                         ident: nm,
-                         methods: decoder::lookup_impl_methods(
-                             cdata, did.node, did.crate)}];
-        }
-    }
-    result
+    let resolver = bind translate_def_id(cstore, def.crate, _);
+    decoder::get_impls_for_mod(cdata, def, name, resolver)
 }
 
-fn get_impl_methods(cstore: cstore::cstore, def: ast::def_id)
-    -> [@middle::resolve::method_info] {
+fn get_iface_methods(tcx: ty::ctxt, def: ast::def_id) -> @[ty::method] {
+    let cstore = tcx.sess.get_cstore();
     let cdata = cstore::get_crate_data(cstore, def.crate).data;
-    decoder::lookup_impl_methods(cdata, def.node, def.crate)
+    let resolver = bind translate_def_id(cstore, def.crate, _);
+    decoder::get_iface_methods(cdata, def, tcx, resolver)
 }
 
 fn get_type(tcx: ty::ctxt, def: ast::def_id) -> ty::ty_param_bounds_and_ty {
     let cstore = tcx.sess.get_cstore();
-    let cnum = def.crate;
-    let cdata = cstore::get_crate_data(cstore, cnum).data;
-    let resolver = bind translate_def_id(cstore, cnum, _);
+    let cdata = cstore::get_crate_data(cstore, def.crate).data;
+    let resolver = bind translate_def_id(cstore, def.crate, _);
     decoder::get_type(cdata, def, tcx, resolver)
 }
 
diff --git a/src/comp/metadata/decoder.rs b/src/comp/metadata/decoder.rs
index 269b6500ac9..95bd8e5811d 100644
--- a/src/comp/metadata/decoder.rs
+++ b/src/comp/metadata/decoder.rs
@@ -26,7 +26,7 @@ export get_crate_deps;
 export get_crate_hash;
 export external_resolver;
 export get_impls_for_mod;
-export lookup_impl_methods;
+export get_iface_methods;
 // A function that takes a def_id relative to the crate being searched and
 // returns a def_id relative to the compilation environment, i.e. if we hit a
 // def_id for an item defined in another crate, somebody needs to figure out
@@ -105,16 +105,19 @@ fn parse_external_def_id(this_cnum: ast::crate_num,
     } else { ret extres(external_def_id); }
 }
 
+fn doc_type(doc: ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
+            extres: external_resolver) -> ty::t {
+    let tp = ebml::get_doc(doc, tag_items_data_item_type);
+    let def_parser = bind parse_external_def_id(this_cnum, extres, _);
+    parse_ty_data(tp.data, this_cnum, tp.start, def_parser, tcx)
+}
+
 fn item_type(item: ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
              extres: external_resolver) -> ty::t {
-    let tp = ebml::get_doc(item, tag_items_data_item_type);
-    let def_parser = bind parse_external_def_id(this_cnum, extres, _);
-    let t = parse_ty_data(item.data, this_cnum, tp.start, tp.end - tp.start,
-                          def_parser, tcx);
+    let t = doc_type(item, this_cnum, tcx, extres);
     if family_names_type(item_family(item)) {
-        t = ty::mk_named(tcx, t, @item_name(item));
-    }
-    t
+        ty::mk_named(tcx, t, @item_name(item))
+    } else { t }
 }
 
 fn item_impl_iface(item: ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
@@ -122,21 +125,32 @@ fn item_impl_iface(item: ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
     let result = none;
     ebml::tagged_docs(item, tag_impl_iface) {|ity|
         let def_parser = bind parse_external_def_id(this_cnum, extres, _);
-        let t = parse_ty_data(ity.data, this_cnum, ity.start,
-                              ity.end - ity.start, def_parser, tcx);
+        let t = parse_ty_data(ity.data, this_cnum, ity.start, def_parser,
+                              tcx);
         result = some(t);
     }
     result
 }
 
+fn item_impl_iface_did(item: ebml::doc, this_cnum: ast::crate_num,
+                       extres: external_resolver)
+    -> option::t<ast::def_id> {
+    let result = none;
+    ebml::tagged_docs(item, tag_impl_iface_did) {|doc|
+        let s = str::unsafe_from_bytes(ebml::doc_data(doc));
+        result = some(parse_external_def_id(this_cnum, extres, s));
+    }
+    result
+}
+
 fn item_ty_param_bounds(item: ebml::doc, this_cnum: ast::crate_num,
                         tcx: ty::ctxt, extres: external_resolver)
     -> @[ty::param_bounds] {
     let bounds = [];
     let def_parser = bind parse_external_def_id(this_cnum, extres, _);
     ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) {|p|
-        bounds += [tydecode::parse_bounds_data(@ebml::doc_data(p), this_cnum,
-                                               def_parser, tcx)];
+        bounds += [tydecode::parse_bounds_data(p.data, p.start,
+                                               this_cnum, def_parser, tcx)];
     }
     @bounds
 }
@@ -211,18 +225,17 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
             tid = {crate: cnum, node: tid.node};
             ast::def_variant(tid, did)
           }
+          'I' { ast::def_ty(did) }
         };
     ret def;
 }
 
 fn get_type(data: @[u8], def: ast::def_id, tcx: ty::ctxt,
             extres: external_resolver) -> ty::ty_param_bounds_and_ty {
-    let this_cnum = def.crate;
-    let node_id = def.node;
-    let item = lookup_item(node_id, data);
-    let t = item_type(item, this_cnum, tcx, extres);
+    let item = lookup_item(def.node, data);
+    let t = item_type(item, def.crate, tcx, extres);
     let tp_bounds = if family_has_type_params(item_family(item)) {
-        item_ty_param_bounds(item, this_cnum, tcx, extres)
+        item_ty_param_bounds(item, def.crate, tcx, extres)
     } else { @[] };
     ret {bounds: tp_bounds, ty: t};
 }
@@ -264,51 +277,59 @@ fn get_tag_variants(_data: @[u8], def: ast::def_id, tcx: ty::ctxt,
     ret infos;
 }
 
-fn get_impls_for_mod(data: @[u8], node: ast::node_id, cnum: ast::crate_num)
-    -> [ast::def_id] {
-    let mod_item = lookup_item(node, data), result = [];
-    ebml::tagged_docs(mod_item, tag_mod_impl) {|doc|
-        let did = parse_def_id(ebml::doc_data(doc));
-        result += [{crate: cnum with did}];
-    }
-    result
-}
-
-fn lookup_impl_methods(data: @[u8], node: ast::node_id, cnum: ast::crate_num)
+fn item_impl_methods(data: @[u8], item: ebml::doc, base_tps: uint)
     -> [@middle::resolve::method_info] {
-    let impl_item = lookup_item(node, data), rslt = [];
-    let base_tps = item_ty_param_count(impl_item);
-    ebml::tagged_docs(impl_item, tag_impl_method) {|doc|
+    let rslt = [];
+    ebml::tagged_docs(item, tag_item_method) {|doc|
         let m_did = parse_def_id(ebml::doc_data(doc));
         let mth_item = lookup_item(m_did.node, data);
-        rslt += [@{did: {crate: cnum, node: m_did.node},
+        rslt += [@{did: m_did,
                    n_tps: item_ty_param_count(mth_item) - base_tps,
                    ident: item_name(mth_item)}];
     }
     rslt
 }
 
+fn get_impls_for_mod(data: @[u8], m_def: ast::def_id,
+                     name: option::t<ast::ident>, extres: external_resolver)
+    -> @[@middle::resolve::_impl] {
+    let mod_item = lookup_item(m_def.node, data), result = [];
+    ebml::tagged_docs(mod_item, tag_mod_impl) {|doc|
+        let did = parse_external_def_id(
+            m_def.crate, extres, str::unsafe_from_bytes(ebml::doc_data(doc)));
+        let item = lookup_item(did.node, data), nm = item_name(item);
+        if alt name { some(n) { n == nm } none. { true } } {
+            let base_tps = item_ty_param_count(doc);
+            let i_did = item_impl_iface_did(item, m_def.crate, extres);
+            result += [@{did: did, iface_did: i_did, ident: nm,
+                         methods: item_impl_methods(data, doc, base_tps)}];
+        }
+    }
+    @result
+}
+
+fn get_iface_methods(data: @[u8], def: ast::def_id, tcx: ty::ctxt,
+                     extres: external_resolver) -> @[ty::method] {
+    let item = lookup_item(def.node, data), result = [];
+    ebml::tagged_docs(item, tag_item_method) {|mth|
+        let bounds = item_ty_param_bounds(mth, def.crate, tcx, extres);
+        let name = item_name(mth);
+        let ty = doc_type(mth, def.crate, tcx, extres);
+        let fty = alt ty::struct(tcx, ty) { ty::ty_fn(f) { f } };
+        result += [{ident: name, tps: bounds, fty: fty}];
+    }
+    @result
+}
+
 fn family_has_type_params(fam_ch: u8) -> bool {
-    ret alt fam_ch as char {
-          'c' { false }
-          'f' { true }
-          'u' { true }
-          'p' { true }
-          'F' { true }
-          'U' { true }
-          'P' { true }
-          'y' { true }
-          't' { true }
-          'T' { false }
-          'm' { false }
-          'n' { false }
-          'v' { true }
-          'i' { true }
-        };
+    alt fam_ch as char {
+      'c' | 'T' | 'm' | 'n' { false }
+      'f' | 'u' | 'p' | 'F' | 'U' | 'P' | 'y' | 't' | 'v' | 'i' | 'I' { true }
+    }
 }
 
 fn family_names_type(fam_ch: u8) -> bool {
-    alt fam_ch as char { 'y' | 't' { true } _ { false } }
+    alt fam_ch as char { 'y' | 't' | 'I' { true } _ { false } }
 }
 
 fn read_path(d: ebml::doc) -> {path: str, pos: uint} {
@@ -339,6 +360,8 @@ fn item_family_to_str(fam: u8) -> str {
       'm' { ret "mod"; }
       'n' { ret "native mod"; }
       'v' { ret "tag"; }
+      'i' { ret "impl"; }
+      'I' { ret "iface"; }
     }
 }
 
diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs
index 2ea9d418a7f..8c564ec627a 100644
--- a/src/comp/metadata/encoder.rs
+++ b/src/comp/metadata/encoder.rs
@@ -277,12 +277,13 @@ fn encode_info_for_mod(ebml_w: ebml::writer, md: _mod,
 
 fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
                         &index: [entry<int>]) {
+    let tcx = ecx.ccx.tcx;
     alt item.node {
       item_const(_, _) {
         ebml::start_tag(ebml_w, tag_items_data_item);
         encode_def_id(ebml_w, local_def(item.id));
         encode_family(ebml_w, 'c' as u8);
-        encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
+        encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
         encode_symbol(ecx, ebml_w, item.id);
         ebml::end_tag(ebml_w);
       }
@@ -296,7 +297,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
                         impure_fn. { 'f' }
                       } as u8);
         encode_type_param_bounds(ebml_w, ecx, tps);
-        encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
+        encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
         encode_symbol(ecx, ebml_w, item.id);
         ebml::end_tag(ebml_w);
       }
@@ -315,7 +316,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
         encode_def_id(ebml_w, local_def(item.id));
         encode_family(ebml_w, 'y' as u8);
         encode_type_param_bounds(ebml_w, ecx, tps);
-        encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
+        encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
         encode_name(ebml_w, item.ident);
         ebml::end_tag(ebml_w);
       }
@@ -324,7 +325,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
         encode_def_id(ebml_w, local_def(item.id));
         encode_family(ebml_w, 't' as u8);
         encode_type_param_bounds(ebml_w, ecx, tps);
-        encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
+        encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
         encode_name(ebml_w, item.ident);
         for v: variant in variants {
             encode_variant_id(ebml_w, local_def(v.node.id));
@@ -333,13 +334,13 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
         encode_tag_variant_info(ecx, ebml_w, item.id, variants, index, tps);
       }
       item_res(_, tps, _, _, ctor_id) {
-        let fn_ty = node_id_to_monotype(ecx.ccx.tcx, ctor_id);
+        let fn_ty = node_id_to_monotype(tcx, ctor_id);
 
         ebml::start_tag(ebml_w, tag_items_data_item);
         encode_def_id(ebml_w, local_def(ctor_id));
         encode_family(ebml_w, 'y' as u8);
         encode_type_param_bounds(ebml_w, ecx, tps);
-        encode_type(ecx, ebml_w, ty::ty_fn_ret(ecx.ccx.tcx, fn_ty));
+        encode_type(ecx, ebml_w, ty::ty_fn_ret(tcx, fn_ty));
         encode_name(ebml_w, item.ident);
         encode_symbol(ecx, ebml_w, item.id);
         ebml::end_tag(ebml_w);
@@ -354,13 +355,13 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
         ebml::end_tag(ebml_w);
       }
       item_obj(_, tps, ctor_id) {
-        let fn_ty = node_id_to_monotype(ecx.ccx.tcx, ctor_id);
+        let fn_ty = node_id_to_monotype(tcx, ctor_id);
 
         ebml::start_tag(ebml_w, tag_items_data_item);
         encode_def_id(ebml_w, local_def(item.id));
         encode_family(ebml_w, 'y' as u8);
         encode_type_param_bounds(ebml_w, ecx, tps);
-        encode_type(ecx, ebml_w, ty::ty_fn_ret(ecx.ccx.tcx, fn_ty));
+        encode_type(ecx, ebml_w, ty::ty_fn_ret(tcx, fn_ty));
         encode_name(ebml_w, item.ident);
         ebml::end_tag(ebml_w);
 
@@ -378,18 +379,26 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
         encode_def_id(ebml_w, local_def(item.id));
         encode_family(ebml_w, 'i' as u8);
         encode_type_param_bounds(ebml_w, ecx, tps);
-        encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
+        encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
         encode_name(ebml_w, item.ident);
         for m in methods {
-            ebml::start_tag(ebml_w, tag_impl_method);
+            ebml::start_tag(ebml_w, tag_item_method);
             ebml_w.writer.write(str::bytes(def_to_str(local_def(m.id))));
             ebml::end_tag(ebml_w);
         }
         alt ifce {
           some(_) {
+            encode_symbol(ecx, ebml_w, item.id);
+            let i_ty = ty::lookup_item_type(tcx, local_def(item.id)).ty;
             ebml::start_tag(ebml_w, tag_impl_iface);
-            write_type(ecx, ebml_w, ty::lookup_item_type(
-                ecx.ccx.tcx, local_def(item.id)).ty);
+            write_type(ecx, ebml_w, i_ty);
+            ebml::end_tag(ebml_w);
+            ebml::start_tag(ebml_w, tag_impl_iface_did);
+            alt ty::struct(tcx, i_ty) {
+              ty::ty_iface(did, _) {
+                ebml_w.writer.write(str::bytes(def_to_str(did)));
+              }
+            }
             ebml::end_tag(ebml_w);
           }
           _ {}
@@ -403,13 +412,30 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
             encode_family(ebml_w, 'f' as u8);
             encode_type_param_bounds(ebml_w, ecx, tps + m.tps);
             encode_type(ecx, ebml_w,
-                        node_id_to_monotype(ecx.ccx.tcx, m.id));
+                        node_id_to_monotype(tcx, m.id));
             encode_name(ebml_w, m.ident);
             encode_symbol(ecx, ebml_w, m.id);
             ebml::end_tag(ebml_w);
         }
       }
-      item_iface(_, _) { /* FIXME[impl] */ }
+      item_iface(tps, ms) {
+        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_bounds(ebml_w, ecx, tps);
+        encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
+        encode_name(ebml_w, item.ident);
+        let i = 0u;
+        for mty in *ty::iface_methods(tcx, local_def(item.id)) {
+            ebml::start_tag(ebml_w, tag_item_method);
+            encode_name(ebml_w, mty.ident);
+            encode_type_param_bounds(ebml_w, ecx, ms[i].tps);
+            encode_type(ecx, ebml_w, ty::mk_fn(tcx, mty.fty));
+            ebml::end_tag(ebml_w);
+            i += 1u;
+        }
+        ebml::end_tag(ebml_w);
+      }
     }
 }
 
diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs
index 1a083bf8fb6..9e87a17537b 100644
--- a/src/comp/metadata/tydecode.rs
+++ b/src/comp/metadata/tydecode.rs
@@ -19,11 +19,10 @@ export parse_bounds_data;
 // Callback to translate defs to strs or back:
 type str_def = fn@(str) -> ast::def_id;
 
-type pstate =
-    {data: @[u8], crate: int, mutable pos: uint, len: uint, tcx: ty::ctxt};
+type pstate = {data: @[u8], crate: int, mutable pos: uint, tcx: ty::ctxt};
 
 fn peek(st: @pstate) -> u8 {
-    if st.pos < vec::len(*st.data) { st.data[st.pos] } else { 0u8 }
+    st.data[st.pos]
 }
 
 fn next(st: @pstate) -> u8 {
@@ -47,10 +46,9 @@ fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn@(char) -> bool) ->
 }
 
 
-fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, len: uint,
-                 sd: str_def, tcx: ty::ctxt) -> ty::t {
-    let st =
-        @{data: data, crate: crate_num, mutable pos: pos, len: len, tcx: tcx};
+fn parse_ty_data(data: @[u8], crate_num: int, pos: uint, sd: str_def,
+                 tcx: ty::ctxt) -> ty::t {
+    let st = @{data: data, crate: crate_num, mutable pos: pos, tcx: tcx};
     parse_ty(st, sd)
 }
 
@@ -295,7 +293,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
         alt st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) {
           some(tt) { ret tt; }
           none. {
-            let ps = @{pos: pos, len: len with *st};
+            let ps = @{pos: pos with *st};
             let tt = parse_ty(ps, sd);
             st.tcx.rcache.insert({cnum: st.crate, pos: pos, len: len}, tt);
             ret tt;
@@ -381,7 +379,7 @@ fn parse_ty_fn(st: @pstate, sd: str_def) -> ty::fn_ty {
 // Rust metadata parsing
 fn parse_def_id(buf: [u8]) -> ast::def_id {
     let colon_idx = 0u;
-    let len = vec::len::<u8>(buf);
+    let len = vec::len(buf);
     while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; }
     if colon_idx == len {
         #error("didn't find ':' when parsing def id");
@@ -400,20 +398,21 @@ fn parse_def_id(buf: [u8]) -> ast::def_id {
     ret {crate: crate_num, node: def_num};
 }
 
-fn parse_bounds_data(data: @[u8], crate_num: int, sd: str_def, tcx: ty::ctxt)
+fn parse_bounds_data(data: @[u8], start: uint,
+                     crate_num: int, sd: str_def, tcx: ty::ctxt)
     -> @[ty::param_bound] {
-    let st = @{data: data, crate: crate_num, mutable pos: 0u,
-               len: vec::len(*data), tcx: tcx};
+    let st = @{data: data, crate: crate_num, mutable pos: start, tcx: tcx};
     parse_bounds(st, sd)
 }
 
 fn parse_bounds(st: @pstate, sd: str_def) -> @[ty::param_bound] {
     let bounds = [];
-    while peek(st) != 0u8 {
+    while true {
         bounds += [alt next(st) as char {
           'S' { ty::bound_send }
           'C' { ty::bound_copy }
           'I' { ty::bound_iface(parse_ty(st, sd)) }
+          '.' { break; }
         }];
     }
     @bounds
diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs
index 73d44472723..2ba572154c5 100644
--- a/src/comp/metadata/tyencode.rs
+++ b/src/comp/metadata/tyencode.rs
@@ -66,10 +66,8 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
             let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len);
             if abbrev_len < len {
                 // I.e. it's actually an abbreviation.
-
-                let s =
-                    "#" + uint::to_str(pos, 16u) + ":" +
-                        uint::to_str(len, 16u) + "#";
+                let s = "#" + uint::to_str(pos, 16u) + ":" +
+                    uint::to_str(len, 16u) + "#";
                 let a = {pos: pos, len: len, s: @s};
                 abbrevs.insert(t, a);
             }
@@ -282,6 +280,7 @@ fn enc_bounds(w: io::writer, cx: @ctxt, bs: @[ty::param_bound]) {
           }
         }
     }
+    w.write_char('.');
 }
 
 //
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index 29d29a32fba..01be1c4409f 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -1827,7 +1827,7 @@ fn find_impls_in_mod(e: env, m: def, &impls: [@_impl],
                 }
                 @tmp
             } else {
-                @csearch::get_impls_for_mod(e.cstore, defid, name)
+                csearch::get_impls_for_mod(e.sess.get_cstore(), defid, name)
             };
             e.impl_cache.insert(defid, cached);
           }
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index c279c0a9b49..4325f0af52b 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -5039,8 +5039,8 @@ fn trans_item(cx: @local_ctxt, item: ast::item) {
                  with *extend_path(cx, item.ident)};
         trans_obj(sub_cx, item.span, ob, ctor_id, tps);
       }
-      ast::item_impl(tps, ifce, _, ms) {
-        trans_impl::trans_impl(cx, item.ident, ms, item.id, tps, ifce);
+      ast::item_impl(tps, _, _, ms) {
+        trans_impl::trans_impl(cx, item.ident, ms, item.id, tps);
       }
       ast::item_res(decl, tps, body, dtor_id, ctor_id) {
         trans_res_ctor(cx, item.span, decl, ctor_id, tps);
@@ -5436,6 +5436,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item, &&pt: [str],
         llvm::LLVMSetInitializer(vt_gvar, tbl);
         llvm::LLVMSetGlobalConstant(vt_gvar, True);
         ccx.item_ids.insert(it.id, vt_gvar);
+        ccx.item_symbols.insert(it.id, s);
       }
       _ { }
     }
diff --git a/src/comp/middle/trans_impl.rs b/src/comp/middle/trans_impl.rs
index 04bff49877f..bddfbb03e6e 100644
--- a/src/comp/middle/trans_impl.rs
+++ b/src/comp/middle/trans_impl.rs
@@ -3,13 +3,13 @@ import trans_common::*;
 import trans_build::*;
 import option::{some, none};
 import syntax::{ast, ast_util};
+import metadata::csearch;
 import back::link;
 import lib::llvm;
 import llvm::llvm::{ValueRef, TypeRef, LLVMGetParam};
 
 fn trans_impl(cx: @local_ctxt, name: ast::ident, methods: [@ast::method],
-              id: ast::node_id, tps: [ast::ty_param],
-              _ifce: option::t<@ast::ty>) {
+              id: ast::node_id, tps: [ast::ty_param]) {
     let sub_cx = extend_path(cx, name);
     for m in methods {
         alt cx.ccx.item_ids.find(m.id) {
@@ -136,8 +136,12 @@ fn get_dict(bcx: @block_ctxt, origin: typeck::dict_origin) -> result {
     let bcx = bcx, ccx = bcx_ccx(bcx);
     alt origin {
       typeck::dict_static(impl_did, tys, sub_origins) {
-        assert impl_did.crate == ast::local_crate; // FIXME[impl]
-        let vtable = ccx.item_ids.get(impl_did.node);
+        let vtable = if impl_did.crate == ast::local_crate {
+            ccx.item_ids.get(impl_did.node)
+        } else {
+            let name = csearch::get_symbol(ccx.sess.get_cstore(), impl_did);
+            get_extern_const(ccx.externs, ccx.llmod, name, T_ptr(T_i8()))
+        };
         let impl_params = ty::lookup_item_type(ccx.tcx, impl_did).bounds;
         let ptrs = [vtable], i = 0u, origin = 0u, ti = none;
         for param in *impl_params {
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 95e84483be6..76a3591cd18 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -2665,7 +2665,7 @@ fn iface_methods(cx: ctxt, id: ast::def_id) -> @[method] {
     }
     // Local interfaces are supposed to have been added explicitly.
     assert id.crate != ast::local_crate;
-    let result = @[]; // FIXME[impl]
+    let result = csearch::get_iface_methods(cx, id);
     cx.iface_method_cache.insert(id, result);
     result
 }