diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-25 13:15:44 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-25 13:23:16 -0700 |
commit | 3ff3a402d58a8c33151d6ce6767d34cb5bc9cc29 (patch) | |
tree | e1613fb290794925c2a6c5d0116321899cc309ef | |
parent | 6a6bb771d6d7786064331afab47943d65b0d4fd6 (diff) |
move to FROUND option for Math.fround
-rwxr-xr-x | emscripten.py | 2 | ||||
-rw-r--r-- | src/parseTools.js | 4 | ||||
-rw-r--r-- | src/preamble.js | 10 | ||||
-rw-r--r-- | src/settings.js | 2 | ||||
-rw-r--r-- | tests/test_core.py | 1 |
5 files changed, 9 insertions, 10 deletions
diff --git a/emscripten.py b/emscripten.py index dbea6eb2..8829a50f 100755 --- a/emscripten.py +++ b/emscripten.py @@ -451,7 +451,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, math_envs = ['Math.min'] # TODO: move min to maths asm_setup += '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs]) - if settings['TO_FLOAT32']: maths += ['Math.toFloat32'] + if settings['FROUND']: maths += ['Math.fround'] basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat'] + [m.replace('.', '_') for m in math_envs] if settings['RESERVED_FUNCTION_POINTERS'] > 0: basic_funcs.append('jsCall') diff --git a/src/parseTools.js b/src/parseTools.js index dae386f1..2272c851 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -2139,8 +2139,8 @@ function makeIsNaN(value) { } function makeFloat(value, type) { - if (TO_FLOAT32 && type == 'float') { - return 'Math_toFloat32(' + value + ')'; + if (FROUND && type == 'float') { + return 'Math_fround(' + value + ')'; } return value; } diff --git a/src/preamble.js b/src/preamble.js index ee273f6a..f00e59e0 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -1074,11 +1074,9 @@ Math['imul'] = function(a, b) { #endif Math.imul = Math['imul']; -#if TO_FLOAT32 -if (!Math['toFloat32']) Math['toFloat32'] = function(x) { - return x; -}; -Math.toFloat32 = Math['toFloat32']; +#if FROUND +if (!Math['fround']) Math['fround'] = function(x) { return x }; +Math.fround = Math['fround']; #endif var Math_abs = Math.abs; @@ -1096,7 +1094,7 @@ var Math_ceil = Math.ceil; var Math_floor = Math.floor; var Math_pow = Math.pow; var Math_imul = Math.imul; -var Math_toFloat32 = Math.toFloat32; +var Math_fround = Math.fround; var Math_min = Math.min; // A counter of dependencies for calling run(). If we need to diff --git a/src/settings.js b/src/settings.js index d2b47dc8..3ea513cb 100644 --- a/src/settings.js +++ b/src/settings.js @@ -115,7 +115,7 @@ var PRECISE_I64_MATH = 1; // If enabled, i64 addition etc. is emulated - which i var PRECISE_I32_MUL = 1; // If enabled, i32 multiplication is done with full precision, which means it is // correct even if the value exceeds the JS double-integer limit of ~52 bits (otherwise, // rounding will occur above that range). -var TO_FLOAT32 = 0; // Use Math.toFloat32 +var FROUND = 0; // Use Math.fround (polyfilling when necessary) var CLOSURE_ANNOTATIONS = 0; // If set, the generated code will be annotated for the closure // compiler. This potentially lets closure optimize the code better. diff --git a/tests/test_core.py b/tests/test_core.py index 74569c7f..88d1e34c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8307,6 +8307,7 @@ extern "C" { if Settings.ASM_JS: # test float support in asm + Settings.FROUND = 1 i, j = results[-1] src = open(path_from_root('tests', 'fasta.cpp'), 'r').read().replace('double', 'float') self.do_run(src, j, [str(i)], lambda x, err: x.replace('\n', '*')) |