summaryrefslogtreecommitdiff
path: root/src/wasm-js.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-17 11:39:39 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-17 11:45:44 -0800
commiteab9bb324d4a88fe94b044bf773fa27c3e842b7a (patch)
tree9dadbf61707c7b987a40cb1185ae8653d12c04bc /src/wasm-js.cpp
parenta439812485b58cf555d02735668b53cfc5889ba4 (diff)
downloadbinaryen-eab9bb324d4a88fe94b044bf773fa27c3e842b7a.tar.gz
binaryen-eab9bb324d4a88fe94b044bf773fa27c3e842b7a.tar.bz2
binaryen-eab9bb324d4a88fe94b044bf773fa27c3e842b7a.zip
return undefined from wasm.js when return type is none
Diffstat (limited to 'src/wasm-js.cpp')
-rw-r--r--src/wasm-js.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 868c8e6ac..25cff2989 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -81,7 +81,8 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm(char *input) {
var name = Pointer_stringify($0);
Module['asmExports'][name] = function() {
Module['tempArguments'] = Array.prototype.slice.call(arguments);
- return Module['_call_from_js']($0);
+ Module['_call_from_js']($0);
+ return Module['tempReturn'];
};
}, curr->name.str);
}
@@ -215,7 +216,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_mapped_globals() {
}
// Does a call from js into an export of the module.
-extern "C" double EMSCRIPTEN_KEEPALIVE call_from_js(const char *target) {
+extern "C" void EMSCRIPTEN_KEEPALIVE call_from_js(const char *target) {
#ifdef WASM_JS_DEBUG
std::cout << "call_from_js " << target << '\n';
#endif
@@ -243,10 +244,10 @@ extern "C" double EMSCRIPTEN_KEEPALIVE call_from_js(const char *target) {
#ifdef WASM_JS_DEBUG
std::cout << "call_from_js returning " << ret << '\n';
#endif
- if (ret.type == none) return 0;
- if (ret.type == i32) return ret.i32;
- if (ret.type == f32) return ret.f32;
- if (ret.type == f64) return ret.f64;
- abort();
+ if (ret.type == none) EM_ASM({ Module['tempReturn'] = undefined });
+ else if (ret.type == i32) EM_ASM_({ Module['tempReturn'] = $0 }, ret.i32);
+ else if (ret.type == f32) EM_ASM_({ Module['tempReturn'] = $0 }, ret.f32);
+ else if (ret.type == f64) EM_ASM_({ Module['tempReturn'] = $0 }, ret.f64);
+ else abort();
}