aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-15 09:48:20 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-15 09:48:20 -0800
commitb1a953ee8b3ec6d488802e29665b533bbe03759b (patch)
treea404a64f52e18c029c85452757661f95a52a8205 /src
parent581ef0e9afeace84c7ffb7605249973d1de0750e (diff)
ensure explicit floats in function call arguments and all coercions
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js8
-rw-r--r--src/parseTools.js16
2 files changed, 16 insertions, 8 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 83ddc62e..5fbea5ba 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1313,8 +1313,12 @@ function JSify(data, functionsOnly, givenFunctions) {
});
args = args.map(function(arg, i) { return indexizeFunctions(arg, argsTypes[i]) });
- if (ASM_JS && shortident in Functions.libraryFunctions) {
- args = args.map(function(arg, i) { return asmCoercion(arg, argsTypes[i]) });
+ if (ASM_JS) {
+ if (shortident in Functions.libraryFunctions) {
+ args = args.map(function(arg, i) { return asmCoercion(arg, argsTypes[i]) });
+ } else {
+ args = args.map(function(arg, i) { return asmEnsureFloat(arg, argsTypes[i]) });
+ }
}
varargs = varargs.map(function(vararg, i) {
diff --git a/src/parseTools.js b/src/parseTools.js
index 268d0e24..e0c99c52 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1019,14 +1019,18 @@ function asmCoercion(value, type, signedness) {
if (type == 'void') {
return value;
} else if (type in Runtime.FLOAT_TYPES) {
- if (signedness) {
- if (signedness == 'u') {
- value = '(' + value + ')>>>0';
- } else {
- value = '(' + value + ')|0';
+ if (isNumber(value)) {
+ return asmEnsureFloat(value, type);
+ } else {
+ if (signedness) {
+ if (signedness == 'u') {
+ value = '(' + value + ')>>>0';
+ } else {
+ value = '(' + value + ')|0';
+ }
}
+ return '(+(' + value + '))';
}
- return '(+(' + value + '))';
} else {
return '((' + value + ')|0)';
}