diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-30 13:13:24 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:21 -0800 |
commit | 5ff4af4293b9f9811d4e814cccd31b8a54c5c18b (patch) | |
tree | 2efc91d4bb99d468563f948dc4df308b55cedff5 | |
parent | ee32a53886e7a4788776e4199115626fb2ce95a7 (diff) |
use toSource on asm module to prevent access outside the module for testing purposes
-rwxr-xr-x | emscripten.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/emscripten.py b/emscripten.py index 99e60a50..df7895a1 100755 --- a/emscripten.py +++ b/emscripten.py @@ -311,7 +311,7 @@ def emscript(infile, settings, outfile, libraries=[]): receiving = ';\n'.join(['var ' + s + ' = Module["' + s + '"] = asm.' + s for s in exported_implemented_functions + function_tables]) # finalize funcs_js = ''' -var asm = (function(env, buffer) { +var asmPre = (function(env, buffer) { 'use asm'; var HEAP8 = new env.Int8Array(buffer); var HEAP16 = new env.Int16Array(buffer); @@ -326,7 +326,13 @@ var asm = (function(env, buffer) { %s return %s; -})(%s, buffer); +}); +if (asmPre.toSource) { // works in sm but not v8, so we get full coverage between those two + asmPre = asmPre.toSource(); + asmPre = asmPre.substr(25, asmPre.length-28); + asmPre = new Function('env', 'buffer', asmPre); +} +var asm = asmPre(%s, buffer); // pass through Function to prevent seeing outside scope %s; ''' % (function_tables_defs.replace('\n', '\n '), exports, sending, receiving) else: |