tydecode: Accept a plain borrowed pointer to the data
This commit is contained in:
parent
51e85f5e6e
commit
96798f5e05
@ -216,13 +216,13 @@ fn variant_disr_val(d: ebml::Doc) -> Option<int> {
|
||||
|
||||
fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let tp = reader::get_doc(doc, tag_items_data_item_type);
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
parse_ty_data(*tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
|
||||
fn doc_method_fty(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::BareFnTy {
|
||||
let tp = reader::get_doc(doc, tag_item_method_fty);
|
||||
parse_bare_fn_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
parse_bare_fn_ty_data(*tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ fn doc_transformed_self_ty(doc: ebml::Doc,
|
||||
cdata: cmd) -> Option<ty::t>
|
||||
{
|
||||
do reader::maybe_get_doc(doc, tag_item_method_transformed_self_ty).map |tp| {
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
parse_ty_data(*tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
}
|
||||
@ -242,7 +242,7 @@ pub fn item_type(_item_id: ast::def_id, item: ebml::Doc,
|
||||
}
|
||||
|
||||
fn doc_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::TraitRef {
|
||||
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
|
||||
parse_trait_ref_data(*doc.data, cdata.cnum, doc.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd,
|
||||
let mut bounds = ~[];
|
||||
for reader::tagged_docs(item, tag) |p| {
|
||||
let bd = parse_type_param_def_data(
|
||||
p.data, p.start, cdata.cnum, tcx,
|
||||
*p.data, p.start, cdata.cnum, tcx,
|
||||
|_, did| translate_def_id(cdata, did));
|
||||
bounds.push(bd);
|
||||
}
|
||||
@ -413,15 +413,9 @@ pub fn get_impl_trait(cdata: cmd,
|
||||
tcx: ty::ctxt) -> Option<@ty::TraitRef>
|
||||
{
|
||||
let item_doc = lookup_item(id, cdata.data);
|
||||
let mut result = None;
|
||||
for reader::tagged_docs(item_doc, tag_item_trait_ref) |tp| {
|
||||
let trait_ref =
|
||||
@parse_trait_ref_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did));
|
||||
result = Some(trait_ref);
|
||||
break;
|
||||
};
|
||||
result
|
||||
do reader::maybe_get_doc(item_doc, tag_item_trait_ref).map |&tp| {
|
||||
@doc_trait_ref(tp, tcx, cdata)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
|
||||
|
@ -55,8 +55,8 @@ pub enum DefIdSource {
|
||||
type conv_did<'self> =
|
||||
&'self fn(source: DefIdSource, ast::def_id) -> ast::def_id;
|
||||
|
||||
pub struct PState {
|
||||
data: @~[u8],
|
||||
pub struct PState<'self> {
|
||||
data: &'self [u8],
|
||||
crate: int,
|
||||
pos: uint,
|
||||
tcx: ty::ctxt
|
||||
@ -103,8 +103,8 @@ fn parse_ident_(st: &mut PState, is_last: @fn(char) -> bool) ->
|
||||
return st.tcx.sess.ident_of(rslt);
|
||||
}
|
||||
|
||||
pub fn parse_state_from_data(data: @~[u8], crate_num: int,
|
||||
pos: uint, tcx: ty::ctxt) -> PState {
|
||||
pub fn parse_state_from_data<'a>(data: &'a [u8], crate_num: int,
|
||||
pos: uint, tcx: ty::ctxt) -> PState<'a> {
|
||||
PState {
|
||||
data: data,
|
||||
crate: crate_num,
|
||||
@ -113,19 +113,19 @@ pub fn parse_state_from_data(data: @~[u8], crate_num: int,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_ty_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_ty_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||
conv: conv_did) -> ty::t {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_ty(&mut st, conv)
|
||||
}
|
||||
|
||||
pub fn parse_bare_fn_ty_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_bare_fn_ty_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||
conv: conv_did) -> ty::BareFnTy {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_bare_fn_ty(&mut st, conv)
|
||||
}
|
||||
|
||||
pub fn parse_trait_ref_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_trait_ref_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
|
||||
conv: conv_did) -> ty::TraitRef {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_trait_ref(&mut st, conv)
|
||||
@ -534,7 +534,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
|
||||
ast::def_id { crate: crate_num, node: def_num }
|
||||
}
|
||||
|
||||
pub fn parse_type_param_def_data(data: @~[u8], start: uint,
|
||||
pub fn parse_type_param_def_data(data: &[u8], start: uint,
|
||||
crate_num: int, tcx: ty::ctxt,
|
||||
conv: conv_did) -> ty::TypeParameterDef
|
||||
{
|
||||
|
@ -964,7 +964,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
|
||||
|
||||
return do self.read_opaque |this, doc| {
|
||||
let ty = tydecode::parse_ty_data(
|
||||
doc.data,
|
||||
*doc.data,
|
||||
xcx.dcx.cdata.cnum,
|
||||
doc.start,
|
||||
xcx.dcx.tcx,
|
||||
@ -994,7 +994,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
|
||||
-> ty::TypeParameterDef {
|
||||
do self.read_opaque |this, doc| {
|
||||
tydecode::parse_type_param_def_data(
|
||||
doc.data,
|
||||
*doc.data,
|
||||
doc.start,
|
||||
xcx.dcx.cdata.cnum,
|
||||
xcx.dcx.tcx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user