diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-01 11:51:30 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-01 11:51:30 -0800 |
commit | 34b3a09aae11f04deb08c14954707f99b0d49b83 (patch) | |
tree | 1d2c170aa772acf2af099014c18bfe0e944fabd0 | |
parent | 904aba781d4cdd7074d2f8d4faa833207a31e83e (diff) | |
download | binaryen-34b3a09aae11f04deb08c14954707f99b0d49b83.tar.gz binaryen-34b3a09aae11f04deb08c14954707f99b0d49b83.tar.bz2 binaryen-34b3a09aae11f04deb08c14954707f99b0d49b83.zip |
enable imports in emcc builds
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/asm2wasm.h | 3 |
2 files changed, 3 insertions, 2 deletions
@@ -112,7 +112,7 @@ Same as Emscripten: MIT license. ## TODO * Waiting for switch to stablize on the spec repo; switches are Nop'ed. - * Waiting for an interpreter with module importing support; imports are Nop'ed. + * Reference interpreter lacks module importing support; imports are Nop'ed in native builds, but enabled in emcc builds (so wasm.js works). * WebAssembly lacks global variables, so `asm2wasm` maps them onto addresses in memory. This requires that you have some reserved space for those variables. You can do that with `emcc -s GLOBAL_BASE=1000`. We still need to write the code to copy the globals there. * Memory section needs the right size. diff --git a/src/asm2wasm.h b/src/asm2wasm.h index e2b853a07..c8dd3f9dd 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -787,13 +787,14 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { } Call* ret; if (wasm.imports.find(name) != wasm.imports.end()) { +#ifndef __EMSCRIPTEN__ // no imports yet in reference interpreter, fake it AsmType asmType = detectAsmType(astStackHelper.getParent(), &asmData); if (asmType == ASM_NONE) return allocator.alloc<Nop>(); if (asmType == ASM_INT) return allocator.alloc<Const>()->set(Literal((int32_t)0)); if (asmType == ASM_DOUBLE) return allocator.alloc<Const>()->set(Literal((double)0.0)); abort(); -#if 0 +#else ret = allocator.alloc<CallImport>(); noteImportedFunctionCall(ast, astStackHelper.getParent(), &asmData); #endif |