aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-07 17:02:17 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 17:02:17 -0800
commitb832e0985b0992973c749909fdeb91bcbb4e82a2 (patch)
treef702a20fafdfd002ffcb6f5e8ba6d38cdf0b2a8f /emscripten.py
parentbc35f5f6f56a8e8a1c0aa8319d517c69fb45da6a (diff)
warn instead of failing if a function table is used without functions of its signature existing
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py
index c0d342b4..66e2c721 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -405,9 +405,17 @@ Runtime.stackRestore = function(top) { asm.stackRestore(top) };
# Set function table masks
def function_table_maskize(js):
masks = {}
+ default = None
for sig, table in last_forwarded_json['Functions']['tables'].iteritems():
masks[sig] = str(table.count(','))
- return re.sub(r'{{{ FTM_([vdi]+) }}}', lambda m: masks[m.groups(0)[0]], js)
+ default = sig
+ def fix(m):
+ sig = m.groups(0)[0]
+ if not sig in masks:
+ print >> sys.stderr, 'warning: function table use without functions for it!', sig
+ return masks[default] # TODO: generate empty function tables for this case, even though it would fail at runtime if used
+ return masks[sig]
+ return re.sub(r'{{{ FTM_([\w\d_$]+) }}}', lambda m: fix(m), js) # masks[m.groups(0)[0]]
funcs_js = function_table_maskize(funcs_js)
else:
function_tables_defs = '\n'.join([table for table in last_forwarded_json['Functions']['tables'].itervalues()])