File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ use std::fmt;
22use std:: convert:: { TryFrom } ;
33use std:: collections:: HashMap ;
44use std:: collections:: HashSet ;
5- use std:: mem:: transmute;
65use crate :: vm:: { Op } ;
76use crate :: program:: * ;
87
@@ -843,8 +842,7 @@ impl Assembler
843842 // 32-bit floating-point value
844843 "f32" => {
845844 let val: f32 = input. parse_float ( ) ?;
846- let val_u32: u32 = unsafe { transmute ( val) } ;
847- self . mem ( ) . push_u32 ( val_u32) ;
845+ self . mem ( ) . push_u32 ( val. to_bits ( ) ) ;
848846 }
849847
850848 // Command to read an arbitrary number of bytes
@@ -1003,9 +1001,8 @@ impl Assembler
10031001 // Push a 32-bit floating-point value
10041002 "push_f32" => {
10051003 let val: f32 = input. parse_float ( ) ?;
1006- let val_u32: u32 = unsafe { transmute ( val) } ;
10071004 self . code . push_op ( Op :: push_u32) ;
1008- self . code . push_u32 ( val_u32 ) ;
1005+ self . code . push_u32 ( val . to_bits ( ) ) ;
10091006 }
10101007
10111008 // Variable-size push
Original file line number Diff line number Diff line change @@ -348,8 +348,7 @@ impl Value
348348
349349 pub fn as_f32 ( & self ) -> f32 {
350350 let Value ( val) = * self ;
351- let val = val as i32 ;
352- unsafe { transmute ( val) }
351+ f32:: from_bits ( val as u32 )
353352 }
354353}
355354
@@ -409,8 +408,7 @@ impl From<i64> for Value {
409408
410409impl From < f32 > for Value {
411410 fn from ( val : f32 ) -> Self {
412- let val: u32 = unsafe { transmute ( val) } ;
413- Value ( val as u64 )
411+ Value ( val. to_bits ( ) as u64 )
414412 }
415413}
416414
You can’t perform that action at this time.
0 commit comments