From fc4018f7f5f83f91c61276430f2e7da6ad0ccb22 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 12 Dec 2015 09:59:59 -0500 Subject: add function types in s2wasm --- src/s2wasm.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/s2wasm.h b/src/s2wasm.h index 07dc2803b..996c116ab 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -402,12 +402,18 @@ private: setOutput(curr, assign); if (curr->is()) { auto call = curr->dyn_cast(); - auto type = allocator.alloc(); - 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); + auto typeName = cashew::IString((std::string("FUNCSIG_") + getSig(call)).c_str(), false); + if (wasm.functionTypesMap.count(typeName) == 0) { + auto type = allocator.alloc(); + type->name = typeName; + // TODO type->result + for (auto operand : call->operands) { + type->params.push_back(operand->type); + } + wasm.addFunctionType(type); + call->fullType = type; + } else { + call->fullType = wasm.functionTypesMap[typeName]; } } } else if (match("block")) { -- cgit v1.2.3