@@ -450,15 +450,13 @@ impl tr for ast::Def {
450450// ______________________________________________________________________
451451// Encoding and decoding of adjustment information
452452
453- impl tr for ty:: AutoAdjustment {
454- fn tr ( & self , xcx : @ExtendedDecodeContext ) -> ty:: AutoAdjustment {
455- match * self {
456- ty:: AutoAddEnv ( r, s) => ty:: AutoAddEnv ( r. tr ( xcx) , s) ,
457- ty:: AutoDerefRef ( ref adr) => {
458- ty:: AutoDerefRef ( ty:: AutoDerefRef {
459- autoderefs : adr. autoderefs ,
460- autoref : adr. autoref . map ( |ar| ar. tr ( xcx) ) ,
461- } )
453+ impl tr for ty:: AutoDerefRef {
454+ fn tr ( & self , xcx : @ExtendedDecodeContext ) -> ty:: AutoDerefRef {
455+ ty:: AutoDerefRef {
456+ autoderefs : self . autoderefs ,
457+ autoref : match self . autoref {
458+ Some ( ref autoref) => Some ( autoref. tr ( xcx) ) ,
459+ None => None
462460 }
463461 }
464462 }
@@ -786,6 +784,8 @@ trait ebml_writer_helpers {
786784 fn emit_tpbt ( & mut self ,
787785 ecx : & e:: EncodeContext ,
788786 tpbt : ty:: ty_param_bounds_and_ty ) ;
787+ fn emit_substs ( & mut self , ecx : & e:: EncodeContext , substs : & ty:: substs ) ;
788+ fn emit_auto_adjustment ( & mut self , ecx : & e:: EncodeContext , adj : & ty:: AutoAdjustment ) ;
789789}
790790
791791impl < ' a > ebml_writer_helpers for writer:: Encoder < ' a > {
@@ -833,6 +833,40 @@ impl<'a> ebml_writer_helpers for writer::Encoder<'a> {
833833 } )
834834 } )
835835 }
836+
837+ fn emit_substs ( & mut self , ecx : & e:: EncodeContext , substs : & ty:: substs ) {
838+ self . emit_opaque ( |this| tyencode:: enc_substs ( this. writer , ecx. ty_str_ctxt ( ) , substs) )
839+ }
840+
841+ fn emit_auto_adjustment ( & mut self , ecx : & e:: EncodeContext , adj : & ty:: AutoAdjustment ) {
842+ self . emit_enum ( "AutoAdjustment" , |this| {
843+ match * adj {
844+ ty:: AutoAddEnv ( region, sigil) => {
845+ this. emit_enum_variant ( "AutoAddEnv" , 0 , 2 , |this| {
846+ this. emit_enum_variant_arg ( 0 , |this| region. encode ( this) ) ;
847+ this. emit_enum_variant_arg ( 1 , |this| sigil. encode ( this) ) ;
848+ } ) ;
849+ }
850+
851+ ty:: AutoDerefRef ( ref auto_deref_ref) => {
852+ this. emit_enum_variant ( "AutoDerefRef" , 1 , 1 , |this| {
853+ this. emit_enum_variant_arg ( 0 , |this| auto_deref_ref. encode ( this) ) ;
854+ } ) ;
855+ }
856+
857+ ty:: AutoObject ( sigil, region, m, b, def_id, ref substs) => {
858+ this. emit_enum_variant ( "AutoObject" , 2 , 6 , |this| {
859+ this. emit_enum_variant_arg ( 0 , |this| sigil. encode ( this) ) ;
860+ this. emit_enum_variant_arg ( 1 , |this| region. encode ( this) ) ;
861+ this. emit_enum_variant_arg ( 2 , |this| m. encode ( this) ) ;
862+ this. emit_enum_variant_arg ( 3 , |this| b. encode ( this) ) ;
863+ this. emit_enum_variant_arg ( 4 , |this| def_id. encode ( this) ) ;
864+ this. emit_enum_variant_arg ( 5 , |this| this. emit_substs ( ecx, substs) ) ;
865+ } ) ;
866+ }
867+ }
868+ } ) ;
869+ }
836870}
837871
838872trait write_tag_and_id {
@@ -1023,7 +1057,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10231057 ebml_w. tag ( c:: tag_table_adjustments, |ebml_w| {
10241058 ebml_w. id ( id) ;
10251059 ebml_w. tag ( c:: tag_table_val, |ebml_w| {
1026- ( * * adj) . encode ( ebml_w )
1060+ ebml_w . emit_auto_adjustment ( ecx , * * adj) ;
10271061 } )
10281062 } )
10291063 }
@@ -1064,6 +1098,8 @@ trait ebml_decoder_decoder_helpers {
10641098 -> ty:: TypeParameterDef ;
10651099 fn read_ty_param_bounds_and_ty ( & mut self , xcx : @ExtendedDecodeContext )
10661100 -> ty:: ty_param_bounds_and_ty ;
1101+ fn read_substs ( & mut self , xcx : @ExtendedDecodeContext ) -> ty:: substs ;
1102+ fn read_auto_adjustment ( & mut self , xcx : @ExtendedDecodeContext ) -> ty:: AutoAdjustment ;
10671103 fn convert_def_id ( & mut self ,
10681104 xcx : @ExtendedDecodeContext ,
10691105 source : DefIdSource ,
@@ -1172,6 +1208,61 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
11721208 } )
11731209 }
11741210
1211+ fn read_substs ( & mut self , xcx : @ExtendedDecodeContext ) -> ty:: substs {
1212+ self . read_opaque ( |this, doc| {
1213+ tydecode:: parse_substs_data ( doc. data ,
1214+ xcx. dcx . cdata . cnum ,
1215+ doc. start ,
1216+ xcx. dcx . tcx ,
1217+ |s, a| this. convert_def_id ( xcx, s, a) )
1218+ } )
1219+ }
1220+
1221+ fn read_auto_adjustment ( & mut self , xcx : @ExtendedDecodeContext ) -> ty:: AutoAdjustment {
1222+ self . read_enum ( "AutoAdjustment" , |this| {
1223+ let variants = [ "AutoAddEnv" , "AutoDerefRef" , "AutoObject" ] ;
1224+ this. read_enum_variant ( variants, |this, i| {
1225+ match i {
1226+ 0 => {
1227+ let region: ty:: Region =
1228+ this. read_enum_variant_arg ( 0 , |this| Decodable :: decode ( this) ) ;
1229+ let sigil: ast:: Sigil =
1230+ this. read_enum_variant_arg ( 1 , |this| Decodable :: decode ( this) ) ;
1231+
1232+ ty:: AutoAddEnv ( region. tr ( xcx) , sigil)
1233+ }
1234+ 1 => {
1235+ let auto_deref_ref: ty:: AutoDerefRef =
1236+ this. read_enum_variant_arg ( 0 , |this| Decodable :: decode ( this) ) ;
1237+
1238+ ty:: AutoDerefRef ( auto_deref_ref. tr ( xcx) )
1239+ }
1240+ 2 => {
1241+ let sigil: ast:: Sigil =
1242+ this. read_enum_variant_arg ( 0 , |this| Decodable :: decode ( this) ) ;
1243+ let region: Option < ty:: Region > =
1244+ this. read_enum_variant_arg ( 1 , |this| Decodable :: decode ( this) ) ;
1245+ let m: ast:: Mutability =
1246+ this. read_enum_variant_arg ( 2 , |this| Decodable :: decode ( this) ) ;
1247+ let b: ty:: BuiltinBounds =
1248+ this. read_enum_variant_arg ( 3 , |this| Decodable :: decode ( this) ) ;
1249+ let def_id: ast:: DefId =
1250+ this. read_enum_variant_arg ( 4 , |this| Decodable :: decode ( this) ) ;
1251+ let substs = this. read_enum_variant_arg ( 5 , |this| this. read_substs ( xcx) ) ;
1252+
1253+ let region = match region {
1254+ Some ( r) => Some ( r. tr ( xcx) ) ,
1255+ None => None
1256+ } ;
1257+
1258+ ty:: AutoObject ( sigil, region, m, b, def_id. tr ( xcx) , substs)
1259+ }
1260+ _ => fail ! ( "bad enum variant for ty::AutoAdjustment" )
1261+ }
1262+ } )
1263+ } )
1264+ }
1265+
11751266 fn convert_def_id ( & mut self ,
11761267 xcx : @ExtendedDecodeContext ,
11771268 source : tydecode:: DefIdSource ,
@@ -1289,8 +1380,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12891380 vtable_map. get ( ) . insert ( id, vtable_res) ;
12901381 }
12911382 c:: tag_table_adjustments => {
1292- let adj: @ty:: AutoAdjustment = @Decodable :: decode ( val_dsr) ;
1293- adj. tr ( xcx) ;
1383+ let adj: @ty:: AutoAdjustment = @val_dsr. read_auto_adjustment ( xcx) ;
12941384 let mut adjustments = dcx. tcx
12951385 . adjustments
12961386 . borrow_mut ( ) ;
0 commit comments