diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-07-11 15:00:40 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-07-17 15:46:43 -0700 |
| commit | db020ab63cd51dd4a25cba2d00117f016128762b (patch) | |
| tree | 2b6f1e99ba4356f3e3bf5338332c278d2a85109b /src/rustc/metadata | |
| parent | b5729bd60095fb5ca884936775e031cf19900760 (diff) | |
| download | rust-db020ab63cd51dd4a25cba2d00117f016128762b.tar.gz rust-db020ab63cd51dd4a25cba2d00117f016128762b.zip | |
rustc: Implement and enforce instance coherence
Diffstat (limited to 'src/rustc/metadata')
| -rw-r--r-- | src/rustc/metadata/csearch.rs | 9 | ||||
| -rw-r--r-- | src/rustc/metadata/decoder.rs | 19 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 22d70f86eb8..56d6dcab106 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -10,6 +10,7 @@ import syntax::diagnostic::span_handler; import syntax::diagnostic::expect; import common::*; import std::map::hashmap; +import dvec::{dvec, extensions}; export class_dtor; export get_symbol; @@ -23,6 +24,7 @@ export lookup_method_purity; export get_enum_variants; export get_impls_for_mod; export get_trait_methods; +export get_method_names_if_trait; export each_path; export get_type; export get_impl_trait; @@ -140,6 +142,13 @@ fn get_trait_methods(tcx: ty::ctxt, def: ast::def_id) -> @~[ty::method] { decoder::get_trait_methods(cdata, def.node, tcx) } +fn get_method_names_if_trait(cstore: cstore::cstore, def: ast::def_id) + -> option<@dvec<@~str>> { + + let cdata = cstore::get_crate_data(cstore, def.crate); + ret decoder::get_method_names_if_trait(cdata, def.node); +} + fn get_class_fields(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::field_ty] { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); 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] { |
