diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/asm_v_wasm.h | 11 | ||||
-rw-r--r-- | src/s2wasm.h | 13 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/asm_v_wasm.h b/src/asm_v_wasm.h index 829d79930..1bf689802 100644 --- a/src/asm_v_wasm.h +++ b/src/asm_v_wasm.h @@ -38,7 +38,6 @@ char getSig(WasmType type) { } std::string getSig(FunctionType *type) { - // generate signature std::string ret; ret += getSig(type->result); for (auto param : type->params) { @@ -48,7 +47,6 @@ std::string getSig(FunctionType *type) { } std::string getSig(Function *func) { - // generate signature std::string ret; ret += getSig(func->result); for (auto param : func->params) { @@ -57,6 +55,15 @@ std::string getSig(Function *func) { return ret; } +std::string getSig(CallBase *call) { + std::string ret; + ret += getSig(call->type); + for (auto operand : call->operands) { + ret += getSig(operand->type); + } + return ret; +} + } // namespace wasm #endif // _asm_v_wasm_h_ diff --git a/src/s2wasm.h b/src/s2wasm.h index 19fd426ac..1d42a08e6 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -5,6 +5,7 @@ #include "wasm.h" #include "parsing.h" +#include "asm_v_wasm.h" namespace wasm { @@ -362,7 +363,7 @@ private: if (match("_import")) { curr = allocator.alloc<CallImport>(); } else if (match("_indirect")) { - curr = allocator.alloc<CallImport>(); + curr = allocator.alloc<CallIndirect>(); } else { curr = allocator.alloc<Call>(); } @@ -384,6 +385,16 @@ private: } std::reverse(curr->operands.begin(), curr->operands.end()); setOutput(curr, assign); + if (curr->is<CallIndirect>()) { + auto call = curr->dyn_cast<CallIndirect>(); + auto type = allocator.alloc<FunctionType>(); + call->fullType = type; + type->name = cashew::IString((std::string("FUNCSIG_") + getSig(call)).c_str(), false); + // TODO type->result + for (auto operand : call->operands) { + type->params.push_back(operand->type); + } + } } else if (match("block")) { auto curr = allocator.alloc<Block>(); curr->name = getStr(); |