wasm_interp: create Instance::from_bytes

This commit is contained in:
Brian Carroll 2022-12-16 00:06:51 +00:00
parent 4d5b7f8b73
commit 4501f2af0e
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0

View file

@ -93,6 +93,17 @@ impl<'a, I: ImportDispatcher> Instance<'a, I> {
}
}
pub fn from_bytes(
arena: &'a Bump,
module_bytes: &[u8],
import_dispatcher: I,
is_debug_mode: bool,
) -> Result<Self, std::string::String> {
let module =
WasmModule::preload(arena, module_bytes, false).map_err(|e| format!("{:?}", e))?;
Self::for_module(arena, arena.alloc(module), import_dispatcher, is_debug_mode)
}
pub fn for_module(
arena: &'a Bump,
module: &'a WasmModule<'a>,