Expose globals to host (#158)
* Make `global_by_index` pub, add `globals` getter * simplify access to globals
This commit is contained in:
parent
073e4e7f1f
commit
ad14d82bce
|
@ -11,6 +11,7 @@ use hashmap_core::HashMap;
|
|||
use std::collections::HashMap;
|
||||
|
||||
use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
|
||||
use core::cell::Ref;
|
||||
use func::{FuncBody, FuncInstance, FuncRef};
|
||||
use global::{GlobalInstance, GlobalRef};
|
||||
use host::Externals;
|
||||
|
@ -215,6 +216,12 @@ impl ModuleInstance {
|
|||
self.globals.borrow_mut().push(global)
|
||||
}
|
||||
|
||||
/// Access all globals. This is a non-standard API so it's unlikely to be
|
||||
/// portable to other engines.
|
||||
pub fn globals<'a>(&self) -> Ref<Vec<GlobalRef>> {
|
||||
self.globals.borrow()
|
||||
}
|
||||
|
||||
fn insert_export<N: Into<String>>(&self, name: N, extern_val: ExternVal) {
|
||||
self.exports.borrow_mut().insert(name.into(), extern_val);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue