summaryrefslogtreecommitdiff
path: root/src/js/post.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-10-31 17:11:04 -0700
committerAlon Zakai <alonzakai@gmail.com>2015-10-31 17:13:51 -0700
commit3e618d9570b278ca9e94663240cf33d4f3cb22a9 (patch)
treedf52ab3eb814ab7274703680bfb1b09bc093ce41 /src/js/post.js
parent2635938b578aa55419bd2a59b837dfaeb546ddcc (diff)
downloadbinaryen-3e618d9570b278ca9e94663240cf33d4f3cb22a9.tar.gz
binaryen-3e618d9570b278ca9e94663240cf33d4f3cb22a9.tar.bz2
binaryen-3e618d9570b278ca9e94663240cf33d4f3cb22a9.zip
call from js into wasm
Diffstat (limited to 'src/js/post.js')
-rw-r--r--src/js/post.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/js/post.js b/src/js/post.js
index 2ee7b20b1..78fad1fc8 100644
--- a/src/js/post.js
+++ b/src/js/post.js
@@ -18,14 +18,14 @@
var temp = wasmJS._malloc(code.length + 1);
wasmJS.writeAsciiToMemory(code, temp);
- var instance = wasmJS._load_asm(temp);
+ wasmJS._load_asm(temp);
wasmJS._free(temp);
// Generate memory XXX TODO get the right size
var theBuffer = Module['buffer'] = new ArrayBuffer(16*1024*1024);
// Information for the instance of the module.
- var instance = wasmJS['instance'] = {
+ var info = wasmJS['info'] = {
global: null,
env: null,
parent: Module // Module inside wasm-js.cpp refers to wasm-js.cpp; this allows access to the outside program.
@@ -35,8 +35,9 @@
Module['asm'] = function(global, env, buffer) {
assert(buffer === theBuffer); // we should not even need to pass it as a 3rd arg for wasm, but that's the asm.js way.
// write the provided data to a location the wasm instance can get at it.
- instance.global = global;
- instance.env = env;
+ info.global = global;
+ info.env = env;
+ return wasmJS['asmExports'];
};
})();