diff options
-rw-r--r-- | src/parseTools.js | 5 | ||||
-rw-r--r-- | src/utility.js | 2 | ||||
-rw-r--r-- | tests/runner.py | 16 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 40f845a3..c8b4b918 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -359,6 +359,9 @@ function finalizeParam(param) { } else if (param.intertype === 'jsvalue') { return param.ident; } else { + if (param.type == 'i64' && I64_MODE == 1) { + return parseI64Constant(param.ident); + } return toNiceIdent(param.ident); } } @@ -526,7 +529,7 @@ function IEEEUnHex(stringy) { return (absolute * (neg ? -1 : 1)).toString(); } -// Makes a proper runtime value for a 64-bit value. Used in library. +// Makes a proper runtime value for a 64-bit value from low and high i32s. function makeI64(low, high) { if (I64_MODE == 1) { return '[' + low + ',' + (high || '0') + ']'; diff --git a/src/utility.js b/src/utility.js index 42c6ca69..5ae4480f 100644 --- a/src/utility.js +++ b/src/utility.js @@ -185,7 +185,7 @@ function mergeInto(obj, other) { } function isNumber(x) { - return x == parseFloat(x); // XXX add: || x.match(/^-?\d+(\.\d+)?/); + return x == parseFloat(x) || (typeof x == 'string' && x.match(/^-?\d+/)); } function isArray(x) { diff --git a/tests/runner.py b/tests/runner.py index 020417c6..ca38d000 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -393,23 +393,29 @@ if 'benchmark' not in str(sys.argv): # Stuff that only works in i64_mode = 1 Settings.I64_MODE = 1 - src = ''' + src = r''' #include <stdio.h> #include <stdint.h> - int64_t returner() { return 0x0000def123450789ULL; } + int64_t returner1() { return 0x0000def123450789ULL; } + int64_t returner2(int test) { + while (test > 10) test /= 2; // confuse the compiler so it doesn't eliminate this function + return test > 5 ? 0x0000def123450123ULL : 0ULL; + } int main() { int64_t x1 = 0x1234def123450789ULL; int64_t x2 = 0x1234def123450788ULL; int64_t x3 = 0x1234def123450789ULL; - printf("*%Ld\\n%d,%d,%d,%d,%d\\n%d,%d,%d,%d,%d*\\n", x1, x1==x2, x1<x2, x1<=x2, x1>x2, x1>=x2, // note: some rounding in the printing! - x1==x3, x1<x3, x1<=x3, x1>x3, x1>=x3); + printf("*%Ld\n%d,%d,%d,%d,%d\n%d,%d,%d,%d,%d*\n", x1, x1==x2, x1<x2, x1<=x2, x1>x2, x1>=x2, // note: some rounding in the printing! + x1==x3, x1<x3, x1<=x3, x1>x3, x1>=x3); + printf("*%Ld*\n", returner1()); + //printf("*%Ld*\n", returner2(30)); return 0; } ''' - self.do_run(src, '*1311918518731868200\n0,0,0,1,1\n1,0,1,0,1*\n') + self.do_run(src, '*1311918518731868200\n0,0,0,1,1\n1,0,1,0,1*\n*245127260211081*\n') def test_unsigned(self): |