Simplified EmscriptenGlobals initialization

This commit is contained in:
Syrus
2019-01-28 14:31:03 -08:00
parent 23492a4c53
commit fe1846d180
3 changed files with 6 additions and 13 deletions

View File

@ -284,12 +284,10 @@ pub struct EmscriptenGlobals {
}
impl EmscriptenGlobals {
pub fn new(
table_min: u32,
table_max: Option<u32>,
memory_min: u32,
memory_max: Option<u32>,
) -> Self {
pub fn new(module: &Module) -> Self {
let (table_min, table_max) = get_emscripten_table_size(&module);
let (memory_min, memory_max) = get_emscripten_memory_size(&module);
// Memory initialization
let memory_type = Memory {
min: memory_min,

View File

@ -15,9 +15,7 @@ macro_rules! assert_emscripten_output {
// let module = compile(&wasm_bytes[..])
// .map_err(|err| format!("Can't create the WebAssembly module: {}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ??
let (table_min, table_max) = wasmer_emscripten::get_emscripten_table_size(&module);
let (memory_min, memory_max) = wasmer_emscripten::get_emscripten_memory_size(&module);
let mut emscripten_globals = EmscriptenGlobals::new(table_min, table_max, memory_min, memory_max);
let mut emscripten_globals = EmscriptenGlobals::new(&module);
let import_object = generate_emscripten_env(&mut emscripten_globals);
let mut instance = module.instantiate(import_object)

View File

@ -70,10 +70,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
.map_err(|e| format!("Can't compile module: {:?}", e))?;
let (_abi, import_object, em_globals) = if wasmer_emscripten::is_emscripten_module(&module) {
let (table_min, table_max) = wasmer_emscripten::get_emscripten_table_size(&module);
let (memory_min, memory_max) = wasmer_emscripten::get_emscripten_memory_size(&module);
let mut emscripten_globals =
wasmer_emscripten::EmscriptenGlobals::new(table_min, table_max, memory_min, memory_max);
let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module);
(
InstanceABI::Emscripten,
wasmer_emscripten::generate_emscripten_env(&mut emscripten_globals),