diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-20 15:55:09 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-20 15:55:09 -0800 |
commit | f54b8332c7fd00cc7b431b3aae2cd015e0cf333f (patch) | |
tree | ab9e4dd92601133f916790e5b00f325907ffeed4 | |
parent | 29200f6d693af396385013e89a7b048067302393 (diff) | |
download | binaryen-f54b8332c7fd00cc7b431b3aae2cd015e0cf333f.tar.gz binaryen-f54b8332c7fd00cc7b431b3aae2cd015e0cf333f.tar.bz2 binaryen-f54b8332c7fd00cc7b431b3aae2cd015e0cf333f.zip |
refactor wasm.js integration code into a method
-rw-r--r-- | src/js/post.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/js/post.js b/src/js/post.js index 4c616e463..c7d99147f 100644 --- a/src/js/post.js +++ b/src/js/post.js @@ -1,6 +1,6 @@ -(function() { - var wasmJS = WasmJS({}); // do not use the normal Module in the current scope +function integrateWasmJS(Module) { + var wasmJS = WasmJS({}); // XXX don't be confused. Module here is in the outside program. wasmJS is the inner wasm-js.cpp. wasmJS['outside'] = Module; // Inside wasm-js.cpp, Module['outside'] reaches the outside module. @@ -26,10 +26,10 @@ return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed }; - var temp = wasmJS._malloc(code.length + 1); - wasmJS.writeAsciiToMemory(code, temp); - wasmJS._load_asm(temp); - wasmJS._free(temp); + var temp = wasmJS['_malloc'](code.length + 1); + wasmJS['writeAsciiToMemory'](code, temp); + wasmJS['_load_asm'](temp); + wasmJS['_free'](temp); // Information for the instance of the module. var info = wasmJS['info'] = { @@ -74,5 +74,5 @@ wasmJS['_load_mapped_globals'](); // now that we have global and env, we can ready the provided imported globals, copying them to their mapped locations. return wasmJS['asmExports']; }; -})(); +} |