2015-11-20 06:51:18 -06:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-11-24 16:00:26 -06:00
|
|
|
use astencode;
|
|
|
|
use cstore;
|
|
|
|
use decoder;
|
|
|
|
use encoder;
|
|
|
|
use loader;
|
|
|
|
|
|
|
|
use middle::cstore::{CrateStore, CrateSource, ChildItem, FoundAst};
|
|
|
|
use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference};
|
2015-11-20 17:08:09 -06:00
|
|
|
use middle::def;
|
2015-11-20 06:51:18 -06:00
|
|
|
use middle::lang_items;
|
2016-02-29 17:36:51 -06:00
|
|
|
use middle::ty::{self, Ty, TyCtxt, VariantKind};
|
2015-11-20 06:51:18 -06:00
|
|
|
use middle::def_id::{DefId, DefIndex};
|
|
|
|
|
2015-12-03 16:11:19 -06:00
|
|
|
use rustc::front::map as hir_map;
|
2015-12-08 14:53:19 -06:00
|
|
|
use rustc::mir::repr::Mir;
|
2016-02-05 02:32:33 -06:00
|
|
|
use rustc::mir::mir_map::MirMap;
|
2015-11-24 16:00:26 -06:00
|
|
|
use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet};
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
use std::cell::RefCell;
|
2015-11-20 06:51:18 -06:00
|
|
|
use std::rc::Rc;
|
2015-11-20 17:08:09 -06:00
|
|
|
use std::path::PathBuf;
|
2015-11-20 06:51:18 -06:00
|
|
|
use syntax::ast;
|
|
|
|
use syntax::attr;
|
2015-12-03 16:11:19 -06:00
|
|
|
use syntax::parse::token;
|
2015-11-24 16:00:26 -06:00
|
|
|
use rustc_back::svh::Svh;
|
2015-11-20 17:08:09 -06:00
|
|
|
use rustc_back::target::Target;
|
2015-11-20 06:51:18 -06:00
|
|
|
use rustc_front::hir;
|
|
|
|
|
|
|
|
impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|
|
|
fn stability(&self, def: DefId) -> Option<attr::Stability>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_stability(&cdata, def.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2015-12-04 10:34:28 -06:00
|
|
|
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_deprecation(&cdata, def.index)
|
2015-12-04 10:34:28 -06:00
|
|
|
}
|
|
|
|
|
2016-03-05 16:22:44 -06:00
|
|
|
fn visibility(&self, def: DefId) -> hir::Visibility {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
|
|
|
decoder::get_visibility(&cdata, def.index)
|
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn closure_kind(&self, _tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureKind
|
2015-11-20 06:51:18 -06:00
|
|
|
{
|
|
|
|
assert!(!def_id.is_local());
|
|
|
|
let cdata = self.get_crate_data(def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::closure_kind(&cdata, def_id.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx>
|
2015-11-20 06:51:18 -06:00
|
|
|
{
|
|
|
|
assert!(!def_id.is_local());
|
|
|
|
let cdata = self.get_crate_data(def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::closure_ty(&cdata, def_id.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn item_variances(&self, def: DefId) -> ty::ItemVariances {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_item_variances(&cdata, def.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_repr_attrs(&cdata, def.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> ty::TypeScheme<'tcx>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_type(&cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> ty::GenericPredicates<'tcx>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_predicates(&cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn item_super_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> ty::GenericPredicates<'tcx>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_super_predicates(&cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_item_attrs(&cdata, def_id.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn item_symbol(&self, def: DefId) -> String
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
|
|
|
decoder::get_symbol(&cdata, def.index)
|
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn trait_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::TraitDef<'tcx>
|
2015-11-20 06:51:18 -06:00
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_trait_def(&cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn adt_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
2015-11-20 06:51:18 -06:00
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_adt_def(&self.intr, &cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2015-11-22 13:02:04 -06:00
|
|
|
fn method_arg_names(&self, did: DefId) -> Vec<String>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(did.krate);
|
|
|
|
decoder::get_method_arg_names(&cdata, did.index)
|
|
|
|
}
|
|
|
|
|
2015-12-03 16:11:19 -06:00
|
|
|
fn item_path(&self, def: DefId) -> Vec<hir_map::PathElem> {
|
2015-11-20 06:51:18 -06:00
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
let path = decoder::get_item_path(&cdata, def.index);
|
2015-11-20 06:51:18 -06:00
|
|
|
|
|
|
|
cdata.with_local_path(|cpath| {
|
|
|
|
let mut r = Vec::with_capacity(cpath.len() + path.len());
|
2015-12-02 19:31:49 -06:00
|
|
|
r.extend_from_slice(cpath);
|
|
|
|
r.extend_from_slice(&path);
|
2015-11-20 06:51:18 -06:00
|
|
|
r
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-12-03 16:11:19 -06:00
|
|
|
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
let path = decoder::get_item_path(&cdata, def.index);
|
2015-12-03 16:11:19 -06:00
|
|
|
|
|
|
|
let mut r = Vec::with_capacity(path.len() + 1);
|
|
|
|
let crate_name = hir_map::PathMod(token::intern(&cdata.name));
|
|
|
|
r.push(crate_name);
|
2015-12-02 19:31:49 -06:00
|
|
|
r.extend_from_slice(&path);
|
2015-12-03 16:11:19 -06:00
|
|
|
r
|
|
|
|
}
|
|
|
|
|
2015-11-20 06:51:18 -06:00
|
|
|
fn item_name(&self, def: DefId) -> ast::Name {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
|
|
|
decoder::get_item_name(&self.intr, &cdata, def.index)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>
|
|
|
|
{
|
|
|
|
let mut result = vec![];
|
|
|
|
let cdata = self.get_crate_data(def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::each_inherent_implementation_for_type(&cdata, def_id.index,
|
2015-11-20 06:51:18 -06:00
|
|
|
|iid| result.push(iid));
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId>
|
|
|
|
{
|
|
|
|
let mut result = vec![];
|
|
|
|
self.iter_crate_data(|_, cdata| {
|
|
|
|
decoder::each_implementation_for_trait(cdata, def_id, &mut |iid| {
|
|
|
|
result.push(iid)
|
|
|
|
})
|
|
|
|
});
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> Vec<Rc<ty::Method<'tcx>>>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_provided_trait_methods(self.intr.clone(), &cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn trait_item_def_ids(&self, def: DefId)
|
|
|
|
-> Vec<ty::ImplOrTraitItemId>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_trait_item_def_ids(&cdata, def.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(impl_def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_impl_items(&cdata, impl_def_id.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_impl_polarity(&cdata, def.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> Option<ty::TraitRef<'tcx>>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_impl_trait(&cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn custom_coerce_unsized_kind(&self, def: DefId)
|
|
|
|
-> Option<ty::adjustment::CustomCoerceUnsized>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_custom_coerce_unsized_kind(&cdata, def.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: killme
|
2016-02-29 17:36:51 -06:00
|
|
|
fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> Vec<Rc<ty::AssociatedConst<'tcx>>> {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_associated_consts(self.intr.clone(), &cdata, def.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId) -> Option<DefId>
|
2015-11-20 06:51:18 -06:00
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_trait_of_item(&cdata, def_id.index, tcx)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn impl_or_trait_item(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> ty::ImplOrTraitItem<'tcx>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
|
|
|
decoder::get_impl_or_trait_item(
|
|
|
|
self.intr.clone(),
|
2016-02-09 14:37:21 -06:00
|
|
|
&cdata,
|
2015-11-20 06:51:18 -06:00
|
|
|
def.index,
|
|
|
|
tcx)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_const_fn(&self, did: DefId) -> bool
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(did.krate);
|
|
|
|
decoder::is_const_fn(&cdata, did.index)
|
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn is_defaulted_trait(&self, trait_def_id: DefId) -> bool
|
|
|
|
{
|
2015-11-20 06:51:18 -06:00
|
|
|
let cdata = self.get_crate_data(trait_def_id.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_defaulted_trait(&cdata, trait_def_id.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn is_impl(&self, did: DefId) -> bool
|
|
|
|
{
|
2015-11-20 06:51:18 -06:00
|
|
|
let cdata = self.get_crate_data(did.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_impl(&cdata, did.index)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
2015-11-22 13:02:04 -06:00
|
|
|
fn is_default_impl(&self, impl_did: DefId) -> bool {
|
|
|
|
let cdata = self.get_crate_data(impl_did.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_default_impl(&cdata, impl_did.index)
|
2015-11-20 09:46:39 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool {
|
2015-11-20 17:08:09 -06:00
|
|
|
let cdata = self.get_crate_data(did.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_extern_item(&cdata, did.index, tcx)
|
2015-11-20 17:08:09 -06:00
|
|
|
}
|
|
|
|
|
2015-11-22 13:02:04 -06:00
|
|
|
fn is_static_method(&self, def: DefId) -> bool
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_static_method(&cdata, def.index)
|
2015-11-22 13:02:04 -06:00
|
|
|
}
|
|
|
|
|
2015-11-21 13:39:05 -06:00
|
|
|
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool
|
|
|
|
{
|
|
|
|
self.do_is_statically_included_foreign_item(id)
|
|
|
|
}
|
|
|
|
|
2015-11-22 13:02:04 -06:00
|
|
|
fn is_typedef(&self, did: DefId) -> bool {
|
|
|
|
let cdata = self.get_crate_data(did.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_typedef(&cdata, did.index)
|
2015-11-22 13:02:04 -06:00
|
|
|
}
|
|
|
|
|
2015-11-20 06:51:18 -06:00
|
|
|
fn dylib_dependency_formats(&self, cnum: ast::CrateNum)
|
2015-11-20 09:46:39 -06:00
|
|
|
-> Vec<(ast::CrateNum, LinkagePreference)>
|
2015-11-20 06:51:18 -06:00
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(cnum);
|
|
|
|
decoder::get_dylib_dependency_formats(&cdata)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn lang_items(&self, cnum: ast::CrateNum) -> Vec<(DefIndex, usize)>
|
|
|
|
{
|
|
|
|
let mut result = vec![];
|
|
|
|
let crate_data = self.get_crate_data(cnum);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::each_lang_item(&crate_data, |did, lid| {
|
2015-11-20 06:51:18 -06:00
|
|
|
result.push((did, lid)); true
|
|
|
|
});
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
fn missing_lang_items(&self, cnum: ast::CrateNum)
|
|
|
|
-> Vec<lang_items::LangItem>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(cnum);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_missing_lang_items(&cdata)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool
|
|
|
|
{
|
|
|
|
self.get_crate_data(cnum).staged_api
|
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool
|
|
|
|
{
|
|
|
|
self.get_crate_data(cnum).explicitly_linked.get()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_allocator(&self, cnum: ast::CrateNum) -> bool
|
|
|
|
{
|
|
|
|
self.get_crate_data(cnum).is_allocator()
|
|
|
|
}
|
|
|
|
|
2015-11-22 13:02:04 -06:00
|
|
|
fn crate_attrs(&self, cnum: ast::CrateNum) -> Vec<ast::Attribute>
|
|
|
|
{
|
|
|
|
decoder::get_crate_attributes(self.get_crate_data(cnum).data())
|
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn crate_name(&self, cnum: ast::CrateNum) -> String
|
|
|
|
{
|
|
|
|
self.get_crate_data(cnum).name.clone()
|
|
|
|
}
|
|
|
|
|
2015-11-21 13:39:05 -06:00
|
|
|
fn crate_hash(&self, cnum: ast::CrateNum) -> Svh
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(cnum);
|
|
|
|
decoder::get_crate_hash(cdata.data())
|
|
|
|
}
|
|
|
|
|
2015-11-22 13:02:04 -06:00
|
|
|
fn crate_struct_field_attrs(&self, cnum: ast::CrateNum)
|
|
|
|
-> FnvHashMap<DefId, Vec<ast::Attribute>>
|
|
|
|
{
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_struct_field_attrs(&self.get_crate_data(cnum))
|
2015-11-22 13:02:04 -06:00
|
|
|
}
|
|
|
|
|
2015-11-20 09:46:39 -06:00
|
|
|
fn plugin_registrar_fn(&self, cnum: ast::CrateNum) -> Option<DefId>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(cnum);
|
|
|
|
decoder::get_plugin_registrar_fn(cdata.data()).map(|index| DefId {
|
|
|
|
krate: cnum,
|
|
|
|
index: index
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn native_libraries(&self, cnum: ast::CrateNum) -> Vec<(NativeLibraryKind, String)>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(cnum);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_native_libraries(&cdata)
|
2015-11-20 17:08:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(cnum);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_reachable_ids(&cdata)
|
2015-11-20 17:08:09 -06:00
|
|
|
}
|
|
|
|
|
2015-12-03 16:11:19 -06:00
|
|
|
fn def_path(&self, def: DefId) -> hir_map::DefPath
|
2015-11-20 09:46:39 -06:00
|
|
|
{
|
2015-11-20 06:51:18 -06:00
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
let path = decoder::def_path(&cdata, def.index);
|
2015-11-20 06:51:18 -06:00
|
|
|
let local_path = cdata.local_def_path();
|
|
|
|
local_path.into_iter().chain(path).collect()
|
|
|
|
}
|
|
|
|
|
2016-01-17 13:57:54 -06:00
|
|
|
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> {
|
|
|
|
let cdata = self.get_crate_data(def_id.krate);
|
|
|
|
decoder::get_variant_kind(&cdata, def_id.index)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(struct_def_id.krate);
|
|
|
|
decoder::get_struct_ctor_def_id(&cdata, struct_def_id.index)
|
|
|
|
}
|
|
|
|
|
2015-11-20 09:46:39 -06:00
|
|
|
fn tuple_struct_definition_if_ctor(&self, did: DefId) -> Option<DefId>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(did.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_tuple_struct_definition_if_ctor(&cdata, did.index)
|
2015-11-20 09:46:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::get_struct_field_names(&self.intr, &cdata, def.index)
|
2015-11-20 09:46:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn item_children(&self, def_id: DefId) -> Vec<ChildItem>
|
|
|
|
{
|
|
|
|
let mut result = vec![];
|
|
|
|
let crate_data = self.get_crate_data(def_id.krate);
|
|
|
|
let get_crate_data = |cnum| self.get_crate_data(cnum);
|
|
|
|
decoder::each_child_of_item(
|
2016-02-09 14:37:21 -06:00
|
|
|
self.intr.clone(), &crate_data,
|
2015-11-20 09:46:39 -06:00
|
|
|
def_id.index, get_crate_data,
|
|
|
|
|def, name, vis| result.push(ChildItem {
|
|
|
|
def: def,
|
|
|
|
name: name,
|
|
|
|
vis: vis
|
|
|
|
}));
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>
|
|
|
|
{
|
|
|
|
let mut result = vec![];
|
|
|
|
let crate_data = self.get_crate_data(cnum);
|
|
|
|
let get_crate_data = |cnum| self.get_crate_data(cnum);
|
|
|
|
decoder::each_top_level_item_of_crate(
|
2016-02-09 14:37:21 -06:00
|
|
|
self.intr.clone(), &crate_data, get_crate_data,
|
2015-11-20 09:46:39 -06:00
|
|
|
|def, name, vis| result.push(ChildItem {
|
|
|
|
def: def,
|
|
|
|
name: name,
|
|
|
|
vis: vis
|
|
|
|
}));
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn maybe_get_item_ast(&'tcx self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-11-20 06:51:18 -06:00
|
|
|
-> FoundAst<'tcx>
|
|
|
|
{
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
|
|
|
let decode_inlined_item = Box::new(astencode::decode_inlined_item);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::maybe_get_item_ast(&cdata, tcx, def.index, decode_inlined_item)
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|
2015-11-20 17:08:09 -06:00
|
|
|
|
2016-02-29 17:36:51 -06:00
|
|
|
fn maybe_get_item_mir(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
2015-12-08 14:53:19 -06:00
|
|
|
-> Option<Mir<'tcx>> {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::maybe_get_item_mir(&cdata, tcx, def.index)
|
2015-12-08 14:53:19 -06:00
|
|
|
}
|
|
|
|
|
2015-11-02 07:46:39 -06:00
|
|
|
fn is_item_mir_available(&self, def: DefId) -> bool {
|
|
|
|
let cdata = self.get_crate_data(def.krate);
|
2016-02-09 14:37:21 -06:00
|
|
|
decoder::is_item_mir_available(&cdata, def.index)
|
2015-11-02 07:46:39 -06:00
|
|
|
}
|
|
|
|
|
2015-11-21 13:39:05 -06:00
|
|
|
fn crates(&self) -> Vec<ast::CrateNum>
|
|
|
|
{
|
|
|
|
let mut result = vec![];
|
|
|
|
self.iter_crate_data(|cnum, _| result.push(cnum));
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
fn used_libraries(&self) -> Vec<(String, NativeLibraryKind)>
|
|
|
|
{
|
|
|
|
self.get_used_libraries().borrow().clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn used_link_args(&self) -> Vec<String>
|
|
|
|
{
|
|
|
|
self.get_used_link_args().borrow().clone()
|
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn metadata_filename(&self) -> &str
|
|
|
|
{
|
|
|
|
loader::METADATA_FILENAME
|
|
|
|
}
|
|
|
|
|
|
|
|
fn metadata_section_name(&self, target: &Target) -> &str
|
|
|
|
{
|
|
|
|
loader::meta_section_name(target)
|
|
|
|
}
|
2016-02-29 17:36:51 -06:00
|
|
|
fn encode_type(&self, tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec<u8>
|
2015-11-20 17:08:09 -06:00
|
|
|
{
|
|
|
|
encoder::encoded_ty(tcx, ty)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>
|
|
|
|
{
|
|
|
|
self.do_get_used_crates(prefer)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource
|
|
|
|
{
|
2015-11-25 09:02:59 -06:00
|
|
|
self.opt_used_crate_source(cnum).unwrap()
|
2015-11-20 17:08:09 -06:00
|
|
|
}
|
|
|
|
|
2015-11-21 13:39:05 -06:00
|
|
|
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
|
|
|
|
{
|
2015-11-25 09:02:59 -06:00
|
|
|
self.do_extern_mod_stmt_cnum(emod_id)
|
2015-11-21 13:39:05 -06:00
|
|
|
}
|
|
|
|
|
2015-11-20 17:08:09 -06:00
|
|
|
fn encode_metadata(&self,
|
2016-02-29 17:36:51 -06:00
|
|
|
tcx: &TyCtxt<'tcx>,
|
2015-11-20 17:08:09 -06:00
|
|
|
reexports: &def::ExportMap,
|
|
|
|
item_symbols: &RefCell<NodeMap<String>>,
|
|
|
|
link_meta: &LinkMeta,
|
|
|
|
reachable: &NodeSet,
|
2016-02-05 02:32:33 -06:00
|
|
|
mir_map: &MirMap<'tcx>,
|
2015-11-20 17:08:09 -06:00
|
|
|
krate: &hir::Crate) -> Vec<u8>
|
|
|
|
{
|
|
|
|
let encode_inlined_item: encoder::EncodeInlinedItem =
|
|
|
|
Box::new(|ecx, rbml_w, ii| astencode::encode_inlined_item(ecx, rbml_w, ii));
|
|
|
|
|
|
|
|
let encode_params = encoder::EncodeParams {
|
|
|
|
diag: tcx.sess.diagnostic(),
|
|
|
|
tcx: tcx,
|
|
|
|
reexports: reexports,
|
|
|
|
item_symbols: item_symbols,
|
|
|
|
link_meta: link_meta,
|
|
|
|
cstore: self,
|
|
|
|
encode_inlined_item: encode_inlined_item,
|
2015-12-08 14:53:19 -06:00
|
|
|
reachable: reachable,
|
|
|
|
mir_map: mir_map,
|
2015-11-20 17:08:09 -06:00
|
|
|
};
|
|
|
|
encoder::encode_metadata(encode_params, krate)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn metadata_encoding_version(&self) -> &[u8]
|
|
|
|
{
|
|
|
|
encoder::metadata_encoding_version
|
|
|
|
}
|
2015-11-20 06:51:18 -06:00
|
|
|
}
|