Add new global import api

This commit is contained in:
Lachlan Sneff
2019-01-28 11:55:44 -08:00
parent 1be20b19e7
commit 98305c8731
16 changed files with 209 additions and 229 deletions

View File

@ -1,9 +1,10 @@
use crate::{
global::Global,
instance::InstanceInner,
memory::Memory,
module::ExportIndex,
module::ModuleInner,
types::{FuncSig, GlobalDesc, TableDesc},
types::{FuncSig, TableDesc},
vm,
};
use hashbrown::hash_map;
@ -27,10 +28,7 @@ pub enum Export {
ctx: Context,
desc: TableDesc,
},
Global {
local: GlobalPointer,
desc: GlobalDesc,
},
Global(Global),
}
#[derive(Debug, Clone)]
@ -65,22 +63,6 @@ impl TablePointer {
}
}
#[derive(Debug, Clone)]
pub struct GlobalPointer(*mut vm::LocalGlobal);
impl GlobalPointer {
/// 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::LocalGlobal) -> Self {
GlobalPointer(f)
}
pub(crate) fn inner(&self) -> *mut vm::LocalGlobal {
self.0
}
}
pub struct ExportIter<'a> {
inner: &'a mut InstanceInner,
iter: hash_map::Iter<'a, String, ExportIndex>,