wiggle: introduce wiggle::Trap, which can be either a String or I32

also, make noreturn functions always return a Trap

wasmtime-wiggle can trivially turn a wiggle::Trap into a wasmtime::Trap.
lucet will have to do the same.
This commit is contained in:
Pat Hickey
2021-01-05 18:19:31 -08:00
parent 4018a06da2
commit f8f9b14c6f
5 changed files with 70 additions and 46 deletions

View File

@@ -199,8 +199,9 @@ fn generate_func(
#(#arg_names),*
);
match result {
Ok(r) => {return Ok(r.into());},
Err(err) => { return Err(wasmtime::Trap::new(err)); },
Ok(r) => Ok(r.into()),
Err(wasmtime_wiggle::Trap::String(err)) => Err(wasmtime::Trap::new(err)),
Err(wasmtime_wiggle::Trap::I32(err)) => Err(wasmtime::Trap::i32_exit(err)),
}
}
}