Fix formatting

This commit is contained in:
Syrus
2019-04-10 10:29:09 -07:00
parent 1ee5e7cde6
commit e620d6bef9
2 changed files with 10 additions and 4 deletions

View File

@ -185,6 +185,8 @@ macro_rules! invoke {
Ok(v) => v, Ok(v) => v,
Err(_e) => { Err(_e) => {
get_emscripten_data($ctx).stack_restore.as_ref().expect("stack_restore is None").call(sp).expect("stack_restore call failed"); get_emscripten_data($ctx).stack_restore.as_ref().expect("stack_restore is None").call(sp).expect("stack_restore call failed");
// TODO: We should check if _e != "longjmp" and if that's the case, re-throw the error
// JS version is: if (e !== e+0 && e !== 'longjmp') throw e;
get_emscripten_data($ctx).set_threw.as_ref().expect("set_threw is None").call(1, 0).expect("set_threw call failed"); get_emscripten_data($ctx).set_threw.as_ref().expect("set_threw is None").call(1, 0).expect("set_threw call failed");
0 as _ 0 as _
} }
@ -199,6 +201,8 @@ macro_rules! invoke_no_return {
Ok(v) => v, Ok(v) => v,
Err(_e) => { Err(_e) => {
get_emscripten_data($ctx).stack_restore.as_ref().expect("stack_restore is None").call(sp).expect("stack_restore call failed"); get_emscripten_data($ctx).stack_restore.as_ref().expect("stack_restore is None").call(sp).expect("stack_restore call failed");
// TODO: We should check if _e != "longjmp" and if that's the case, re-throw the error
// JS version is: if (e !== e+0 && e !== 'longjmp') throw e;
get_emscripten_data($ctx).set_threw.as_ref().expect("set_threw is None").call(1, 0).expect("set_threw call failed"); get_emscripten_data($ctx).set_threw.as_ref().expect("set_threw is None").call(1, 0).expect("set_threw call failed");
} }
} }

View File

@ -1,6 +1,6 @@
use super::process::abort_with_message;
use super::env::get_emscripten_data; use super::env::get_emscripten_data;
use libc::{c_int}; use super::process::abort_with_message;
use libc::c_int;
// use std::cell::UnsafeCell; // use std::cell::UnsafeCell;
use wasmer_runtime_core::vm::Ctx; use wasmer_runtime_core::vm::Ctx;
@ -42,7 +42,8 @@ pub fn __longjmp(ctx: &mut Ctx, _env_addr: u32, _val: c_int) {
} }
/// _longjmp /// _longjmp
pub fn _longjmp(ctx: &mut Ctx, env_addr: i32, val: c_int) { // This function differs from the js implementation, it should return Result<(), &'static str>
pub fn _longjmp(ctx: &mut Ctx, env_addr: i32, val: c_int) -> Result<(), ()> {
let val = if val == 0 { 1 } else { val }; let val = if val == 0 { 1 } else { val };
get_emscripten_data(ctx) get_emscripten_data(ctx)
.set_threw .set_threw
@ -50,7 +51,8 @@ pub fn _longjmp(ctx: &mut Ctx, env_addr: i32, val: c_int) {
.expect("set_threw is None") .expect("set_threw is None")
.call(env_addr, val) .call(env_addr, val)
.expect("set_threw failed to call"); .expect("set_threw failed to call");
panic!("longjmp") // TODO: return Err("longjmp")
Err(())
} }
// extern "C" { // extern "C" {