clean up implementation

This commit is contained in:
Mark McCaskey
2019-03-27 14:01:27 -07:00
parent f9a29445ca
commit 09068c1a74
11 changed files with 109 additions and 58 deletions

View File

@ -13,7 +13,6 @@ use crate::{
types::{FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex, Value},
vm,
};
use hashbrown::HashMap;
use std::{mem, sync::Arc};
pub(crate) struct InstanceInner {
@ -45,11 +44,7 @@ pub struct Instance {
}
impl Instance {
pub(crate) fn new(
module: Arc<ModuleInner>,
imports: &ImportObject,
maybe_symbol_map: Option<HashMap<u32, String>>,
) -> Result<Instance> {
pub(crate) fn new(module: Arc<ModuleInner>, imports: &ImportObject) -> Result<Instance> {
// We need the backing and import_backing to create a vm::Ctx, but we need
// a vm::Ctx to create a backing and an import_backing. The solution is to create an
// uninitialized vm::Ctx and then initialize it in-place.
@ -68,12 +63,7 @@ impl Instance {
// Initialize the vm::Ctx in-place after the backing
// has been boxed.
unsafe {
*inner.vmctx = vm::Ctx::new(
&mut inner.backing,
&mut inner.import_backing,
&module,
maybe_symbol_map,
)
*inner.vmctx = vm::Ctx::new(&mut inner.backing, &mut inner.import_backing, &module)
};
let instance = Instance {