aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-03 19:20:20 -0500
committerAlon Zakai <alonzakai@gmail.com>2014-02-03 19:20:20 -0500
commit9ce41213fd7c3978952cf8beae785e7ce0e7064d (patch)
tree35abdeb23c3f7767db19f166a7d6a225d91a1f2e /emscripten.py
parent2d106105d1da2d733a75342b73a378357835f76f (diff)
fix wrapper coercions on floats in fastcomp
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py
index f908a339..b75df587 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -907,12 +907,15 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
else:
pre_tables = ''
+ def unfloat(s):
+ return 'd' if s == 'f' else s # lower float to double for ffis
+
def make_table(sig, raw):
i = Counter.i
Counter.i += 1
bad = 'b' + str(i)
params = ','.join(['p%d' % p for p in range(len(sig)-1)])
- coerced_params = ','.join([shared.JS.make_coercion('p%d', sig[p+1], settings) % p for p in range(len(sig)-1)])
+ coerced_params = ','.join([shared.JS.make_coercion('p%d', unfloat(sig[p+1]), settings) % p for p in range(len(sig)-1)])
coercions = ';'.join(['p%d = %s' % (p, shared.JS.make_coercion('p%d' % p, sig[p+1], settings)) for p in range(len(sig)-1)]) + ';'
def make_func(name, code):
return 'function %s(%s) { %s %s }' % (name, params, coercions, code)
@@ -936,6 +939,8 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
if not call_ident.startswith('_') and not call_ident.startswith('Math_'): call_ident = '_' + call_ident
code = call_ident + '(' + coerced_params + ')'
if sig[0] != 'v':
+ # ffis cannot return float
+ if sig[0] == 'f': code = '+' + code
code = 'return ' + shared.JS.make_coercion(code, sig[0], settings)
code += ';'
Counter.pre.append(make_func(item + '__wrapper', code))