aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-09 15:48:15 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-09 15:48:15 -0800
commit5ffce90b0c70f24caaf9359a834b7787e0d9e0c9 (patch)
treeca830258e27f20bd2cdd215e5eafa724d8f09cda /src/parseTools.js
parent06c7bd01799e072514f6043491f1c20cac80ef4a (diff)
fix i64 bitshifts (fixes test_intvars in i64 mode) and two other minor corrections for toNiceIdent and detecting the number of bits in mathops
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 743b9793..a2f4458f 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -95,9 +95,9 @@ function toNiceIdentCarefully(ident) {
// is true, then also allow () and spaces.
function isNiceIdent(ident, loose) {
if (loose) {
- return /^\(?[\w$_]+[\w$_\d ]*\)?$/.test(ident);
+ return /^\(?[$_]+[\w$_\d ]*\)?$/.test(ident);
} else {
- return /^[\w$_]+[\w$_\d]*$/.test(ident);
+ return /^[$_]+[\w$_\d]*$/.test(ident);
}
}
@@ -1586,7 +1586,7 @@ function processMathop(item) {
if (item.type[0] === 'i') {
bits = parseInt(item.type.substr(1));
}
- var bitsLeft = ident2 ? ident2.substr(2, ident2.length-3) : null; // remove (i and ), to leave number. This value is important in float ops
+ var bitsLeft = item.param2 ? item.param2.ident.substr(1) : null; // remove i to leave number. This value is important in float ops
function integerizeBignum(value) {
return makeInlineCalculation('VALUE-VALUE%1', value, 'tempBigIntI');
@@ -1609,14 +1609,14 @@ function processMathop(item) {
}
case 'shl': {
return '[' + ident1 + '[0] << ' + ident2 + ', ' +
- '('+ident1 + '[1] << ' + ident2 + ') | ((' + ident1 + '[0]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >> (32-' + ident2 + '))]';
+ '('+ident1 + '[1] << ' + ident2 + ') | ((' + ident1 + '[0]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >>> (32-' + ident2 + '))]';
}
case 'ashr': {
- return '[('+ident1 + '[0] >> ' + ident2 + ') | ((' + ident1 + '[1]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >> (32-' + ident2 + ')),' +
- ident1 + '[1] >> ' + ident2 + ']';
+ return '[('+ident1 + '[0] >>> ' + ident2 + ') | ((' + ident1 + '[1]&(Math.pow(2, ' + ident2 + ')-1))<<(32-' + ident2 + ')),' +
+ ident1 + '[1] >>> ' + ident2 + ']';
}
case 'lshr': {
- return '[('+ident1 + '[0] >>> ' + ident2 + ') | ((' + ident1 + '[1]&((Math.pow(2, ' + ident2 + ')-1)<<(32-' + ident2 + '))) >> (32-' + ident2 + ')),' +
+ return '[('+ident1 + '[0] >>> ' + ident2 + ') | ((' + ident1 + '[1]&(Math.pow(2, ' + ident2 + ')-1))<<(32-' + ident2 + ')),' +
ident1 + '[1] >>> ' + ident2 + ']';
}
case 'uitofp': case 'sitofp': return ident1 + '[0] + ' + ident1 + '[1]*4294967296';