diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-08 21:23:07 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-11 14:54:29 -0800 |
commit | 574bc2c9207f455518eab14bd1656cf9ba8b30c1 (patch) | |
tree | c1e6615e9b2d3bfb16e35db3eb8549130a8be4d1 /src/runtime.js | |
parent | ee70b710083e7659f1391b239eb6365e4120d2d3 (diff) |
initial work on legalizing i64s
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/runtime.js b/src/runtime.js index b5663045..803407c6 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -79,9 +79,10 @@ var RuntimeGenerator = { // Rounding is inevitable if the number is large. This is a particular problem for small negative numbers // (-1 will be rounded!), so handle negatives separately and carefully makeBigInt: function(low, high, unsigned) { - return '(' + unsigned + - ' ? (' + makeSignOp(low, 'i32', 'un', 1, 1) + '+(' + makeSignOp(high, 'i32', 'un', 1, 1) + '*4294967296))' + - ' : (' + makeSignOp(low, 'i32', 'un', 1, 1) + '+(' + makeSignOp(high, 'i32', 're', 1, 1) + '*4294967296)))'; + var unsignedRet = '(' + makeSignOp(low, 'i32', 'un', 1, 1) + '+(' + makeSignOp(high, 'i32', 'un', 1, 1) + '*4294967296))'; + var signedRet = '(' + makeSignOp(low, 'i32', 'un', 1, 1) + '+(' + makeSignOp(high, 'i32', 're', 1, 1) + '*4294967296))'; + if (typeof unsigned === 'string') return '(' + unsigned + ' ? ' + unsignedRet + ' : ' + signedRet + ')'; + return unsigned ? unsignedRet : signedRet; } }; |