summaryrefslogtreecommitdiff
path: root/src/wasm-js.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-03-24 15:45:31 -0700
committerGitHub <noreply@github.com>2017-03-24 15:45:31 -0700
commitf1c992f946438ba8785c418e769ee024606fdde0 (patch)
treea2c91c8e21fdddbc22e9455f2c180f446fa4bf70 /src/wasm-js.cpp
parent7b71bb6b0d3966ce42b631d433c772e24d6e68be (diff)
downloadbinaryen-f1c992f946438ba8785c418e769ee024606fdde0.tar.gz
binaryen-f1c992f946438ba8785c418e769ee024606fdde0.tar.bz2
binaryen-f1c992f946438ba8785c418e769ee024606fdde0.zip
New binaryen.js (#922)
New binaryen.js implementation, based on the C API underneath and with a JS-friendly API on top. See docs under docs/ for API details.
Diffstat (limited to 'src/wasm-js.cpp')
-rw-r--r--src/wasm-js.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 22f1f1a18..94404aeb9 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -80,7 +80,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) {
module->memory.max = pre.memoryGrowth ? Address(Memory::kMaxSize) : module->memory.initial;
if (wasmJSDebug) std::cerr << "wasming...\n";
- asm2wasm = new Asm2WasmBuilder(*module, pre, debug, false /* TODO: support imprecise? */, PassOptions(), false /* TODO: support optimizing? */, false /* TODO: support asm2wasm-i64? */);
+ asm2wasm = new Asm2WasmBuilder(*module, pre, debug, Asm2WasmBuilder::TrapMode::JS, PassOptions(), false /* TODO: support optimizing? */, false /* TODO: support asm2wasm-i64? */);
asm2wasm->processAsm(asmjs);
}
@@ -171,7 +171,10 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
if (wasmJSDebug) std::cerr << "creating instance...\n";
struct JSExternalInterface : ModuleInstance::ExternalInterface {
+ Module* module = nullptr;
+
void init(Module& wasm, ModuleInstance& instance) override {
+ module = &wasm;
// look for imported memory
{
bool found = false;
@@ -302,7 +305,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
if (wasmJSDebug) std::cout << "calling import returning " << ret << '\n';
- return getResultFromJS(ret, import->functionType->result);
+ return getResultFromJS(ret, module->getFunctionType(import->functionType)->result);
}
Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) override {