diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-03 22:41:53 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-03 22:41:53 -0500 |
commit | 7b363c5b3a4f88b4bb82c9691e0f589ac94fd154 (patch) | |
tree | e82739a8a28b6a8409994cd0704018e2e1735f51 /emscripten.py | |
parent | 442caa6c9509da663b601e9a5053c98f3cf8da15 (diff) |
handle global initializers from fastcomp
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/emscripten.py b/emscripten.py index 8936aa3e..907e88ce 100755 --- a/emscripten.py +++ b/emscripten.py @@ -848,11 +848,13 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, #print >> sys.stderr, 'glue:', pre, '\n\n||||||||||||||||\n\n', post, '...............' - # memory initializer + # memory and global initializers + + global_initializers = ', '.join(map(lambda i: '{ func: function() { %s() } }' % i, metadata['initializers'])) pre = pre.replace('STATICTOP = STATIC_BASE + 0;', '''STATICTOP = STATIC_BASE + Runtime.alignMemory(%d); -/* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } }); -%s''' % (mem_init.count(',')+1, mem_init)) # XXX wrong size calculation! +/* global initializers */ __ATINIT__.push(%s); +%s''' % (mem_init.count(',')+1, global_initializers, mem_init)) # XXX wrong size calculation! funcs_js = [funcs] if settings.get('ASM_JS'): @@ -995,7 +997,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, basic_funcs.append('extCall_%s' % sig) # calculate exports - exported_implemented_functions = list(exported_implemented_functions) + exported_implemented_functions = list(exported_implemented_functions) + metadata['initializers'] exported_implemented_functions.append('runPostSets') exports = [] if not simple: |