diff options
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 99176fd2..dcc853f2 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -38,6 +38,7 @@ function JSify(data, functionsOnly, givenFunctions) { var preFile = BUILD_AS_SHARED_LIB ? 'preamble_sharedlib.js' : 'preamble.js'; var pre = processMacros(preprocess(read(preFile).replace('{{RUNTIME}}', getRuntime()))); print(pre); + if (PRECISE_I64_MATH) print(read('long.js')); Functions.implementedFunctions = set(data.unparsedFunctions.map(function(func) { return func.ident })); } @@ -166,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; } |