Add importable memories and dynamic memories

This commit is contained in:
Lachlan Sneff
2019-01-25 15:28:54 -08:00
parent a20627964c
commit e4686e67c4
26 changed files with 992 additions and 694 deletions

View File

@ -1,8 +1,9 @@
use crate::{
instance::InstanceInner,
memory::Memory,
module::ExportIndex,
module::ModuleInner,
types::{FuncSig, GlobalDesc, Memory, Table},
types::{FuncSig, GlobalDesc, TableDesc},
vm,
};
use hashbrown::hash_map;
@ -20,19 +21,15 @@ pub enum Export {
ctx: Context,
signature: FuncSig,
},
Memory {
local: MemoryPointer,
ctx: Context,
memory: Memory,
},
Memory(Memory),
Table {
local: TablePointer,
ctx: Context,
table: Table,
desc: TableDesc,
},
Global {
local: GlobalPointer,
global: GlobalDesc,
desc: GlobalDesc,
},
}
@ -52,22 +49,6 @@ impl FuncPointer {
}
}
#[derive(Debug, Clone)]
pub struct MemoryPointer(*mut vm::LocalMemory);
impl MemoryPointer {
/// 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::LocalMemory) -> Self {
MemoryPointer(f)
}
pub(crate) fn inner(&self) -> *mut vm::LocalMemory {
self.0
}
}
#[derive(Debug, Clone)]
pub struct TablePointer(*mut vm::LocalTable);