File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/librustc/mir/interpret Expand file tree Collapse file tree 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> {
421421 Ok ( b as u8 )
422422 }
423423
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+
424430 pub fn to_u32 ( self ) -> InterpResult < ' static , u32 > {
425431 let sz = Size :: from_bits ( 32 ) ;
426432 let b = self . to_bits ( sz) ?;
@@ -445,6 +451,13 @@ impl<'tcx, Tag> Scalar<Tag> {
445451 Ok ( b as i8 )
446452 }
447453
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+
448461 pub fn to_i32 ( self ) -> InterpResult < ' static , i32 > {
449462 let sz = Size :: from_bits ( 32 ) ;
450463 let b = self . to_bits ( sz) ?;
You can’t perform that action at this time.
0 commit comments