about summary refs log tree commit diff
path: root/src/rustc/metadata/decoder.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-07-11 15:00:40 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-07-17 15:46:43 -0700
commitdb020ab63cd51dd4a25cba2d00117f016128762b (patch)
tree2b6f1e99ba4356f3e3bf5338332c278d2a85109b /src/rustc/metadata/decoder.rs
parentb5729bd60095fb5ca884936775e031cf19900760 (diff)
rustc: Implement and enforce instance coherence
Diffstat (limited to 'src/rustc/metadata/decoder.rs')
-rw-r--r--src/rustc/metadata/decoder.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs
index 45bdee06070..c9b214134a7 100644
--- a/src/rustc/metadata/decoder.rs
+++ b/src/rustc/metadata/decoder.rs
@@ -2,6 +2,7 @@
 
 import std::{ebml, map};
 import std::map::{hashmap, str_hash};
+import dvec::{dvec, extensions};
 import io::writer_util;
 import syntax::{ast, ast_util};
 import syntax::attr;
@@ -37,6 +38,7 @@ export get_crate_hash;
 export get_crate_vers;
 export get_impls_for_mod;
 export get_trait_methods;
+export get_method_names_if_trait;
 export get_crate_module_paths;
 export def_like;
 export dl_def;
@@ -640,6 +642,23 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
     @result
 }
 
+// If the item in question is a trait, returns its set of methods. Otherwise,
+// returns none.
+fn get_method_names_if_trait(cdata: cmd, node_id: ast::node_id)
+                          -> option<@dvec<@~str>> {
+
+    let item = lookup_item(node_id, cdata.data);
+    if item_family(item) != 'I' {
+        ret none;
+    }
+
+    let resulting_method_names = @dvec();
+    do ebml::tagged_docs(item, tag_item_trait_method) |method| {
+        (*resulting_method_names).push(item_name(method));
+    }
+    ret some(resulting_method_names);
+}
+
 // Helper function that gets either fields or methods
 fn get_class_members(cdata: cmd, id: ast::node_id,
                      p: fn(char) -> bool) -> ~[ty::field_ty] {