diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-05 17:53:36 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-05 17:59:07 -0800 |
commit | 538e2d9813dd46e76aa226143b978f2b1acfb8e6 (patch) | |
tree | 17134f1b536ce597dbdeeb0ccb9fbd73a8b22f31 /src | |
parent | b2812d358ef291cee41f4670d2a0622876c5b113 (diff) | |
download | binaryen-538e2d9813dd46e76aa226143b978f2b1acfb8e6.tar.gz binaryen-538e2d9813dd46e76aa226143b978f2b1acfb8e6.tar.bz2 binaryen-538e2d9813dd46e76aa226143b978f2b1acfb8e6.zip |
call coercions in wasm2asm
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm2asm.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h index 8f4c54de3..f33065a5d 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -553,7 +553,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { return ret; } - Ref makeStatementizedCall(ExpressionList& operands, Ref ret, Ref theCall, IString result) { + Ref makeStatementizedCall(ExpressionList& operands, Ref ret, Ref theCall, IString result, WasmType type) { std::vector<ScopedTemp> temps; for (auto& operand : operands) { temps.emplace_back(operand->type, parent); @@ -561,6 +561,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { ret[1]->push_back(visitAndAssign(operand, temp)); theCall[2]->push_back(ValueBuilder::makeName(temp)); } + theCall = makeAsmCoercion(theCall, wasmToAsmType(type)); if (result != NO_RESULT) { theCall = ValueBuilder::makeStatement(ValueBuilder::makeAssign(ValueBuilder::makeName(result), theCall)); } @@ -575,10 +576,10 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { for (auto operand : curr->operands) { theCall[2]->push_back(visit(operand, EXPRESSION_RESULT)); } - return theCall; + return makeAsmCoercion(theCall, wasmToAsmType(curr->type)); } // we must statementize them all - return makeStatementizedCall(curr->operands, ValueBuilder::makeBlock(), theCall, result); + return makeStatementizedCall(curr->operands, ValueBuilder::makeBlock(), theCall, result, curr->type); } Ref visitCallImport(CallImport *curr) override { return visitCall(curr); @@ -590,14 +591,14 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { for (auto operand : curr->operands) { theCall[2]->push_back(visit(operand, EXPRESSION_RESULT)); } - return theCall; + return makeAsmCoercion(theCall, wasmToAsmType(curr->type)); } // we must statementize them all Ref ret = ValueBuilder::makeBlock(); ScopedTemp temp(i32, parent); ret[1]->push_back(visit(curr->target, temp)); Ref theCall = ValueBuilder::makeCall(ValueBuilder::makeSub(ValueBuilder::makeName(FUNCTION_TABLE), temp.getAstName())); - return makeStatementizedCall(curr->operands, ret, theCall, result); + return makeStatementizedCall(curr->operands, ret, theCall, result, curr->type); } Ref visitGetLocal(GetLocal *curr) override { return ValueBuilder::makeName(fromName(curr->name)); |