@@ -20,7 +20,7 @@ use metadata::decoder;
20
20
use metadata:: tydecode:: { parse_ty_data, parse_def_id,
21
21
parse_type_param_def_data,
22
22
parse_bare_fn_ty_data, parse_trait_ref_data} ;
23
- use middle:: ty ;
23
+ use middle:: { ty , resolve } ;
24
24
25
25
use std:: hash:: HashUtil ;
26
26
use std:: int;
@@ -174,6 +174,14 @@ fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
174
174
None
175
175
}
176
176
177
+ fn translated_parent_item_opt ( cnum : ast:: crate_num , d : ebml:: Doc ) ->
178
+ Option < ast:: def_id > {
179
+ let trait_did_opt = item_parent_item ( d) ;
180
+ do trait_did_opt. map |trait_did| {
181
+ ast:: def_id { crate : cnum, node : trait_did. node }
182
+ }
183
+ }
184
+
177
185
fn item_reqd_and_translated_parent_item ( cnum : ast:: crate_num ,
178
186
d : ebml:: Doc ) -> ast:: def_id {
179
187
let trait_did = item_parent_item ( d) . expect ( "item without parent" ) ;
@@ -185,12 +193,6 @@ fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id {
185
193
return translate_def_id ( cdata, reader:: with_doc_data ( tagdoc, parse_def_id) ) ;
186
194
}
187
195
188
- fn get_provided_source ( d : ebml:: Doc , cdata : cmd ) -> Option < ast:: def_id > {
189
- do reader:: maybe_get_doc ( d, tag_item_method_provided_source) . map |doc| {
190
- translate_def_id ( cdata, reader:: with_doc_data ( * doc, parse_def_id) )
191
- }
192
- }
193
-
194
196
fn each_reexport ( d : ebml:: Doc , f : & fn ( ebml:: Doc ) -> bool ) -> bool {
195
197
for reader:: tagged_docs( d, tag_items_data_item_reexport) |reexport_doc| {
196
198
if !f ( reexport_doc) {
@@ -321,19 +323,13 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
321
323
UnsafeFn => dl_def ( ast:: def_fn ( did, ast:: unsafe_fn) ) ,
322
324
Fn => dl_def ( ast:: def_fn ( did, ast:: impure_fn) ) ,
323
325
ForeignFn => dl_def ( ast:: def_fn ( did, ast:: extern_fn) ) ,
324
- StaticMethod | UnsafeStaticMethod => {
325
- let purity = if fam == UnsafeStaticMethod { ast:: unsafe_fn } else
326
- { ast:: impure_fn } ;
327
- // def_static_method carries an optional field of its enclosing
328
- // *trait*, but not an inclosing Impl (if this is an inherent
329
- // static method). So we need to detect whether this is in
330
- // a trait or not, which we do through the mildly hacky
331
- // way of checking whether there is a trait_method_sort.
332
- let trait_did_opt = if reader:: maybe_get_doc (
333
- item, tag_item_trait_method_sort) . is_some ( ) {
334
- Some ( item_reqd_and_translated_parent_item ( cnum, item) )
335
- } else { None } ;
336
- dl_def ( ast:: def_static_method ( did, trait_did_opt, purity) )
326
+ UnsafeStaticMethod => {
327
+ let trait_did_opt = translated_parent_item_opt ( cnum, item) ;
328
+ dl_def ( ast:: def_static_method ( did, trait_did_opt, ast:: unsafe_fn) )
329
+ }
330
+ StaticMethod => {
331
+ let trait_did_opt = translated_parent_item_opt ( cnum, item) ;
332
+ dl_def ( ast:: def_static_method ( did, trait_did_opt, ast:: impure_fn) )
337
333
}
338
334
Type | ForeignType => dl_def ( ast:: def_ty ( did) ) ,
339
335
Mod => dl_def ( ast:: def_mod ( did) ) ,
@@ -799,29 +795,34 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
799
795
}
800
796
801
797
fn item_impl_methods ( intr : @ident_interner , cdata : cmd , item : ebml:: Doc ,
802
- tcx : ty :: ctxt ) -> ~[ @ty :: Method ] {
798
+ base_tps : uint ) -> ~[ @resolve :: MethodInfo ] {
803
799
let mut rslt = ~[ ] ;
804
800
for reader:: tagged_docs( item, tag_item_impl_method) |doc| {
805
801
let m_did = reader:: with_doc_data ( doc, parse_def_id) ;
806
- rslt. push ( @get_method ( intr, cdata, m_did. node , tcx) ) ;
802
+ let mth_item = lookup_item ( m_did. node , cdata. data ) ;
803
+ let explicit_self = get_explicit_self ( mth_item) ;
804
+ rslt. push ( @resolve:: MethodInfo {
805
+ did : translate_def_id ( cdata, m_did) ,
806
+ n_tps : item_ty_param_count ( mth_item) - base_tps,
807
+ ident : item_name ( intr, mth_item) ,
808
+ explicit_self : explicit_self} ) ;
807
809
}
808
-
809
810
rslt
810
811
}
811
812
812
813
/// Returns information about the given implementation.
813
- pub fn get_impl ( intr : @ident_interner , cdata : cmd , impl_id : ast:: node_id ,
814
- tcx : ty:: ctxt )
815
- -> ty:: Impl {
814
+ pub fn get_impl ( intr : @ident_interner , cdata : cmd , impl_id : ast:: node_id )
815
+ -> resolve:: Impl {
816
816
let data = cdata. data ;
817
817
let impl_item = lookup_item ( impl_id, data) ;
818
- ty:: Impl {
818
+ let base_tps = item_ty_param_count ( impl_item) ;
819
+ resolve:: Impl {
819
820
did : ast:: def_id {
820
821
crate : cdata. cnum ,
821
822
node : impl_id,
822
823
} ,
823
824
ident : item_name ( intr, impl_item) ,
824
- methods : item_impl_methods ( intr, cdata, impl_item, tcx ) ,
825
+ methods : item_impl_methods ( intr, cdata, impl_item, base_tps ) ,
825
826
}
826
827
}
827
828
@@ -841,16 +842,13 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
841
842
{
842
843
let method_doc = lookup_item ( id, cdata. data ) ;
843
844
let def_id = item_def_id ( method_doc, cdata) ;
844
- let container_id = item_reqd_and_translated_parent_item ( cdata. cnum ,
845
- method_doc) ;
846
845
let name = item_name ( intr, method_doc) ;
847
846
let type_param_defs = item_ty_param_defs ( method_doc, tcx, cdata,
848
847
tag_item_method_tps) ;
849
848
let transformed_self_ty = doc_transformed_self_ty ( method_doc, tcx, cdata) ;
850
849
let fty = doc_method_fty ( method_doc, tcx, cdata) ;
851
850
let vis = item_visibility ( method_doc) ;
852
851
let explicit_self = get_explicit_self ( method_doc) ;
853
- let provided_source = get_provided_source ( method_doc, cdata) ;
854
852
855
853
ty:: Method :: new (
856
854
name,
@@ -862,9 +860,7 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
862
860
fty,
863
861
explicit_self,
864
862
vis,
865
- def_id,
866
- container_id,
867
- provided_source
863
+ def_id
868
864
)
869
865
}
870
866
0 commit comments