aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-15 10:20:26 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-15 10:20:26 -0800
commit00876c9bd1f4363f897f59e0b5212128390bf1b4 (patch)
treed4b98c99f4d3a7257c698963fb4fd3bee52bdcfa /emscripten.py
parentb1a953ee8b3ec6d488802e29665b533bbe03759b (diff)
add Infinity and asm debug printers
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/emscripten.py b/emscripten.py
index 26fe0659..2662e40a 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -311,9 +311,9 @@ def emscript(infile, settings, outfile, libraries=[]):
maths += ['Math.imul']
asm_setup = '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in maths])
fundamentals = ['buffer', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array']
- basic_funcs = ['abort', 'assert'] + [m.replace('.', '_') for m in maths]
+ basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat'] + [m.replace('.', '_') for m in maths]
basic_vars = ['STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT']
- basic_float_vars = ['NaN']
+ basic_float_vars = ['NaN', 'Infinity']
if forwarded_json['Types']['preciseI64MathUsed']:
basic_funcs += ['i64Math_' + op for op in ['add', 'subtract', 'multiply', 'divide', 'modulo']]
asm_setup += '''
@@ -369,6 +369,12 @@ var i64Math_modulo = function(a, b, c, d, e) { i64Math.modulo(a, b, c, d, e) };
# finalize
funcs_js = '''
%s
+function asmPrintInt(x) {
+ Module.print('int ' + x);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x) {
+ Module.print('float ' + x);// + ' ' + new Error().stack);
+}
var asmPre = (function(env, buffer) {
'use asm';
var HEAP8 = new env.Int8Array(buffer);