diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-01 18:03:05 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 15:31:05 -0700 |
commit | 218696cdd2af0f6a96b7bb506c60c845ab36852f (patch) | |
tree | 2246dc3ba28fe3d6f3afb16efb0a4b068d3160c0 /emscripten.py | |
parent | cde6b80d99c6e4fd9eb0b67db929e51f93518b56 (diff) |
add a naming to globals that can be linked and used across modules
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/emscripten.py b/emscripten.py index 26e9f44f..7d9dd1a2 100755 --- a/emscripten.py +++ b/emscripten.py @@ -479,6 +479,14 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, ''.join([' var ' + g + '=env.' + math_fix(g) + ';\n' for g in basic_funcs + global_funcs]) asm_global_vars = ''.join([' var ' + g + '=env.' + g + '|0;\n' for g in basic_vars + global_vars]) + \ ''.join([' var ' + g + '=+env.' + g + ';\n' for g in basic_float_vars]) + # In linkable modules, we need to add some explicit globals for global variables that can be linked and used across modules + if settings.get('MAIN_MODULE') or settings.get('SIDE_MODULE'): + for key, value in forwarded_json['Variables']['globals'].iteritems(): + if value.get('linkable'): + init = str(forwarded_json['Variables']['indexedGlobals'][key]) + if settings.get('SIDE_MODULE'): init = '(H_BASE+' + init + ')|0' + asm_global_vars += ' var %s=%s;\n' % (key, init) + # sent data the_global = '{ ' + ', '.join(['"' + math_fix(s) + '": ' + s for s in fundamentals]) + ' }' sending = '{ ' + ', '.join(['"' + math_fix(s) + '": ' + s for s in basic_funcs + global_funcs + basic_vars + basic_float_vars + global_vars]) + ' }' |