summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-06 10:48:18 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-12-06 10:48:18 -0800
commit34e45ae6426706ae31c4df8e0b36a4d14ea1f682 (patch)
tree22e18dfd03532ede4fd4c245f1ad3596d70cd609 /src
parent1585a63c8846eef56b95f076be2ffe2f7e2f15da (diff)
downloadbinaryen-34e45ae6426706ae31c4df8e0b36a4d14ea1f682.tar.gz
binaryen-34e45ae6426706ae31c4df8e0b36a4d14ea1f682.tar.bz2
binaryen-34e45ae6426706ae31c4df8e0b36a4d14ea1f682.zip
fix if_else return value in wasm2asm
Diffstat (limited to 'src')
-rw-r--r--src/wasm2asm.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index a19416e04..46a9bc969 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -397,7 +397,7 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) {
Ref ret = visit(curr, result);
// if it's not already a statement, then it's an expression, and we need to assign it
// (if it is a statement, it already assigns to the result var)
- if (!isStatement(curr)) {
+ if (!isStatement(curr) && result != NO_RESULT) { // XXX also not EXPRESSION_RESULT?
ret = ValueBuilder::makeStatement(ValueBuilder::makeAssign(ValueBuilder::makeName(result), ret));
}
return ret;
@@ -496,10 +496,10 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) {
Ref visitIf(If *curr) override {
IString temp;
Ref condition = visitForExpression(curr->condition, i32, temp);
- Ref ifTrue = visit(curr->ifTrue, result);
+ Ref ifTrue = visitAndAssign(curr->ifTrue, result);
Ref ifFalse;
if (curr->ifFalse) {
- ifFalse = visit(curr->ifFalse, result);
+ ifFalse = visitAndAssign(curr->ifFalse, result);
}
if (temp.isNull()) {
return ValueBuilder::makeIf(condition, ifTrue, ifFalse); // simple if