remove the last remnants of old interface
This commit is contained in:
parent
b09cf1293a
commit
7a3a1be5e4
@ -24,9 +24,7 @@ use metadata::csearch;
|
||||
use metadata::cstore;
|
||||
use metadata::encoder::def_to_u64;
|
||||
use metadata::inline::InlinedItem;
|
||||
use metadata::tydecode::{parse_ty_data, parse_region_data,
|
||||
parse_type_param_def_data, parse_bare_fn_ty_data,
|
||||
parse_trait_ref_data, parse_predicate_data};
|
||||
use metadata::tydecode::TyDecoder;
|
||||
use middle::def;
|
||||
use middle::lang_items;
|
||||
use middle::subst;
|
||||
@ -235,22 +233,25 @@ fn variant_disr_val(d: rbml::Doc) -> Option<ty::Disr> {
|
||||
|
||||
fn doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
|
||||
let tp = reader::get_doc(doc, tag_items_data_item_type);
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, tp,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_ty()
|
||||
}
|
||||
|
||||
fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Option<Ty<'tcx>> {
|
||||
reader::maybe_get_doc(doc, tag_items_data_item_type).map(|tp| {
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, tp,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_ty()
|
||||
})
|
||||
}
|
||||
|
||||
fn doc_method_fty<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>,
|
||||
cdata: Cmd) -> ty::BareFnTy<'tcx> {
|
||||
let tp = reader::get_doc(doc, tag_item_method_fty);
|
||||
parse_bare_fn_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, tp,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_bare_fn_ty()
|
||||
}
|
||||
|
||||
pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
|
||||
@ -260,8 +261,9 @@ pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
|
||||
|
||||
fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
|
||||
-> ty::TraitRef<'tcx> {
|
||||
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, doc,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_trait_ref()
|
||||
}
|
||||
|
||||
fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
|
||||
@ -1465,9 +1467,10 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
|
||||
|
||||
let mut types = subst::VecPerParamSpace::empty();
|
||||
for p in reader::tagged_docs(doc, tag_type_param_def) {
|
||||
let bd = parse_type_param_def_data(
|
||||
p.data, p.start, cdata.cnum, tcx,
|
||||
|_, did| translate_def_id(cdata, did));
|
||||
let bd =
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, p,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_type_param_def();
|
||||
types.push(bd.space, bd);
|
||||
}
|
||||
|
||||
@ -1487,8 +1490,9 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
|
||||
let index = reader::doc_as_u64(doc) as u32;
|
||||
|
||||
let bounds = reader::tagged_docs(rp_doc, tag_items_data_region).map(|p| {
|
||||
parse_region_data(p.data, cdata.cnum, p.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, p,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_region()
|
||||
}).collect();
|
||||
|
||||
regions.push(space, ty::RegionParameterDef { name: name,
|
||||
@ -1515,8 +1519,10 @@ fn doc_predicates<'tcx>(base_doc: rbml::Doc,
|
||||
let space = subst::ParamSpace::from_uint(reader::doc_as_u8(space_doc) as usize);
|
||||
|
||||
let data_doc = reader::get_doc(predicate_doc, tag_predicate_data);
|
||||
let data = parse_predicate_data(data_doc.data, data_doc.start, cdata.cnum, tcx,
|
||||
|_, did| translate_def_id(cdata, did));
|
||||
let data =
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, data_doc,
|
||||
&mut |_, did| translate_def_id(cdata, did))
|
||||
.parse_predicate();
|
||||
|
||||
predicates.push(space, data);
|
||||
}
|
||||
|
@ -58,104 +58,6 @@ pub enum DefIdSource {
|
||||
ClosureSource
|
||||
}
|
||||
|
||||
pub fn parse_ty_closure_data<'tcx, F>(data: &[u8],
|
||||
crate_num: ast::CrateNum,
|
||||
pos: usize,
|
||||
tcx: &ty::ctxt<'tcx>,
|
||||
mut conv: F)
|
||||
-> ty::ClosureTy<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_closure_ty()
|
||||
}
|
||||
|
||||
pub fn parse_ty_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
|
||||
tcx: &ty::ctxt<'tcx>, mut conv: F) -> Ty<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
debug!("parse_ty_data {}", data_log_string(data, pos));
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_ty()
|
||||
}
|
||||
|
||||
pub fn parse_region_data<F>(data: &[u8], crate_num: ast::CrateNum, pos: usize, tcx: &ty::ctxt,
|
||||
mut conv: F) -> ty::Region where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
debug!("parse_region_data {}", data_log_string(data, pos));
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_region()
|
||||
}
|
||||
|
||||
pub fn parse_bare_fn_ty_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
|
||||
tcx: &ty::ctxt<'tcx>, mut conv: F)
|
||||
-> ty::BareFnTy<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
debug!("parse_bare_fn_ty_data {}", data_log_string(data, pos));
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_bare_fn_ty()
|
||||
}
|
||||
|
||||
pub fn parse_trait_ref_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
|
||||
tcx: &ty::ctxt<'tcx>, mut conv: F)
|
||||
-> ty::TraitRef<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
debug!("parse_trait_ref_data {}", data_log_string(data, pos));
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_trait_ref()
|
||||
}
|
||||
|
||||
pub fn parse_substs_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
|
||||
tcx: &ty::ctxt<'tcx>, mut conv: F) -> subst::Substs<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
debug!("parse_substs_data{}", data_log_string(data, pos));
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_substs()
|
||||
}
|
||||
|
||||
pub fn parse_existential_bounds_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum,
|
||||
pos: usize, tcx: &ty::ctxt<'tcx>, mut conv: F)
|
||||
-> ty::ExistentialBounds<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_existential_bounds()
|
||||
}
|
||||
|
||||
pub fn parse_builtin_bounds_data<F>(data: &[u8], crate_num: ast::CrateNum,
|
||||
pos: usize, tcx: &ty::ctxt, mut conv: F)
|
||||
-> ty::BuiltinBounds where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
|
||||
st.parse_builtin_bounds()
|
||||
}
|
||||
|
||||
pub fn parse_type_param_def_data<'tcx, F>(data: &[u8], start: usize,
|
||||
crate_num: ast::CrateNum, tcx: &ty::ctxt<'tcx>,
|
||||
mut conv: F) -> ty::TypeParameterDef<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
let mut st = TyDecoder::new(data, crate_num, start, tcx, &mut conv);
|
||||
st.parse_type_param_def()
|
||||
}
|
||||
|
||||
pub fn parse_predicate_data<'tcx, F>(data: &[u8],
|
||||
start: usize,
|
||||
crate_num: ast::CrateNum,
|
||||
tcx: &ty::ctxt<'tcx>,
|
||||
mut conv: F)
|
||||
-> ty::Predicate<'tcx> where
|
||||
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
|
||||
{
|
||||
let mut st = TyDecoder::new(data, crate_num, start, tcx, &mut conv);
|
||||
st.parse_predicate()
|
||||
}
|
||||
|
||||
pub type DefIdConvert<'a> = &'a mut FnMut(DefIdSource, ast::DefId) -> ast::DefId;
|
||||
|
||||
pub struct TyDecoder<'a, 'tcx: 'a> {
|
||||
@ -292,7 +194,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_region(&mut self) -> ty::Region {
|
||||
pub fn parse_region(&mut self) -> ty::Region {
|
||||
match self.next() {
|
||||
'b' => {
|
||||
assert_eq!(self.next(), '[');
|
||||
@ -629,7 +531,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_bare_fn_ty(&mut self) -> ty::BareFnTy<'tcx> {
|
||||
pub fn parse_bare_fn_ty(&mut self) -> ty::BareFnTy<'tcx> {
|
||||
let unsafety = parse_unsafety(self.next());
|
||||
let abi = self.parse_abi_set();
|
||||
let sig = self.parse_sig();
|
||||
@ -777,21 +679,6 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn data_log_string(data: &[u8], pos: usize) -> String {
|
||||
let mut buf = String::new();
|
||||
buf.push_str("<<");
|
||||
for i in pos..data.len() {
|
||||
let c = data[i];
|
||||
if c > 0x20 && c <= 0x7F {
|
||||
buf.push(c as char);
|
||||
} else {
|
||||
buf.push('.');
|
||||
}
|
||||
}
|
||||
buf.push_str(">>");
|
||||
buf
|
||||
}
|
||||
|
||||
// Rust metadata parsing
|
||||
fn parse_defid(buf: &[u8]) -> ast::DefId {
|
||||
let mut colon_idx = 0;
|
||||
|
@ -1252,11 +1252,9 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
||||
fn read_substs<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
|
||||
-> subst::Substs<'tcx> {
|
||||
self.read_opaque(|this, doc| {
|
||||
Ok(tydecode::parse_substs_data(doc.data,
|
||||
dcx.cdata.cnum,
|
||||
doc.start,
|
||||
dcx.tcx,
|
||||
|s, a| this.convert_def_id(dcx, s, a)))
|
||||
Ok(tydecode::TyDecoder::with_doc(dcx.tcx, dcx.cdata.cnum, doc,
|
||||
&mut |s, a| this.convert_def_id(dcx, s, a))
|
||||
.parse_substs())
|
||||
}).unwrap()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user