1use wasmer_types::{NativeWasmType, RawValue, Type};
5
6use crate::store::AsStoreRef;
7use crate::vm::{VMExternRef, VMFuncRef};
8
9use crate::{ExternRef, Function, TypedFunction};
10use std::array::TryFromSliceError;
11use std::convert::Infallible;
12use std::convert::TryInto;
13use std::error::Error;
14
15use crate::store::AsStoreMut;
16
17pub trait NativeWasmTypeInto: NativeWasmType + Sized {
20 #[doc(hidden)]
21 fn into_abi(self, store: &mut impl AsStoreMut) -> Self::Abi;
22
23 #[doc(hidden)]
24 unsafe fn from_abi(store: &mut impl AsStoreMut, abi: Self::Abi) -> Self;
25
26 fn into_raw(self, store: &mut impl AsStoreMut) -> RawValue;
28
29 unsafe fn from_raw(store: &mut impl AsStoreMut, raw: RawValue) -> Self;
34}
35
36impl NativeWasmTypeInto for i32 {
37 #[inline]
38 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
39 abi
40 }
41
42 #[inline]
43 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
44 self
45 }
46
47 #[inline]
48 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
49 RawValue { i32: self }
50 }
51
52 #[inline]
53 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
54 raw.i32
55 }
56}
57
58impl NativeWasmTypeInto for u32 {
59 #[inline]
60 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
61 abi
62 }
63
64 #[inline]
65 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
66 self
67 }
68
69 #[inline]
70 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
71 RawValue { i32: self as _ }
72 }
73
74 #[inline]
75 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
76 raw.i32 as _
77 }
78}
79
80impl NativeWasmTypeInto for i64 {
81 #[inline]
82 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
83 abi
84 }
85
86 #[inline]
87 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
88 self
89 }
90
91 #[inline]
92 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
93 RawValue { i64: self }
94 }
95
96 #[inline]
97 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
98 raw.i64
99 }
100}
101
102impl NativeWasmTypeInto for u64 {
103 #[inline]
104 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
105 abi
106 }
107
108 #[inline]
109 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
110 self
111 }
112
113 #[inline]
114 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
115 RawValue { i64: self as _ }
116 }
117
118 #[inline]
119 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
120 raw.i64 as _
121 }
122}
123
124impl NativeWasmTypeInto for f32 {
125 #[inline]
126 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
127 abi
128 }
129
130 #[inline]
131 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
132 self
133 }
134
135 #[inline]
136 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
137 RawValue { f32: self }
138 }
139
140 #[inline]
141 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
142 raw.f32
143 }
144}
145
146impl NativeWasmTypeInto for f64 {
147 #[inline]
148 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
149 abi
150 }
151
152 #[inline]
153 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
154 self
155 }
156
157 #[inline]
158 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
159 RawValue { f64: self }
160 }
161
162 #[inline]
163 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
164 raw.f64
165 }
166}
167
168impl NativeWasmTypeInto for u128 {
169 #[inline]
170 unsafe fn from_abi(_store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
171 abi
172 }
173
174 #[inline]
175 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
176 self
177 }
178
179 #[inline]
180 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
181 RawValue { u128: self }
182 }
183
184 #[inline]
185 unsafe fn from_raw(_store: &mut impl AsStoreMut, raw: RawValue) -> Self {
186 raw.u128
187 }
188}
189
190impl NativeWasmType for ExternRef {
191 const WASM_TYPE: Type = Type::ExternRef;
192 type Abi = usize;
193}
194
195impl NativeWasmTypeInto for Option<ExternRef> {
196 #[inline]
197 unsafe fn from_abi(store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
198 VMExternRef::from_raw(RawValue { externref: abi })
199 .map(|e| ExternRef::from_vm_externref(store, e))
200 }
201
202 #[inline]
203 fn into_abi(self, _store: &mut impl AsStoreMut) -> Self::Abi {
204 self.map_or(0, |e| unsafe { e.vm_externref().into_raw().externref })
205 }
206
207 #[inline]
208 fn into_raw(self, _store: &mut impl AsStoreMut) -> RawValue {
209 self.map_or(RawValue { externref: 0 }, |e| e.vm_externref().into_raw())
210 }
211
212 #[inline]
213 unsafe fn from_raw(store: &mut impl AsStoreMut, raw: RawValue) -> Self {
214 VMExternRef::from_raw(raw).map(|e| ExternRef::from_vm_externref(store, e))
215 }
216}
217
218impl<Args, Rets> From<TypedFunction<Args, Rets>> for Function
219where
220 Args: WasmTypeList,
221 Rets: WasmTypeList,
222{
223 fn from(other: TypedFunction<Args, Rets>) -> Self {
224 other.into_function()
225 }
226}
227
228impl NativeWasmType for Function {
229 const WASM_TYPE: Type = Type::FuncRef;
230 type Abi = usize;
231}
232
233impl NativeWasmTypeInto for Option<Function> {
234 #[inline]
235 unsafe fn from_abi(store: &mut impl AsStoreMut, abi: Self::Abi) -> Self {
236 VMFuncRef::from_raw(RawValue { funcref: abi }).map(|f| Function::from_vm_funcref(store, f))
237 }
238
239 #[inline]
240 fn into_abi(self, store: &mut impl AsStoreMut) -> Self::Abi {
241 self.map_or(0, |f| unsafe { f.vm_funcref(store).into_raw().externref })
242 }
243
244 #[inline]
245 fn into_raw(self, store: &mut impl AsStoreMut) -> RawValue {
246 self.map_or(RawValue { externref: 0 }, |e| {
247 e.vm_funcref(store).into_raw()
248 })
249 }
250
251 #[inline]
252 unsafe fn from_raw(store: &mut impl AsStoreMut, raw: RawValue) -> Self {
253 VMFuncRef::from_raw(raw).map(|f| Function::from_vm_funcref(store, f))
254 }
255}
256
257pub unsafe trait FromToNativeWasmType
269where
270 Self: Sized,
271{
272 type Native: NativeWasmTypeInto;
274
275 fn from_native(native: Self::Native) -> Self;
282
283 fn to_native(self) -> Self::Native;
290
291 fn is_from_store(&self, _store: &impl AsStoreRef) -> bool {
296 true
297 }
298}
299
300macro_rules! from_to_native_wasm_type {
301 ( $( $type:ty => $native_type:ty ),* ) => {
302 $(
303 #[allow(clippy::use_self)]
304 unsafe impl FromToNativeWasmType for $type {
305 type Native = $native_type;
306
307 #[inline]
308 fn from_native(native: Self::Native) -> Self {
309 native as Self
310 }
311
312 #[inline]
313 fn to_native(self) -> Self::Native {
314 self as Self::Native
315 }
316 }
317 )*
318 };
319}
320
321macro_rules! from_to_native_wasm_type_same_size {
322 ( $( $type:ty => $native_type:ty ),* ) => {
323 $(
324 #[allow(clippy::use_self)]
325 unsafe impl FromToNativeWasmType for $type {
326 type Native = $native_type;
327
328 #[inline]
329 fn from_native(native: Self::Native) -> Self {
330 Self::from_ne_bytes(Self::Native::to_ne_bytes(native))
331 }
332
333 #[inline]
334 fn to_native(self) -> Self::Native {
335 Self::Native::from_ne_bytes(Self::to_ne_bytes(self))
336 }
337 }
338 )*
339 };
340}
341
342from_to_native_wasm_type!(
343 i8 => i32,
344 u8 => i32,
345 i16 => i32,
346 u16 => i32
347);
348
349from_to_native_wasm_type_same_size!(
350 i32 => i32,
351 u32 => i32,
352 i64 => i64,
353 u64 => i64,
354 f32 => f32,
355 f64 => f64
356);
357
358unsafe impl FromToNativeWasmType for Option<ExternRef> {
359 type Native = Self;
360
361 fn to_native(self) -> Self::Native {
362 self
363 }
364 fn from_native(n: Self::Native) -> Self {
365 n
366 }
367 fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
368 self.as_ref().map_or(true, |e| e.is_from_store(store))
369 }
370}
371
372unsafe impl FromToNativeWasmType for Option<Function> {
373 type Native = Self;
374
375 fn to_native(self) -> Self::Native {
376 self
377 }
378 fn from_native(n: Self::Native) -> Self {
379 n
380 }
381 fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
382 self.as_ref().map_or(true, |f| f.is_from_store(store))
383 }
384}
385
386#[cfg(test)]
387mod test_from_to_native_wasm_type {
388 use super::*;
389
390 #[test]
391 fn test_to_native() {
392 assert_eq!(7i8.to_native(), 7i32);
393 assert_eq!(7u8.to_native(), 7i32);
394 assert_eq!(7i16.to_native(), 7i32);
395 assert_eq!(7u16.to_native(), 7i32);
396 assert_eq!(u32::MAX.to_native(), -1);
397 }
398
399 #[test]
400 fn test_to_native_same_size() {
401 assert_eq!(7i32.to_native(), 7i32);
402 assert_eq!(7u32.to_native(), 7i32);
403 assert_eq!(7i64.to_native(), 7i64);
404 assert_eq!(7u64.to_native(), 7i64);
405 assert_eq!(7f32.to_native(), 7f32);
406 assert_eq!(7f64.to_native(), 7f64);
407 }
408}
409
410pub trait WasmTypeList
414where
415 Self: Sized,
416{
417 type CStruct;
420
421 type Array: AsMut<[RawValue]>;
425
426 fn size() -> u32;
428
429 unsafe fn from_array(store: &mut impl AsStoreMut, array: Self::Array) -> Self;
433
434 unsafe fn from_slice(
443 store: &mut impl AsStoreMut,
444 slice: &[RawValue],
445 ) -> Result<Self, TryFromSliceError>;
446
447 unsafe fn into_array(self, store: &mut impl AsStoreMut) -> Self::Array;
452
453 fn empty_array() -> Self::Array;
457
458 unsafe fn from_c_struct(store: &mut impl AsStoreMut, c_struct: Self::CStruct) -> Self;
463
464 unsafe fn into_c_struct(self, store: &mut impl AsStoreMut) -> Self::CStruct;
469
470 unsafe fn write_c_struct_to_ptr(c_struct: Self::CStruct, ptr: *mut RawValue);
474
475 fn wasm_types() -> &'static [Type];
478}
479
480pub trait IntoResult<T>
486where
487 T: WasmTypeList,
488{
489 type Error: Error + Sync + Send + 'static;
491
492 fn into_result(self) -> Result<T, Self::Error>;
494}
495
496impl<T> IntoResult<T> for T
497where
498 T: WasmTypeList,
499{
500 type Error = Infallible;
503
504 fn into_result(self) -> Result<Self, Infallible> {
505 Ok(self)
506 }
507}
508
509impl<T, E> IntoResult<T> for Result<T, E>
510where
511 T: WasmTypeList,
512 E: Error + Sync + Send + 'static,
513{
514 type Error = E;
515
516 fn into_result(self) -> Self {
517 self
518 }
519}
520
521#[cfg(test)]
522mod test_into_result {
523 use super::*;
524 use std::convert::Infallible;
525
526 #[test]
527 fn test_into_result_over_t() {
528 let x: i32 = 42;
529 let result_of_x: Result<i32, Infallible> = x.into_result();
530
531 assert_eq!(result_of_x.unwrap(), x);
532 }
533
534 #[test]
535 fn test_into_result_over_result() {
536 {
537 let x: Result<i32, Infallible> = Ok(42);
538 let result_of_x: Result<i32, Infallible> = x.into_result();
539
540 assert_eq!(result_of_x, x);
541 }
542
543 {
544 use std::{error, fmt};
545
546 #[derive(Debug, PartialEq)]
547 struct E;
548
549 impl fmt::Display for E {
550 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
551 write!(formatter, "E")
552 }
553 }
554
555 impl error::Error for E {}
556
557 let x: Result<Infallible, E> = Err(E);
558 let result_of_x: Result<Infallible, E> = x.into_result();
559
560 assert_eq!(result_of_x.unwrap_err(), E);
561 }
562 }
563}
564
565impl WasmTypeList for Infallible {
570 type CStruct = Self;
571 type Array = [RawValue; 0];
572
573 fn size() -> u32 {
574 0
575 }
576
577 unsafe fn from_array(_: &mut impl AsStoreMut, _: Self::Array) -> Self {
578 unreachable!()
579 }
580
581 unsafe fn from_slice(
582 _: &mut impl AsStoreMut,
583 _: &[RawValue],
584 ) -> Result<Self, TryFromSliceError> {
585 unreachable!()
586 }
587
588 unsafe fn into_array(self, _: &mut impl AsStoreMut) -> Self::Array {
589 []
590 }
591
592 fn empty_array() -> Self::Array {
593 []
594 }
595
596 unsafe fn from_c_struct(_: &mut impl AsStoreMut, self_: Self::CStruct) -> Self {
597 self_
598 }
599
600 unsafe fn into_c_struct(self, _: &mut impl AsStoreMut) -> Self::CStruct {
601 self
602 }
603
604 unsafe fn write_c_struct_to_ptr(_: Self::CStruct, _: *mut RawValue) {}
605
606 fn wasm_types() -> &'static [Type] {
607 &[]
608 }
609}
610
611macro_rules! impl_wasmtypelist {
612 ( [$c_struct_representation:ident]
613 $c_struct_name:ident,
614 $( $x:ident ),* ) => {
615
616 #[repr($c_struct_representation)]
619 pub struct $c_struct_name< $( $x ),* > ( $( <<$x as FromToNativeWasmType>::Native as NativeWasmType>::Abi ),* )
620 where
621 $( $x: FromToNativeWasmType ),*;
622
623 #[allow(unused_parens, dead_code)]
625 impl< $( $x ),* >
626 WasmTypeList
627 for
628 ( $( $x ),* )
629 where
630 $( $x: FromToNativeWasmType ),*
631 {
632 type CStruct = $c_struct_name< $( $x ),* >;
633
634 type Array = [RawValue; count_idents!( $( $x ),* )];
635
636 fn size() -> u32 {
637 count_idents!( $( $x ),* ) as _
638 }
639
640 #[allow(unused_mut)]
641 #[allow(clippy::unused_unit)]
642 #[allow(clippy::missing_safety_doc)]
643 unsafe fn from_array(mut _store: &mut impl AsStoreMut, array: Self::Array) -> Self {
644 #[allow(non_snake_case)]
646 let [ $( $x ),* ] = array;
647
648 (
650 $(
651 FromToNativeWasmType::from_native(NativeWasmTypeInto::from_raw(_store, $x))
652 ),*
653 )
654 }
655
656 #[allow(clippy::missing_safety_doc)]
657 unsafe fn from_slice(store: &mut impl AsStoreMut, slice: &[RawValue]) -> Result<Self, TryFromSliceError> {
658 Ok(Self::from_array(store, slice.try_into()?))
659 }
660
661 #[allow(unused_mut)]
662 #[allow(clippy::missing_safety_doc)]
663 unsafe fn into_array(self, mut _store: &mut impl AsStoreMut) -> Self::Array {
664 #[allow(non_snake_case)]
666 let ( $( $x ),* ) = self;
667
668 [
670 $(
671 FromToNativeWasmType::to_native($x).into_raw(_store)
672 ),*
673 ]
674 }
675
676 fn empty_array() -> Self::Array {
677 [RawValue { i32: 0 }; count_idents!( $( $x ),* )]
679 }
680
681 #[allow(unused_mut)]
682 #[allow(clippy::unused_unit)]
683 #[allow(clippy::missing_safety_doc)]
684 unsafe fn from_c_struct(mut _store: &mut impl AsStoreMut, c_struct: Self::CStruct) -> Self {
685 #[allow(non_snake_case)]
687 let $c_struct_name( $( $x ),* ) = c_struct;
688
689 (
690 $(
691 FromToNativeWasmType::from_native(NativeWasmTypeInto::from_abi(_store, $x))
692 ),*
693 )
694 }
695
696 #[allow(unused_parens, non_snake_case, unused_mut)]
697 #[allow(clippy::missing_safety_doc)]
698 unsafe fn into_c_struct(self, mut _store: &mut impl AsStoreMut) -> Self::CStruct {
699 let ( $( $x ),* ) = self;
701
702 $c_struct_name(
704 $(
705 FromToNativeWasmType::to_native($x).into_abi(_store)
706 ),*
707 )
708 }
709
710 #[allow(non_snake_case)]
711 unsafe fn write_c_struct_to_ptr(c_struct: Self::CStruct, _ptr: *mut RawValue) {
712 let $c_struct_name( $( $x ),* ) = c_struct;
714
715 let mut _n = 0;
716 $(
717 *_ptr.add(_n).cast() = $x;
718 _n += 1;
719 )*
720 }
721
722 fn wasm_types() -> &'static [Type] {
723 &[
724 $(
725 $x::Native::WASM_TYPE
726 ),*
727 ]
728 }
729 }
730
731 };
732}
733
734macro_rules! count_idents {
736 ( $($idents:ident),* ) => {
737 {
738 #[allow(dead_code, non_camel_case_types)]
739 enum Idents { $( $idents, )* __CountIdentsLast }
740 const COUNT: usize = Idents::__CountIdentsLast as usize;
741 COUNT
742 }
743 };
744}
745
746impl_wasmtypelist!([C] S0,);
749impl_wasmtypelist!([transparent] S1, A1);
750impl_wasmtypelist!([C] S2, A1, A2);
751impl_wasmtypelist!([C] S3, A1, A2, A3);
752impl_wasmtypelist!([C] S4, A1, A2, A3, A4);
753impl_wasmtypelist!([C] S5, A1, A2, A3, A4, A5);
754impl_wasmtypelist!([C] S6, A1, A2, A3, A4, A5, A6);
755impl_wasmtypelist!([C] S7, A1, A2, A3, A4, A5, A6, A7);
756impl_wasmtypelist!([C] S8, A1, A2, A3, A4, A5, A6, A7, A8);
757impl_wasmtypelist!([C] S9, A1, A2, A3, A4, A5, A6, A7, A8, A9);
758impl_wasmtypelist!([C] S10, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
759impl_wasmtypelist!([C] S11, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11);
760impl_wasmtypelist!([C] S12, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12);
761impl_wasmtypelist!([C] S13, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13);
762impl_wasmtypelist!([C] S14, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14);
763impl_wasmtypelist!([C] S15, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15);
764impl_wasmtypelist!([C] S16, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16);
765impl_wasmtypelist!([C] S17, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17);
766impl_wasmtypelist!([C] S18, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18);
767impl_wasmtypelist!([C] S19, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19);
768impl_wasmtypelist!([C] S20, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20);
769impl_wasmtypelist!([C] S21, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21);
770impl_wasmtypelist!([C] S22, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22);
771impl_wasmtypelist!([C] S23, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23);
772impl_wasmtypelist!([C] S24, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24);
773impl_wasmtypelist!([C] S25, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25);
774impl_wasmtypelist!([C] S26, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26);
775
776#[cfg(test)]
777mod test_wasm_type_list {
778 use super::*;
779 use wasmer_types::Type;
780 #[test]
813 fn test_empty_array() {
814 assert_eq!(<()>::empty_array().len(), 0);
815 assert_eq!(<i32>::empty_array().len(), 1);
816 assert_eq!(<(i32, i64)>::empty_array().len(), 2);
817 }
818 #[test]
833 fn test_wasm_types_for_uni_values() {
834 assert_eq!(<i32>::wasm_types(), [Type::I32]);
835 assert_eq!(<i64>::wasm_types(), [Type::I64]);
836 assert_eq!(<f32>::wasm_types(), [Type::F32]);
837 assert_eq!(<f64>::wasm_types(), [Type::F64]);
838 }
839
840 #[test]
841 fn test_wasm_types_for_multi_values() {
842 assert_eq!(<(i32, i32)>::wasm_types(), [Type::I32, Type::I32]);
843 assert_eq!(<(i64, i64)>::wasm_types(), [Type::I64, Type::I64]);
844 assert_eq!(<(f32, f32)>::wasm_types(), [Type::F32, Type::F32]);
845 assert_eq!(<(f64, f64)>::wasm_types(), [Type::F64, Type::F64]);
846
847 assert_eq!(
848 <(i32, i64, f32, f64)>::wasm_types(),
849 [Type::I32, Type::I64, Type::F32, Type::F64]
850 );
851 }
852}
853#[cfg(test)]
925mod test_native_type {
926 use super::*;
927 use wasmer_types::Type;
928
929 #[test]
930 fn test_wasm_types() {
931 assert_eq!(i32::WASM_TYPE, Type::I32);
932 assert_eq!(i64::WASM_TYPE, Type::I64);
933 assert_eq!(f32::WASM_TYPE, Type::F32);
934 assert_eq!(f64::WASM_TYPE, Type::F64);
935 assert_eq!(u128::WASM_TYPE, Type::V128);
936 }
937 }
950
951