diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-10-04 20:04:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-04 20:04:57 -0700 |
commit | 4e1667aa3454f56b3e96df674c504cb16366b628 (patch) | |
tree | a2240899abe69c5adb9ef5061ec71967979d3b24 /src | |
parent | c5b8f379fc3834bc5df10743b525570ffe1a5a73 (diff) | |
download | binaryen-4e1667aa3454f56b3e96df674c504cb16366b628.tar.gz binaryen-4e1667aa3454f56b3e96df674c504cb16366b628.tar.bz2 binaryen-4e1667aa3454f56b3e96df674c504cb16366b628.zip |
handle ifs with an i64 condition #741 (#742)
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index f00004b1f..d9618d8fd 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -539,6 +539,12 @@ private: return call; } + Expression* truncateToInt32(Expression* value) { + if (value->type == i64) return builder.makeUnary(UnaryOp::WrapInt64, value); + // either i32, or a call_import whose type we don't know yet (but would be legalized to i32 anyhow) + return value; + } + Function* processFunction(Ref ast); }; @@ -1432,7 +1438,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { } else if (what == IF) { auto* condition = process(ast[1]); auto* ifTrue = process(ast[2]); - return builder.makeIf(condition, ifTrue, !!ast[3] ? process(ast[3]) : nullptr); + return builder.makeIf(truncateToInt32(condition), ifTrue, !!ast[3] ? process(ast[3]) : nullptr); } else if (what == CALL) { if (ast[1][0] == NAME) { IString name = ast[1][1]->getIString(); |