diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-07 14:42:18 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-07 14:42:18 -0800 |
commit | 75e8b709fe900efcfb53813f884a1cde6e81907b (patch) | |
tree | ab2f1f164b65c4f10196656ec00e78ae8fb606c6 /src/wasm2asm.h | |
parent | 0fb0a68db70f2720d93a182129e73e4a0eaeb3cb (diff) | |
download | binaryen-75e8b709fe900efcfb53813f884a1cde6e81907b.tar.gz binaryen-75e8b709fe900efcfb53813f884a1cde6e81907b.tar.bz2 binaryen-75e8b709fe900efcfb53813f884a1cde6e81907b.zip |
handle imports in wasm2asm
Diffstat (limited to 'src/wasm2asm.h')
-rw-r--r-- | src/wasm2asm.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h index e57a0cff8..836fc450c 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -163,6 +163,7 @@ private: size_t tableSize; void addBasics(Ref ast); + void addImport(Ref ast, Import *import); }; Ref Wasm2AsmBuilder::processWasm(Module* wasm) { @@ -175,6 +176,9 @@ Ref Wasm2AsmBuilder::processWasm(Module* wasm) { asmFunc[3]->push_back(ValueBuilder::makeStatement(ValueBuilder::makeString(USE_ASM))); // create heaps, etc addBasics(asmFunc[3]); + for (auto import : wasm->imports) { + addImport(asmFunc[3], import); + } // figure out the table size tableSize = wasm->table.names.size(); size_t pow2ed = 1; @@ -237,6 +241,18 @@ void Wasm2AsmBuilder::addBasics(Ref ast) { addMath(MATH_IMUL, IMUL); } +void Wasm2AsmBuilder::addImport(Ref ast, Import *import) { + Ref theVar = ValueBuilder::makeVar(); + ast->push_back(theVar); + ValueBuilder::appendToVar(theVar, + fromName(import->name), + ValueBuilder::makeDot( + ValueBuilder::makeName(fromName(import->module)), + fromName(import->base) + ) + ); +} + Ref Wasm2AsmBuilder::processFunction(Function* func) { Ref ret = ValueBuilder::makeFunction(fromName(func->name)); frees.clear(); |