Get table imports working

This commit is contained in:
Lachlan Sneff
2019-01-29 10:16:39 -08:00
parent 98305c8731
commit 19242a413f
21 changed files with 859 additions and 595 deletions

View File

@ -1,13 +1,9 @@
use crate::{
global::Global,
instance::InstanceInner,
memory::Memory,
module::ExportIndex,
module::ModuleInner,
types::{FuncSig, TableDesc},
vm,
global::Global, instance::InstanceInner, memory::Memory, module::ExportIndex,
module::ModuleInner, table::Table, types::FuncSig, vm,
};
use hashbrown::hash_map;
use std::sync::Arc;
#[derive(Debug, Copy, Clone)]
pub enum Context {
@ -20,14 +16,10 @@ pub enum Export {
Function {
func: FuncPointer,
ctx: Context,
signature: FuncSig,
signature: Arc<FuncSig>,
},
Memory(Memory),
Table {
local: TablePointer,
ctx: Context,
desc: TableDesc,
},
Table(Table),
Global(Global),
}
@ -47,22 +39,6 @@ impl FuncPointer {
}
}
#[derive(Debug, Clone)]
pub struct TablePointer(*mut vm::LocalTable);
impl TablePointer {
/// This needs to be unsafe because there is
/// no way to check whether the passed function
/// is valid and has the right signature.
pub unsafe fn new(f: *mut vm::LocalTable) -> Self {
TablePointer(f)
}
pub(crate) fn inner(&self) -> *mut vm::LocalTable {
self.0
}
}
pub struct ExportIter<'a> {
inner: &'a mut InstanceInner,
iter: hash_map::Iter<'a, String, ExportIndex>,