Add context and context_mut methods to Instance

This commit is contained in:
Lachlan Sneff
2019-01-23 15:58:15 -08:00
parent 147b214965
commit 0aa1687ca3

View File

@ -159,10 +159,29 @@ impl Instance {
self.call_with_index(func_index, args)
}
/// Returns a immutable reference to the
/// [`Ctx`] used by this Instance.
///
/// [`Ctx`]: struct.Ctx.html
pub fn context(&self) -> &vm::Ctx {
&self.inner.vmctx
}
/// Returns a mutable reference to the
/// [`Ctx`] used by this Instance.
///
/// [`Ctx`]: struct.Ctx.html
pub fn context_mut(&mut self) -> &mut vm::Ctx {
&mut self.inner.vmctx
}
/// Returns a iterator over all of the items
/// exported from this instance.
pub fn exports(&mut self) -> ExportIter {
ExportIter::new(&self.module, &mut self.inner)
}
/// The module used to instantiate this Instance.
pub fn module(&self) -> Module {
Module::new(Rc::clone(&self.module))
}