diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 14:43:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 15:31:05 -0700 |
commit | a4d526cf91f52882a59b11b9bc53fa533a06b33e (patch) | |
tree | 13487ec2417b80fc4a23dd9ec16aee90d645ce53 /emscripten.py | |
parent | 1804c48e607cbdd499799c840828085ccedf630e (diff) |
move runPostSets into asm module
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/emscripten.py b/emscripten.py index eeee26e4..df0587f9 100755 --- a/emscripten.py +++ b/emscripten.py @@ -341,8 +341,18 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, ret = re.sub(r'"?{{{ BA_([\w\d_$]+)\|([\w\d_$]+) }}}"?,0,0,0', lambda m: split_32(blockaddrs[m.groups(0)[0]][m.groups(0)[1]]), js) return re.sub(r'"?{{{ BA_([\w\d_$]+)\|([\w\d_$]+) }}}"?', lambda m: str(blockaddrs[m.groups(0)[0]][m.groups(0)[1]]), ret) + pre = blockaddrsize(indexize(pre)) + + if settings.get('ASM_JS'): + # move postsets into the asm module + class PostSets: js = '' + def handle_post_sets(m): + PostSets.js = m.group(0) + return '\n' + pre = re.sub(r'function runPostSets[^}]+}', handle_post_sets, pre) + #if DEBUG: outfile.write('// pre\n') - outfile.write(blockaddrsize(indexize(pre))) + outfile.write(pre) pre = None #if DEBUG: outfile.write('// funcs\n') @@ -458,6 +468,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, # calculate exports exported_implemented_functions = list(exported_implemented_functions) + exported_implemented_functions.append('runPostSets') exports = [] if not simple: for export in exported_implemented_functions + asm_runtime_funcs + function_tables: @@ -575,7 +586,7 @@ var asm = (function(global, env, buffer) { value = value|0; tempRet%d = value; } -''' % (i, i) for i in range(10)])] + funcs_js + [''' +''' % (i, i) for i in range(10)])] + [PostSets.js + '\n'] + funcs_js + [''' %s return %s; |