diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-15 19:32:58 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-15 19:32:58 -0800 |
commit | c3ffdca9f60e262db5d317aea227a74162f13aa6 (patch) | |
tree | c92736b3c0b20b7578bd4c821e7956d077aada2f /emscripten.py | |
parent | af2f1481581ffae83bc32239f9218af0629453a6 (diff) |
when not running js opts in fastcomp, fix +f to f.0 in python
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py index 71844687..4f4b305f 100755 --- a/emscripten.py +++ b/emscripten.py @@ -726,7 +726,6 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, """ assert(settings['ASM_JS']) # TODO: apply ASM_JS even in -O0 for fastcomp - assert(settings['RUNNING_JS_OPTS']) # Overview: # * Run LLVM backend to emit JS. JS includes function bodies, memory initializer, @@ -814,6 +813,20 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, table_sizes[k] = str(v.count(',')) # undercounts by one, but that is what we want funcs = re.sub(r"#FM_(\w+)#", lambda m: table_sizes[m.groups(0)[0]], funcs) + # fix +float into float.0, if not running js opts + if not settings['RUNNING_JS_OPTS']: + def fix_dot_zero(m): + num = m.group(2) + # TODO: handle 0x floats? + if num.find('.') < 0: + e = num.find('e'); + if e < 0: + num += '.0' + else: + num = num[:e] + '.0' + num[e:] + return m.group(1) + num + funcs = re.sub(r'([=,] *)\+((0x)?[0-9a-f]*\.?[0-9]+([eE][-+]?[0-9]+)?)', lambda m: fix_dot_zero(m), funcs) + # js compiler if DEBUG: logging.debug('emscript: js compiler glue') |