wasmer_emscripten/
exception.rs

1use super::env;
2use super::process::_abort;
3use crate::EmEnv;
4use wasmer::FunctionEnvMut;
5
6/// emscripten: ___cxa_allocate_exception
7pub fn ___cxa_allocate_exception(mut ctx: FunctionEnvMut<EmEnv>, size: u32) -> u32 {
8    debug!("emscripten::___cxa_allocate_exception");
9    env::call_malloc(&mut ctx.as_mut(), size as _)
10}
11
12pub fn ___cxa_current_primary_exception(_ctx: FunctionEnvMut<EmEnv>) -> u32 {
13    debug!("emscripten::___cxa_current_primary_exception");
14    unimplemented!("emscripten::___cxa_current_primary_exception")
15}
16
17pub fn ___cxa_decrement_exception_refcount(_ctx: FunctionEnvMut<EmEnv>, _a: u32) {
18    debug!("emscripten::___cxa_decrement_exception_refcount({})", _a);
19    unimplemented!("emscripten::___cxa_decrement_exception_refcount({})", _a)
20}
21
22pub fn ___cxa_increment_exception_refcount(_ctx: FunctionEnvMut<EmEnv>, _a: u32) {
23    debug!("emscripten::___cxa_increment_exception_refcount({})", _a);
24    unimplemented!("emscripten::___cxa_increment_exception_refcount({})", _a)
25}
26
27pub fn ___cxa_rethrow_primary_exception(_ctx: FunctionEnvMut<EmEnv>, _a: u32) {
28    debug!("emscripten::___cxa_rethrow_primary_exception({})", _a);
29    unimplemented!("emscripten::___cxa_rethrow_primary_exception({})", _a)
30}
31
32/// emscripten: ___cxa_throw
33/// TODO: We don't have support for exceptions yet
34pub fn ___cxa_throw(ctx: FunctionEnvMut<EmEnv>, _ptr: u32, _ty: u32, _destructor: u32) {
35    debug!("emscripten::___cxa_throw");
36    eprintln!("Throwing exceptions not yet implemented: aborting!");
37    _abort(ctx);
38}
39
40pub fn ___cxa_begin_catch(_ctx: FunctionEnvMut<EmEnv>, _exception_object_ptr: u32) -> i32 {
41    debug!("emscripten::___cxa_begin_catch");
42    -1
43}
44
45pub fn ___cxa_end_catch(_ctx: FunctionEnvMut<EmEnv>) {
46    debug!("emscripten::___cxa_end_catch");
47}
48
49pub fn ___cxa_uncaught_exception(_ctx: FunctionEnvMut<EmEnv>) -> i32 {
50    debug!("emscripten::___cxa_uncaught_exception");
51    -1
52}
53
54pub fn ___cxa_pure_virtual(_ctx: FunctionEnvMut<EmEnv>) {
55    debug!("emscripten::___cxa_pure_virtual");
56    // ABORT = true
57    panic!("Pure virtual function called!");
58}