summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-12 09:59:59 -0500
committerAlon Zakai <alonzakai@gmail.com>2015-12-12 09:59:59 -0500
commitfc4018f7f5f83f91c61276430f2e7da6ad0ccb22 (patch)
tree7de49db1036004542d9ac3afa729bf159ef79e11
parent7bdcdb2f5ee6e2346f946637dc6ba766256badea (diff)
downloadbinaryen-fc4018f7f5f83f91c61276430f2e7da6ad0ccb22.tar.gz
binaryen-fc4018f7f5f83f91c61276430f2e7da6ad0ccb22.tar.bz2
binaryen-fc4018f7f5f83f91c61276430f2e7da6ad0ccb22.zip
add function types in s2wasm
-rw-r--r--src/s2wasm.h18
-rw-r--r--test/dot_s/call.wast1
2 files changed, 13 insertions, 6 deletions
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<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);
+ auto typeName = cashew::IString((std::string("FUNCSIG_") + getSig(call)).c_str(), false);
+ if (wasm.functionTypesMap.count(typeName) == 0) {
+ auto type = allocator.alloc<FunctionType>();
+ 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")) {
diff --git a/test/dot_s/call.wast b/test/dot_s/call.wast
index 7c7e47a25..27262b4f0 100644
--- a/test/dot_s/call.wast
+++ b/test/dot_s/call.wast
@@ -1,5 +1,6 @@
(module
(memory 0 4294967295)
+ (type $FUNCSIG_v (func))
(func $call_i32_nullary (result i32)
(block $fake_return_waka123
(block