@@ -9,7 +9,7 @@ use crate::{
99} ;
1010use alloc:: boxed:: Box ;
1111use core:: { mem:: MaybeUninit , ptr} ;
12- use wasmi:: { Func , Ref , Val , ValType , F32 , F64 , V128 } ;
12+ use wasmi:: { Func , Ref , Val , ValType , F32 , F64 } ;
1313
1414/// A Wasm value.
1515///
@@ -38,8 +38,6 @@ pub union wasm_val_union {
3838 pub f32 : f32 ,
3939 /// A Wasm 64-bit float.
4040 pub f64 : f64 ,
41- /// A Wasm `v128` value.
42- pub v128 : u128 ,
4341 /// A Wasm referenced object.
4442 pub ref_ : * mut wasm_ref_t ,
4543}
@@ -99,12 +97,9 @@ impl From<Val> for wasm_val_t {
9997 u64 : value. to_bits ( ) ,
10098 } ,
10199 } ,
102- Val :: V128 ( value) => Self {
103- kind : from_valtype ( & ValType :: V128 ) ,
104- of : wasm_val_union {
105- v128 : value. as_u128 ( ) ,
106- } ,
107- } ,
100+ Val :: V128 ( value) => core:: panic!(
101+ "`wasm_val_t`: creating a `wasm_val_t` from an `v128` value is not supported but found: {value:?}"
102+ ) ,
108103 Val :: FuncRef ( funcref) => Self {
109104 kind : from_valtype ( & ValType :: FuncRef ) ,
110105 of : wasm_val_union {
@@ -132,17 +127,16 @@ impl wasm_val_t {
132127 ///
133128 /// This effectively clones the [`wasm_val_t`] if necessary.
134129 pub fn to_val ( & self ) -> Val {
135- match into_valtype ( self . kind ) {
136- ValType :: I32 => Val :: from ( unsafe { self . of . i32 } ) ,
137- ValType :: I64 => Val :: from ( unsafe { self . of . i64 } ) ,
138- ValType :: F32 => Val :: from ( F32 :: from ( unsafe { self . of . f32 } ) ) ,
139- ValType :: F64 => Val :: from ( F64 :: from ( unsafe { self . of . f64 } ) ) ,
140- ValType :: V128 => Val :: from ( V128 :: from ( unsafe { self . of . v128 } ) ) ,
141- ValType :: FuncRef => match unsafe { self . of . ref_ } . is_null ( ) {
130+ match self . kind {
131+ wasm_valkind_t:: WASM_I32 => Val :: from ( unsafe { self . of . i32 } ) ,
132+ wasm_valkind_t:: WASM_I64 => Val :: from ( unsafe { self . of . i64 } ) ,
133+ wasm_valkind_t:: WASM_F32 => Val :: from ( F32 :: from ( unsafe { self . of . f32 } ) ) ,
134+ wasm_valkind_t:: WASM_F64 => Val :: from ( F64 :: from ( unsafe { self . of . f64 } ) ) ,
135+ wasm_valkind_t:: WASM_FUNCREF => match unsafe { self . of . ref_ } . is_null ( ) {
142136 true => Val :: FuncRef ( <Ref < Func > >:: Null ) ,
143137 false => ref_to_val ( unsafe { & * self . of . ref_ } ) ,
144138 } ,
145- ValType :: ExternRef => {
139+ wasm_valkind_t :: WASM_EXTERNREF => {
146140 core:: unreachable!( "`wasm_val_t`: cannot contain non-function reference values" )
147141 }
148142 }
0 commit comments