Add/use create_wasi_instance() instead of instantiate_wasi(). (#571)
* Add/use create_wasi_instance() instead of instantiate_wasi(). * rm Result from Instance::from_handle
This commit is contained in:
committed by
Dan Gohman
parent
9896a5cabd
commit
ea56118651
@@ -103,11 +103,8 @@ pub fn instantiate(
|
||||
// If this module expects to be able to use wasi then go ahead and hook
|
||||
// that up into the imported crates.
|
||||
let wasi = if let Some(module_name) = data.find_wasi_module_name() {
|
||||
let global_exports = store.borrow().global_exports().clone();
|
||||
let wasi_handle = wasmtime_wasi::instantiate_wasi("", global_exports, &[], &[], &[])
|
||||
let instance = wasmtime_wasi::create_wasi_instance(&store, &[], &[], &[])
|
||||
.map_err(|e| err2py(e.into()))?;
|
||||
let instance =
|
||||
api::Instance::from_handle(&store, wasi_handle).map_err(|e| err2py(e.into()))?;
|
||||
Some((module_name, instance))
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -66,14 +66,8 @@ fn generate_load(item: &syn::ItemTrait) -> syn::Result<TokenStream> {
|
||||
|
||||
let mut imports: Vec<Extern> = Vec::new();
|
||||
if let Some(module_name) = data.find_wasi_module_name() {
|
||||
let wasi_handle = wasmtime_wasi::instantiate_wasi(
|
||||
"",
|
||||
global_exports,
|
||||
&[],
|
||||
&[],
|
||||
&[],
|
||||
)?;
|
||||
let wasi_instance = Instance::from_handle(&store, wasi_handle)?;
|
||||
let wasi_instance = wasmtime_wasi::create_wasi_instance(&store, &[], &[], &[])
|
||||
.map_err(|e| format_err!("wasm instantiation error: {:?}", e))?;
|
||||
for i in module.borrow().imports().iter() {
|
||||
if i.module().as_str() != module_name {
|
||||
bail!("unknown import module {}", i.module().as_str());
|
||||
|
||||
Reference in New Issue
Block a user