Improved code based on feedback

This commit is contained in:
Syrus Akbary
2021-07-14 04:10:49 -07:00
parent 983190cc6e
commit 93b84110e9
4 changed files with 24 additions and 20 deletions

View File

@@ -77,7 +77,7 @@ impl From<ExportError> for HostEnvInitError {
/// }
/// }
/// ```
pub trait WasmerEnv: {
pub trait WasmerEnv {
/// The function that Wasmer will call on your type to let it finish
/// setting up the environment with data from the `Instance`.
///

View File

@@ -65,6 +65,7 @@ impl VMFunction {
environment: environment.map(|env| Arc::new(RefCell::new(env))),
}
}
pub(crate) fn init_envs(&self, instance: &Instance) -> Result<(), HostEnvInitError> {
if let Some(env) = &self.environment {
let mut borrowed_env = env.borrow_mut();

View File

@@ -1,11 +1,11 @@
// use super::frame_info::{FrameInfo, GlobalFrameInfo, FRAME_INFO};
use std::convert::TryInto;
use std::error::Error;
use std::fmt;
use std::sync::Arc;
use std::convert::TryInto;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsValue;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
/// A struct representing an aborted instruction execution, with a message
/// indicating the cause.
@@ -61,8 +61,7 @@ impl RuntimeError {
pub fn raise(error: Box<dyn Error + Send + Sync>) -> ! {
let error = if error.is::<RuntimeError>() {
*error.downcast::<RuntimeError>().unwrap()
}
else {
} else {
RuntimeError {
inner: Arc::new(RuntimeErrorSource::User(error)),
}
@@ -131,13 +130,13 @@ impl From<JsValue> for RuntimeError {
// Ok(rt) => rt,
// Err(_) => RuntimeError {
// inner: Arc::new(RuntimeErrorSource::Js(original)),
// }
// }
// }
// match original.dyn_into::<RuntimeError>() {
// Ok(rt) => rt,
// Err(original) => RuntimeError {
// inner: Arc::new(RuntimeErrorSource::Js(original)),
// }
// }
// }
}
}