1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Part of the logic, here, is borrowed as-is from rust's stdlib.

mod dwarf;

cfg_if::cfg_if! {
    if #[cfg(any(target_env = "msvc", target_family = "wasm"))] {
        // We have yet to figure this out.
        #[repr(C)]
        pub struct UwExceptionWrapper {
            pub _uwe: (),
            pub cause: Box<dyn std::any::Any + Send>,
        }

        impl UwExceptionWrapper {
            pub fn new(tag: u64, data_ptr: usize, data_size: u64) -> Self {
                Self {
                    _uwe: (),
                    cause: Box::new(WasmerException {
                        tag,
                        data_ptr,
                        data_size,
                    }),
                }
            }
        }

        #[repr(C)]
        #[derive(Debug, thiserror::Error, Clone)]
        #[error("Uncaught exception in wasm code!")]
        pub struct WasmerException {
            pub tag: u64,
            pub data_ptr: usize,
            pub data_size: u64,
        }

        pub fn wasmer_eh_personality() {
            panic!()
        }

        pub  fn throw(tag: u64, data_ptr: usize, data_size: u64) -> ! {
            panic!()
        }

        pub fn rethrow(exc: *mut UwExceptionWrapper) -> ! {
            panic!()
        }


    } else if #[cfg(any(
        all(target_family = "windows", target_env = "gnu"),
        target_family = "unix",
    ))] {
        // gcc-like eh-personality mechanisms.
        mod gcc;
        pub use gcc::*;
    } else {
        // Targets that don't support unwinding.
        // - os=none ("bare metal" targets)
        // - os=uefi
        // - os=espidf
        // - os=hermit
        // - nvptx64-nvidia-cuda
        // - arch=avr
    }
}