Remove unneded prefix argument from instantiate_wasi. (#584)
* Remove unneded prefix argument from `instantiate_wasi`. This was an artifact of an earlier backwards-compatibility mechanism which is no longer needed. * Remove unneeded prefix arg from remaning uses
This commit is contained in:
@@ -53,7 +53,6 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
|
|||||||
Instance::from_handle(
|
Instance::from_handle(
|
||||||
&store,
|
&store,
|
||||||
wasmtime_wasi::instantiate_wasi_with_context(
|
wasmtime_wasi::instantiate_wasi_with_context(
|
||||||
"",
|
|
||||||
global_exports.clone(),
|
global_exports.clone(),
|
||||||
builder.build().context("failed to build wasi context")?,
|
builder.build().context("failed to build wasi context")?,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,14 +21,13 @@ pub fn create_wasi_instance(
|
|||||||
environ: &[(String, String)],
|
environ: &[(String, String)],
|
||||||
) -> Result<api::Instance, InstantiationError> {
|
) -> Result<api::Instance, InstantiationError> {
|
||||||
let global_exports = store.borrow().global_exports().clone();
|
let global_exports = store.borrow().global_exports().clone();
|
||||||
let wasi = instantiate_wasi("", global_exports, preopened_dirs, argv, environ)?;
|
let wasi = instantiate_wasi(global_exports, preopened_dirs, argv, environ)?;
|
||||||
let instance = api::Instance::from_handle(&store, wasi);
|
let instance = api::Instance::from_handle(&store, wasi);
|
||||||
Ok(instance)
|
Ok(instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an instance implementing the "wasi" interface.
|
/// Return an instance implementing the "wasi" interface.
|
||||||
pub fn instantiate_wasi(
|
pub fn instantiate_wasi(
|
||||||
prefix: &str,
|
|
||||||
global_exports: Rc<RefCell<HashMap<String, Option<wasmtime_runtime::Export>>>>,
|
global_exports: Rc<RefCell<HashMap<String, Option<wasmtime_runtime::Export>>>>,
|
||||||
preopened_dirs: &[(String, File)],
|
preopened_dirs: &[(String, File)],
|
||||||
argv: &[String],
|
argv: &[String],
|
||||||
@@ -54,14 +53,13 @@ pub fn instantiate_wasi(
|
|||||||
let wasi_ctx = wasi_ctx_builder.build().map_err(|err| {
|
let wasi_ctx = wasi_ctx_builder.build().map_err(|err| {
|
||||||
InstantiationError::Resource(format!("couldn't assemble WASI context object: {}", err))
|
InstantiationError::Resource(format!("couldn't assemble WASI context object: {}", err))
|
||||||
})?;
|
})?;
|
||||||
instantiate_wasi_with_context(prefix, global_exports, wasi_ctx)
|
instantiate_wasi_with_context(global_exports, wasi_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an instance implementing the "wasi" interface.
|
/// Return an instance implementing the "wasi" interface.
|
||||||
///
|
///
|
||||||
/// The wasi context is configured by
|
/// The wasi context is configured by
|
||||||
pub fn instantiate_wasi_with_context(
|
pub fn instantiate_wasi_with_context(
|
||||||
prefix: &str,
|
|
||||||
global_exports: Rc<RefCell<HashMap<String, Option<wasmtime_runtime::Export>>>>,
|
global_exports: Rc<RefCell<HashMap<String, Option<wasmtime_runtime::Export>>>>,
|
||||||
wasi_ctx: WasiCtx,
|
wasi_ctx: WasiCtx,
|
||||||
) -> Result<InstanceHandle, InstantiationError> {
|
) -> Result<InstanceHandle, InstantiationError> {
|
||||||
@@ -88,10 +86,9 @@ pub fn instantiate_wasi_with_context(
|
|||||||
pointer_type,
|
pointer_type,
|
||||||
));
|
));
|
||||||
let func = module.functions.push(sig);
|
let func = module.functions.push(sig);
|
||||||
module.exports.insert(
|
module
|
||||||
prefix.to_owned() + stringify!($name),
|
.exports
|
||||||
Export::Function(func),
|
.insert(stringify!($name).to_owned(), Export::Function(func));
|
||||||
);
|
|
||||||
finished_functions.push(syscalls::$name::SHIM as *const VMFunctionBody);
|
finished_functions.push(syscalls::$name::SHIM as *const VMFunctionBody);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ fn main() -> Result<()> {
|
|||||||
#[cfg(feature = "wasi-c")]
|
#[cfg(feature = "wasi-c")]
|
||||||
{
|
{
|
||||||
let global_exports = store.borrow().global_exports().clone();
|
let global_exports = store.borrow().global_exports().clone();
|
||||||
let handle = instantiate_wasi_c("", global_exports, &preopen_dirs, &argv, &environ)?;
|
let handle = instantiate_wasi_c(global_exports, &preopen_dirs, &argv, &environ)?;
|
||||||
Instance::from_handle(&store, handle)
|
Instance::from_handle(&store, handle)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "wasi-c"))]
|
#[cfg(not(feature = "wasi-c"))]
|
||||||
|
|||||||
Reference in New Issue
Block a user