test/mjsunit/wasm/memory-external-call.js
// functions and/or an additional imported function.
functions and/or an additional imported function.
functions and / or an additional imported function .
function generateBuilder(add_memory, import_sig) {
  let builder = new WasmModuleBuilder();
  if (import_sig) {
    let idx = builder.addImport('import_module', 'other_module_fn', import_sig);
    assertEquals(idx, other_fn_idx)
  }
  if (add_memory) {
    builder.addMemory(initialMemoryPages, maximumMemoryPages, true);
    builder.addFunction('load', kSig_i_i)
        .addBody([kExprLocalGet, 0, kExprI32LoadMem, 0, 0])
        .exportFunc();
    builder.addFunction('store', kSig_i_ii)
        .addBody([
          kExprLocalGet, 0, kExprLocalGet, 1, kExprI32StoreMem, 0, 0,
          kExprLocalGet, 1
        ])
        .exportFunc();
  }
  return builder;
}
function generateBuilder ( add_memory , import_sig ) { let builder = new WasmModuleBuilder ( ) ; if ( import_sig ) { let idx = builder . addImport ( 'import_module' , 'other_module_fn' , import_sig ) ; assertEquals ( idx , other_fn_idx ) } if ( add_memory ) { builder . addMemory ( initialMemoryPages , maximumMemoryPages , true ) ; builder . addFunction ( 'load' , kSig_i_i ) . addBody ( [ kExprLocalGet , 0 , kExprI32LoadMem , 0 , 0 ] ) . exportFunc ( ) ; builder . addFunction ( 'store' , kSig_i_ii ) . addBody ( [ kExprLocalGet , 0 , kExprLocalGet , 1 , kExprI32StoreMem , 0 , 0 , kExprLocalGet , 1 ] ) . exportFunc ( ) ; } return builder ; }
functions and/or an additional imported function.
functions and / or an additional imported function .
// Add the import if we expect a module builder with imported functions. // The imported function should always have index 0. With this assertion we // verify that we can use other_fn_idx to refer to this function. // Add the memory if we expect a module builder with memory and load/store.