@@ -1020,11 +1020,12 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
1020
1020
}
1021
1021
1022
1022
pub fn sign_extend ( & self , value : u128 , ty : TyLayout < ' _ > ) -> u128 {
1023
- super :: sign_extend ( value, ty)
1023
+ assert ! ( ty. abi. is_signed( ) ) ;
1024
+ super :: sign_extend ( value, ty. size )
1024
1025
}
1025
1026
1026
1027
pub fn truncate ( & self , value : u128 , ty : TyLayout < ' _ > ) -> u128 {
1027
- super :: truncate ( value, ty)
1028
+ super :: truncate ( value, ty. size )
1028
1029
}
1029
1030
1030
1031
fn dump_field_name ( & self , s : & mut String , ty : Ty < ' tcx > , i : usize , variant : usize ) -> :: std:: fmt:: Result {
@@ -1095,18 +1096,17 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
1095
1096
}
1096
1097
}
1097
1098
1098
- pub fn sign_extend ( value : u128 , layout : TyLayout < ' _ > ) -> u128 {
1099
- let size = layout. size . bits ( ) ;
1100
- assert ! ( layout. abi. is_signed( ) ) ;
1099
+ pub fn sign_extend ( value : u128 , size : Size ) -> u128 {
1100
+ let size = size. bits ( ) ;
1101
1101
// sign extend
1102
1102
let shift = 128 - size;
1103
1103
// shift the unsigned value to the left
1104
1104
// and back to the right as signed (essentially fills with FF on the left)
1105
1105
( ( ( value << shift) as i128 ) >> shift) as u128
1106
1106
}
1107
1107
1108
- pub fn truncate ( value : u128 , layout : TyLayout < ' _ > ) -> u128 {
1109
- let size = layout . size . bits ( ) ;
1108
+ pub fn truncate ( value : u128 , size : Size ) -> u128 {
1109
+ let size = size. bits ( ) ;
1110
1110
let shift = 128 - size;
1111
1111
// truncate (shift left to drop out leftover values, shift right to fill with zeroes)
1112
1112
( value << shift) >> shift
0 commit comments