Update spectests to work with new Instance; use Arc<Mutex<>>

This commit is contained in:
Mark McCaskey
2019-09-23 13:43:01 -07:00
parent 1e637badc4
commit c4818f12dc
2 changed files with 121 additions and 130 deletions

View File

@ -16,7 +16,12 @@ use crate::{
vm::{self, InternalField},
};
use smallvec::{smallvec, SmallVec};
use std::{mem, pin::Pin, ptr::NonNull, sync::Arc};
use std::{
mem,
pin::Pin,
ptr::NonNull,
sync::{Arc, Mutex},
};
pub(crate) struct InstanceInner {
#[allow(dead_code)]
@ -520,6 +525,27 @@ impl LikeNamespace for Rc<Instance> {
}
}
impl LikeNamespace for Arc<Mutex<Instance>> {
fn get_export(&self, name: &str) -> Option<Export> {
let instance = self.lock().unwrap();
let export_index = instance.module.info.exports.get(name)?;
Some(
instance
.inner
.get_export_from_index(&instance.module, export_index),
)
}
fn get_exports(&self) -> Vec<(String, Export)> {
unimplemented!("Use the exports method instead");
}
fn maybe_insert(&mut self, _name: &str, _export: Export) -> Option<()> {
None
}
}
#[must_use]
fn call_func_with_index(
info: &ModuleInfo,