aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-01 20:23:17 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-01 20:23:17 -0700
commit3c4fc418648c3c33dd419f20d7d7cac3238ff5be (patch)
tree326306e711a5c0dee920cc2e315fec82839482f4 /src
parent4401a0b0e47832a94ba54b787795678535273d19 (diff)
fix parsing of i64 constants in globals, and add working cube2hash testcase
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js20
-rw-r--r--src/parseTools.js6
2 files changed, 14 insertions, 12 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 8b9948be..dcc853f2 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -167,23 +167,27 @@ function JSify(data, functionsOnly, givenFunctions) {
ret[index++] = 0;
}
// Add current value(s)
- var currValue = flatten(values[i]);
+ var currValue = values[i];
if (USE_TYPED_ARRAYS == 2 && typeData.fields[i] == 'i64') {
// 'flatten' out the 64-bit value into two 32-bit halves
- ret[index++] = currValue>>>0;
+ var parts = parseI64Constant(currValue, true);
+ ret[index++] = parts[0];
ret[index++] = 0;
ret[index++] = 0;
ret[index++] = 0;
- ret[index++] = Math.floor(currValue/4294967296);
+ ret[index++] = parts[1];
ret[index++] = 0;
ret[index++] = 0;
ret[index++] = 0;
- } else if (typeof currValue == 'object') {
- for (var j = 0; j < currValue.length; j++) {
- ret[index++] = currValue[j];
- }
} else {
- ret[index++] = currValue;
+ currValue = flatten(currValue);
+ if (typeof currValue == 'object') {
+ for (var j = 0; j < currValue.length; j++) {
+ ret[index++] = currValue[j];
+ }
+ } else {
+ ret[index++] = currValue;
+ }
}
i += 1;
}
diff --git a/src/parseTools.js b/src/parseTools.js
index c8543963..5ec3b4ed 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -683,16 +683,14 @@ function parseArbitraryInt(str, bits) {
return ret;
}
-function parseI64Constant(str) {
- assert(USE_TYPED_ARRAYS == 2);
-
+function parseI64Constant(str, legalized) {
if (!isNumber(str)) {
// This is a variable. Copy it, so we do not modify the original
return legalizedI64s ? str : makeCopyI64(str);
}
var parsed = parseArbitraryInt(str, 64);
- if (legalizedI64s) return parsed;
+ if (legalizedI64s || legalized) return parsed;
return '[' + parsed[0] + ',' + parsed[1] + ']';
}