Naive short circuiting implementation for user panics and results. (#167)

* Add panic and result catching

* exit process on panic and user runtime error

* Complete initial implementation
This commit is contained in:
Lachlan Sneff
2019-02-08 13:08:03 -08:00
committed by GitHub
parent 4e1bc483a8
commit 1886b3d3c1
10 changed files with 171 additions and 60 deletions

View File

@ -3,6 +3,7 @@ use crate::{
error::Result,
import::ImportObject,
structures::{Map, TypedIndex},
typed_func::EARLY_TRAPPER,
types::{
FuncIndex, FuncSig, GlobalDescriptor, GlobalIndex, GlobalInit, ImportedFuncIndex,
ImportedGlobalIndex, ImportedMemoryIndex, ImportedTableIndex, Initializer,
@ -63,6 +64,10 @@ pub struct Module(#[doc(hidden)] pub Arc<ModuleInner>);
impl Module {
pub(crate) fn new(inner: Arc<ModuleInner>) -> Self {
unsafe {
EARLY_TRAPPER
.with(|ucell| *ucell.get() = Some(inner.protected_caller.get_early_trapper()));
}
Module(inner)
}