aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()])