File tree 1 file changed +13
-0
lines changed
src/librustc/mir/interpret
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,12 @@ impl<'tcx, Tag> Scalar<Tag> {
421
421
Ok ( b as u8 )
422
422
}
423
423
424
+ pub fn to_u16 ( self ) -> InterpResult < ' static , u16 > {
425
+ let sz = Size :: from_bits ( 16 ) ;
426
+ let b = self . to_bits ( sz) ?;
427
+ Ok ( b as u16 )
428
+ }
429
+
424
430
pub fn to_u32 ( self ) -> InterpResult < ' static , u32 > {
425
431
let sz = Size :: from_bits ( 32 ) ;
426
432
let b = self . to_bits ( sz) ?;
@@ -445,6 +451,13 @@ impl<'tcx, Tag> Scalar<Tag> {
445
451
Ok ( b as i8 )
446
452
}
447
453
454
+ pub fn to_i16 ( self ) -> InterpResult < ' static , i16 > {
455
+ let sz = Size :: from_bits ( 16 ) ;
456
+ let b = self . to_bits ( sz) ?;
457
+ let b = sign_extend ( b, sz) as i128 ;
458
+ Ok ( b as i16 )
459
+ }
460
+
448
461
pub fn to_i32 ( self ) -> InterpResult < ' static , i32 > {
449
462
let sz = Size :: from_bits ( 32 ) ;
450
463
let b = self . to_bits ( sz) ?;
You can’t perform that action at this time.
0 commit comments