Fix emscripten globals

This commit is contained in:
Steve Akinyemi
2019-01-11 21:17:28 +01:00
parent 927f6e4155
commit fdb0841783
2 changed files with 7 additions and 7 deletions

View File

@ -112,12 +112,12 @@ macro_rules! mock_external {
}};
}
struct EmscriptenGlobals {
pub struct EmscriptenGlobals {
pub data: Vec<(String, LocalGlobal, GlobalDesc)>,
}
impl EmscriptenGlobals {
fn new() -> Self {
pub fn new() -> Self {
let mut data = Vec::new();
data.push((
@ -156,13 +156,11 @@ impl EmscriptenGlobals {
}
}
pub fn generate_emscripten_env() -> Imports {
pub fn generate_emscripten_env(globals: &EmscriptenGlobals) -> Imports {
let mut imports = Imports::new();
let em_globals = EmscriptenGlobals::new();
// Add globals.
for (ref name, ref global, ref desc) in em_globals.data {
for (name, global, desc) in &globals.data {
let export = Export::Global {
local: unsafe { std::mem::transmute::<&LocalGlobal, *mut LocalGlobal>(global) },
global: desc.clone(),