@@ -9,38 +9,28 @@ use tinywasm_types::{ValType, WasmValue};
99#[ derive( Clone , Copy , Default , PartialEq , Eq ) ]
1010pub struct RawWasmValue ( [ u8 ; 8 ] ) ;
1111
12- /// A large raw wasm value, used for 128-bit values.
13- ///
14- /// This is the internal representation of vector values.
15- ///
16- /// See [`WasmValue`] for the public representation.
17- #[ derive( Clone , Copy , Default , PartialEq , Eq ) ]
18- pub struct LargeRawWasmValue ( [ u8 ; 16 ] ) ;
19-
2012impl Debug for RawWasmValue {
2113 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
2214 write ! ( f, "RawWasmValue({})" , 0 )
2315 }
2416}
2517
26- impl Debug for LargeRawWasmValue {
27- fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
28- write ! ( f, "LargeRawWasmValue({})" , 0 )
18+ impl RawWasmValue {
19+ #[ inline( always) ]
20+ /// Get the raw value
21+ pub fn raw_value ( & self ) -> [ u8 ; 8 ] {
22+ self . 0
2923 }
30- }
31-
32- pub trait WasmValueRepr {
33- fn attach_type ( self , ty : ValType ) -> WasmValue ;
34- }
3524
36- impl WasmValueRepr for RawWasmValue {
3725 #[ inline]
38- fn attach_type ( self , ty : ValType ) -> WasmValue {
26+ /// Attach a type to the raw value (does not support simd values)
27+ pub fn attach_type ( self , ty : ValType ) -> WasmValue {
3928 match ty {
4029 ValType :: I32 => WasmValue :: I32 ( self . into ( ) ) ,
4130 ValType :: I64 => WasmValue :: I64 ( self . into ( ) ) ,
4231 ValType :: F32 => WasmValue :: F32 ( f32:: from_bits ( self . into ( ) ) ) ,
4332 ValType :: F64 => WasmValue :: F64 ( f64:: from_bits ( self . into ( ) ) ) ,
33+ ValType :: V128 => panic ! ( "RawWasmValue cannot be converted to V128" ) ,
4434 ValType :: RefExtern => match i64:: from ( self ) {
4535 v if v < 0 => WasmValue :: RefNull ( ValType :: RefExtern ) ,
4636 addr => WasmValue :: RefExtern ( addr as u32 ) ,
@@ -53,13 +43,6 @@ impl WasmValueRepr for RawWasmValue {
5343 }
5444}
5545
56- impl RawWasmValue {
57- #[ inline( always) ]
58- pub fn raw_value ( & self ) -> [ u8 ; 8 ] {
59- self . 0
60- }
61- }
62-
6346impl From < WasmValue > for RawWasmValue {
6447 #[ inline]
6548 fn from ( v : WasmValue ) -> Self {
@@ -68,6 +51,7 @@ impl From<WasmValue> for RawWasmValue {
6851 WasmValue :: I64 ( i) => Self :: from ( i) ,
6952 WasmValue :: F32 ( i) => Self :: from ( i) ,
7053 WasmValue :: F64 ( i) => Self :: from ( i) ,
54+ WasmValue :: V128 ( _) => panic ! ( "RawWasmValue cannot be converted to V128" ) ,
7155 WasmValue :: RefExtern ( v) => Self :: from ( v as i64 ) ,
7256 WasmValue :: RefFunc ( v) => Self :: from ( v as i64 ) ,
7357 WasmValue :: RefNull ( _) => Self :: from ( -1i64 ) ,
0 commit comments