@@ -450,15 +450,13 @@ impl tr for ast::Def {
450
450
// ______________________________________________________________________
451
451
// Encoding and decoding of adjustment information
452
452
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
462
460
}
463
461
}
464
462
}
@@ -786,6 +784,8 @@ trait ebml_writer_helpers {
786
784
fn emit_tpbt ( & mut self ,
787
785
ecx : & e:: EncodeContext ,
788
786
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 ) ;
789
789
}
790
790
791
791
impl < ' a > ebml_writer_helpers for writer:: Encoder < ' a > {
@@ -833,6 +833,40 @@ impl<'a> ebml_writer_helpers for writer::Encoder<'a> {
833
833
} )
834
834
} )
835
835
}
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
+ }
836
870
}
837
871
838
872
trait write_tag_and_id {
@@ -1023,7 +1057,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
1023
1057
ebml_w. tag ( c:: tag_table_adjustments, |ebml_w| {
1024
1058
ebml_w. id ( id) ;
1025
1059
ebml_w. tag ( c:: tag_table_val, |ebml_w| {
1026
- ( * * adj) . encode ( ebml_w )
1060
+ ebml_w . emit_auto_adjustment ( ecx , * * adj) ;
1027
1061
} )
1028
1062
} )
1029
1063
}
@@ -1064,6 +1098,8 @@ trait ebml_decoder_decoder_helpers {
1064
1098
-> ty:: TypeParameterDef ;
1065
1099
fn read_ty_param_bounds_and_ty ( & mut self , xcx : @ExtendedDecodeContext )
1066
1100
-> 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 ;
1067
1103
fn convert_def_id ( & mut self ,
1068
1104
xcx : @ExtendedDecodeContext ,
1069
1105
source : DefIdSource ,
@@ -1172,6 +1208,61 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
1172
1208
} )
1173
1209
}
1174
1210
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
+
1175
1266
fn convert_def_id ( & mut self ,
1176
1267
xcx : @ExtendedDecodeContext ,
1177
1268
source : tydecode:: DefIdSource ,
@@ -1289,8 +1380,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
1289
1380
vtable_map. get ( ) . insert ( id, vtable_res) ;
1290
1381
}
1291
1382
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) ;
1294
1384
let mut adjustments = dcx. tcx
1295
1385
. adjustments
1296
1386
. borrow_mut ( ) ;
0 commit comments