diff options
-rwxr-xr-x | emscripten.py | 6 | ||||
-rw-r--r-- | src/modules.js | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/emscripten.py b/emscripten.py index 5b587a4b..137d95cb 100755 --- a/emscripten.py +++ b/emscripten.py @@ -315,8 +315,8 @@ def emscript(infile, settings, outfile, libraries=[]): Counter.i += 1 bad = 'b' + str(i) params = ','.join(['p%d' % p for p in range(len(sig)-1)]) - coercions = ';'.join(['p%d = %sp%d%s' % (p, '+' if sig[p+1] == 'f' else '', p, '' if sig[p+1] == 'f' else '|0') for p in range(len(sig)-1)]) + ';' - ret = '' if sig[0] == 'v' else ('return %s0' % ('+' if sig[0] == 'f' else '')) + coercions = ';'.join(['p%d = %sp%d%s' % (p, '+' if sig[p+1] != 'i' else '', p, '' if sig[p+1] != 'i' else '|0') for p in range(len(sig)-1)]) + ';' + ret = '' if sig[0] == 'v' else ('return %s0' % ('+' if sig[0] != 'i' else '')) return ('function %s(%s) { %s abort(%d); %s };' % (bad, params, coercions, i, ret), raw.replace('[0,', '[' + bad + ',').replace(',0,', ',' + bad + ',').replace(',0,', ',' + bad + ',').replace(',0]', ',' + bad + ']').replace(',0]', ',' + bad + ']')) infos = [make_table(sig, raw) for sig, raw in last_forwarded_json['Functions']['tables'].iteritems()] function_tables_defs = '\n'.join([info[0] for info in infos] + [info[1] for info in infos]) @@ -343,7 +343,7 @@ var i64Math_modulo = function(a, b, c, d, e) { i64Math.modulo(a, b, c, d, e) }; # function tables def asm_coerce(value, sig): if sig == 'v': return value - return ('+' if sig == 'f' else '') + value + ('|0' if sig == 'i' else '') + return ('+' if sig != 'i' else '') + value + ('|0' if sig == 'i' else '') function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']] function_tables_impls = [] diff --git a/src/modules.js b/src/modules.js index 435fb894..f33f302b 100644 --- a/src/modules.js +++ b/src/modules.js @@ -319,8 +319,8 @@ var Functions = { } for (var j = 1; j < t.length; j++) { args += (j > 1 ? ',' : '') + 'a' + j; - arg_coercions += 'a' + j + '=' + asmCoercion('a' + j, t[j] == 'f' ? 'float' : 'i32') + ';'; - call += (j > 1 ? ',' : '') + asmCoercion('a' + j, t[j] == 'f' ? 'float' : 'i32'); + arg_coercions += 'a' + j + '=' + asmCoercion('a' + j, t[j] != 'i' ? 'float' : 'i32') + ';'; + call += (j > 1 ? ',' : '') + asmCoercion('a' + j, t[j] != 'i' ? 'float' : 'i32'); } call += ')'; tables.pre += 'function ' + curr + '__wrapper(' + args + ') { ' + arg_coercions + ' ; ' + retPre + call + retPost + ' }\n'; |