aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-26 15:29:59 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-02-26 15:29:59 -0500
commitf3cc2377985a3a4b6de0ef36213f68df1db125e7 (patch)
tree3e04c9d7f6a1632dd9a880818385b767213242b6
parent108f6550f37ed10bef300c93f6158029471f7921 (diff)
add some newlines in very large function tables, to avoid emitting ridiculously long lines
-rwxr-xr-xemscripten.py2
-rw-r--r--src/modules.js9
2 files changed, 10 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py
index fd9c8ba2..b766cfb4 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -317,7 +317,7 @@ def emscript(infile, settings, outfile, libraries=[]):
params = ','.join(['p%d' % p for p in range(len(sig)-1)])
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 + ']'))
+ 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 + ']').replace(',0\n', ',' + bad + '\n'))
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])
diff --git a/src/modules.js b/src/modules.js
index 695abbe7..f3c14cd1 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -330,6 +330,15 @@ var Functions = {
}
}
}
+ if (table.length > 20) {
+ // add some newlines in the table, for readability
+ table = table.slice(0);
+ var j = 10;
+ while (j+10 < table.length) {
+ table[j] += '\n';
+ j += 10;
+ }
+ }
var indices = table.toString().replace('"', '');
if (BUILD_AS_SHARED_LIB) {
// Shared libraries reuse the parent's function table.