summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-18 10:46:50 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-18 10:46:50 -0800
commit47add7947265b99c6c68add694e6ae70911f4f4e (patch)
tree6d5c388b5f5a22efa1460969c7c79a8bc481ab66 /src
parentf948a0e9f1c75f3275b219100a901adb3f96083f (diff)
downloadbinaryen-47add7947265b99c6c68add694e6ae70911f4f4e.tar.gz
binaryen-47add7947265b99c6c68add694e6ae70911f4f4e.tar.bz2
binaryen-47add7947265b99c6c68add694e6ae70911f4f4e.zip
fix call types based on coercions, but do not modify other things automatically
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 5865fd901..35b75a50c 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -359,6 +359,12 @@ private:
return ret;
}
+ void fixCallType(Expression* call, WasmType type) {
+ if (call->is<Call>()) call->type = type;
+ if (call->is<CallImport>()) call->type = type;
+ else if (call->is<CallIndirect>()) call->type = type;
+ }
+
Function* processFunction(Ref ast);
};
@@ -672,7 +678,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
} else if (what == BINARY) {
if (ast[1] == OR && ast[3][0] == NUM && ast[3][1]->getNumber() == 0) {
auto ret = process(ast[2]); // just look through the ()|0 coercion
- ret->type = WasmType::i32; // we add it here for e.g. call coercions
+ fixCallType(ret, i32);
return ret;
}
BinaryOp binary;
@@ -791,7 +797,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
}
assert(childType == ASM_NONE || childType == ASM_DOUBLE); // e.g. a coercion on a call or for a return
auto ret = process(ast[2]); // just look through the +() coercion
- ret->type = WasmType::f64; // we add it here for e.g. call coercions
+ fixCallType(ret, f64);
return ret;
} else if (ast[1] == MINUS) {
if (ast[2][0] == NUM || (ast[2][0] == UNARY_PREFIX && ast[2][1] == PLUS && ast[2][2][0] == NUM)) {