diff options
| author | JF Bastien <jfb@chromium.org> | 2016-01-13 10:48:44 -0800 |
|---|---|---|
| committer | JF Bastien <jfb@chromium.org> | 2016-01-13 10:48:44 -0800 |
| commit | 80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575 (patch) | |
| tree | d6dc07b081ed5c7e3a44bf1827c9b7d285d1a456 /src/asm_v_wasm.h | |
| parent | 2a0404579a2c061a965e2ac032801e250ab7f2bc (diff) | |
| parent | 3da40ef949ddfac78df2db33e6b35e14f54cb78c (diff) | |
| download | binaryen-80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575.tar.gz binaryen-80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575.tar.bz2 binaryen-80d0b8eb31b1bb15ecd2245ef6ad57ca4d3a2575.zip | |
Merge branch 'master' of github.com:WebAssembly/binaryen
Diffstat (limited to 'src/asm_v_wasm.h')
| -rw-r--r-- | src/asm_v_wasm.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/asm_v_wasm.h b/src/asm_v_wasm.h index f0065bbf9..394c7a321 100644 --- a/src/asm_v_wasm.h +++ b/src/asm_v_wasm.h @@ -17,6 +17,7 @@ #ifndef wasm_asm_v_wasm_h #define wasm_asm_v_wasm_h +#include "mixed_arena.h" #include "emscripten-optimizer/optimizer.h" namespace wasm { @@ -81,6 +82,15 @@ std::string getSig(CallBase *call) { return ret; } +std::string getSig(WasmType result, ExpressionList& operands) { + std::string ret; + ret += getSig(result); + for (auto operand : operands) { + ret += getSig(operand->type); + } + return ret; +} + WasmType sigToWasmType(char sig) { switch (sig) { case 'i': return i32; @@ -101,6 +111,22 @@ FunctionType sigToFunctionType(std::string sig) { return ret; } +FunctionType* ensureFunctionType(std::string sig, Module* wasm, MixedArena& allocator) { + cashew::IString name(("FUNCSIG$" + sig).c_str(), false); + if (wasm->functionTypesMap.find(name) != wasm->functionTypesMap.end()) { + return wasm->functionTypesMap[name]; + } + // add new type + auto type = allocator.alloc<FunctionType>(); + type->name = name; + type->result = sigToWasmType(sig[0]); + for (size_t i = 1; i < sig.size(); i++) { + type->params.push_back(sigToWasmType(sig[i])); + } + wasm->addFunctionType(type); + return type; +} + } // namespace wasm #endif // wasm_asm_v_wasm_h |
