diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-19 13:21:03 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-19 13:25:46 -0700 |
commit | ea490e9c7f6f98b0df1de1e6259a86704d8d150d (patch) | |
tree | 696a62faf94dda343f0ed32f965412f6171e8716 | |
parent | 10cfa9fc93ab611fb8c94aed563513fe9c124644 (diff) |
refactor use of this[..] in shell.js to use Module[..]
-rw-r--r-- | src/compiler.js | 3 | ||||
-rw-r--r-- | src/library.js | 18 | ||||
-rw-r--r-- | src/library_sdl.js | 4 | ||||
-rw-r--r-- | src/postamble.js | 2 | ||||
-rw-r--r-- | src/preamble.js | 85 | ||||
-rw-r--r-- | src/shell.js | 86 | ||||
-rwxr-xr-x | tests/runner.py | 104 |
7 files changed, 128 insertions, 174 deletions
diff --git a/src/compiler.js b/src/compiler.js index 2e95552d..c39927e7 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -8,7 +8,8 @@ try { } catch(e) {} -// The environment setup code appears here, in shell.js, in js_optimizer.js and in tests/hello_world.js because it can't be shared. Keep them in sync! +// The environment setup code appears here, in js_optimizer.js and in tests/hello_world.js because it can't be shared. Keep them in sync! +// It also appears, in modified form, in shell.js. // *** Environment setup code *** var arguments_ = []; diff --git a/src/library.js b/src/library.js index 8f4e5799..f7ae62cb 100644 --- a/src/library.js +++ b/src/library.js @@ -256,12 +256,12 @@ LibraryManager.library = { if (typeof XMLHttpRequest !== 'undefined') { // Browser. assert('Cannot do synchronous binary XHRs in modern browsers. Use --embed-file or --preload-file in emcc'); - } else if (typeof read !== 'undefined') { + } else if (Module.read) { // Command-line. try { // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as // read() will try to parse UTF8. - obj.contents = intArrayFromString(read(obj.url), true); + obj.contents = intArrayFromString(Module.read(obj.url), true); } catch (e) { success = false; } @@ -331,13 +331,13 @@ LibraryManager.library = { stdoutOverridden = false; output = simpleOutput; } - if (!output.printer) output.printer = print; + if (!output.printer) output.printer = Module['print']; if (!output.buffer) output.buffer = []; if (!error) { stderrOverridden = false; error = simpleOutput; } - if (!error.printer) error.printer = print; + if (!error.printer) error.printer = Module['print']; if (!error.buffer) error.buffer = []; // Create the temporary folder. @@ -4405,7 +4405,7 @@ LibraryManager.library = { ___cxa_throw.initialized = true; } #if EXCEPTION_DEBUG - print('Compiled code throwing an exception, ' + [ptr,type,destructor] + ', at ' + new Error().stack); + Module.printErr('Compiled code throwing an exception, ' + [ptr,type,destructor] + ', at ' + new Error().stack); #endif {{{ makeSetValue('_llvm_eh_exception.buf', '0', 'ptr', 'void*') }}} {{{ makeSetValue('_llvm_eh_exception.buf', QUANTUM_SIZE, 'type', 'void*') }}} @@ -4959,7 +4959,7 @@ LibraryManager.library = { var lib_module = eval(lib_data)(FUNCTION_TABLE.length); } catch (e) { #if ASSERTIONS - print('Error in loading dynamic library: ' + e); + Module.printErr('Error in loading dynamic library: ' + e); #endif DLFCN_DATA.errorMsg = 'Could not evaluate dynamic lib: ' + filename; return 0; @@ -5996,12 +5996,12 @@ LibraryManager.library = { invalid: 0, dump: function() { if (Profiling.invalid) { - print('Invalid # of calls to Profiling begin and end!'); + Module.printErr('Invalid # of calls to Profiling begin and end!'); return; } - print('Profiling data:') + Module.printErr('Profiling data:') for (var i = 0; i < Profiling.max_; i++) { - print('Block ' + i + ': ' + Profiling.times[i]); + Module.printErr('Block ' + i + ': ' + Profiling.times[i]); } } }, diff --git a/src/library_sdl.js b/src/library_sdl.js index d1247f9e..4c125989 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -280,7 +280,7 @@ mergeInto(LibraryManager.library, { }, SDL_Quit: function() { - print('SDL_Quit called (and ignored)'); + Module.print('SDL_Quit called (and ignored)'); }, SDL_LockSurface: function(surf) { @@ -369,7 +369,7 @@ mergeInto(LibraryManager.library, { }, SDL_Delay: function(delay) { - print('SDL_Delay called! - potential infinite loop'); + Module.print('SDL_Delay called! - potential infinite loop'); }, SDL_WM_SetCaption: function(title, icon) { diff --git a/src/postamble.js b/src/postamble.js index 7371ff05..4a2fbf60 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -59,7 +59,7 @@ addRunDependency(); if (runDependencies == 0) { var ret = run(); #if CATCH_EXIT_CODE - print('Exit Status: ' + ret); + Module.print('Exit Status: ' + ret); #endif } diff --git a/src/preamble.js b/src/preamble.js index 1c599836..db092045 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -14,7 +14,7 @@ var HEAP_WATCHED = []; var HEAP_HISTORY = []; function SAFE_HEAP_CLEAR(dest) { #if SAFE_HEAP_LOG - print('SAFE_HEAP clear: ' + dest); + Module.print('SAFE_HEAP clear: ' + dest); #endif HEAP_HISTORY[dest] = []; } @@ -22,7 +22,7 @@ var SAFE_HEAP_ERRORS = 0; var ACCEPTABLE_SAFE_HEAP_ERRORS = 0; function SAFE_HEAP_ACCESS(dest, type, store, ignore) { - //if (dest === A_NUMBER) print ([dest, type, store] + ' ' + new Error().stack); // Something like this may be useful, in debugging + //if (dest === A_NUMBER) Module.print ([dest, type, store] + ' ' + new Error().stack); // Something like this may be useful, in debugging #if USE_TYPED_ARRAYS // When using typed arrays, reads over the top of TOTAL_MEMORY will fail silently, so we must @@ -59,12 +59,12 @@ function SAFE_HEAP_ACCESS(dest, type, store, ignore) { // assert((history && history[0]) /* || HEAP[dest] === 0 */, "Loading from where there was no store! " + dest + ',' + HEAP[dest] + ',' + type + ', \n\n' + new Error().stack + '\n'); // if (history[0].type !== type) { if (history !== type && !ignore) { - print('Load-store consistency assumption failure! ' + dest); - print('\n'); - print(JSON.stringify(history)); - print('\n'); - print('LOAD: ' + type + ', ' + new Error().stack); - print('\n'); + Module.print('Load-store consistency assumption failure! ' + dest); + Module.print('\n'); + Module.print(JSON.stringify(history)); + Module.print('\n'); + Module.print('LOAD: ' + type + ', ' + new Error().stack); + Module.print('\n'); SAFE_HEAP_ERRORS++; assert(SAFE_HEAP_ERRORS <= ACCEPTABLE_SAFE_HEAP_ERRORS, 'Load-store consistency assumption failure!'); } @@ -73,7 +73,7 @@ function SAFE_HEAP_ACCESS(dest, type, store, ignore) { function SAFE_HEAP_STORE(dest, value, type, ignore) { #if SAFE_HEAP_LOG - print('SAFE_HEAP store: ' + [dest, type, value, ignore]); + Module.print('SAFE_HEAP store: ' + [dest, type, value, ignore]); #endif if (!ignore && !value && value !== 0 && value !== false && !isNaN(value)) { // false can be the result of a mathop comparator; NaN can be the result of a math function @@ -81,7 +81,7 @@ function SAFE_HEAP_STORE(dest, value, type, ignore) { } SAFE_HEAP_ACCESS(dest, type, true, ignore); if (dest in HEAP_WATCHED) { - print((new Error()).stack); + Module.print((new Error()).stack); throw "Bad store!" + dest; } @@ -107,7 +107,7 @@ function SAFE_HEAP_LOAD(dest, type, unsigned, ignore) { SAFE_HEAP_ACCESS(dest, type, ignore); #if SAFE_HEAP_LOG - print('SAFE_HEAP load: ' + [dest, type, getValue(dest, type, 1), ignore]); + Module.print('SAFE_HEAP load: ' + [dest, type, getValue(dest, type, 1), ignore]); #endif #if USE_TYPED_ARRAYS == 2 @@ -132,7 +132,7 @@ function SAFE_HEAP_LOAD(dest, type, unsigned, ignore) { function SAFE_HEAP_COPY_HISTORY(dest, src) { #if SAFE_HEAP_LOG - print('SAFE_HEAP copy: ' + [dest, src]); + Module.print('SAFE_HEAP copy: ' + [dest, src]); #endif HEAP_HISTORY[dest] = HEAP_HISTORY[src]; SAFE_HEAP_ACCESS(dest, HEAP_HISTORY[dest] || null, true, false); @@ -160,7 +160,7 @@ var CorrectionsMonitor = { sig = (new Error().stack).toString().split('\n')[2].split(':').slice(-1)[0]; // Spidermonkey-specific FIXME sig = type + '|' + sig; if (!this.sigs[sig]) { - //print('Correction: ' + sig); + //Module.print('Correction: ' + sig); this.sigs[sig] = [0, 0]; // fail, succeed } this.sigs[sig][succeed ? 1 : 0]++; @@ -181,7 +181,7 @@ var CorrectionsMonitor = { items.sort(function(x, y) { return y.total - x.total; }); for (var i = 0; i < items.length; i++) { var item = items[i]; - print(item.sig + ' : ' + item.total + ' hits, %' + (Math.ceil(100*item.fails/item.total)) + ' failures'); + Module.print(item.sig + ' : ' + item.total + ' hits, %' + (Math.ceil(100*item.fails/item.total)) + ' failures'); } #endif } @@ -253,7 +253,7 @@ Module['stopProfiling'] = stopProfiling; function printProfiling() { function dumpData(name_, node, indent) { - print(indent + ('________' + node.time).substr(-8) + ': ' + name_ + ' (' + node.calls + ')'); + Module.print(indent + ('________' + node.time).substr(-8) + ': ' + name_ + ' (' + node.calls + ')'); var children = []; for (var child in node.children) { children.push(node.children[child]); @@ -265,57 +265,6 @@ function printProfiling() { dumpData('root', PROFILING_ROOT, ' '); } Module['printProfiling'] = printProfiling; - -function printXULProfiling() { - function dumpData(name_, node, indent) { - var children = []; - for (var child in node.children) { - children.push(node.children[child]); - children[children.length-1].name_ = child; - } - print('<treeitem' + (children.length > 0 ? ' container="true"' : '') + '>'); - print(' <treerow>'); - print(' <treecell label="' + name_ + '"/>'); - print(' <treecell label="' + node.time + '"/>'); - print(' <treecell label="' + node.calls + '"/>'); - print(' </treerow>'); - - if (children.length > 0) { - print(' <treechildren>'); - children.sort(function(x, y) { return y.time - x.time }); - children.forEach(function(child) { dumpData(child.name_, child, indent + ' ') }); - print(' </treechildren>'); - } - - print('</treeitem>'); - } - - print('<?xml version="1.0"?>'); - print('<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> '); - print('<?xml-stylesheet href="file://C:/main.css" type="text/css"?> '); - print('<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> '); - print('<tree id="myTree" flex="1" hidecolumnpicker="false" seltype="single" class="tree"'); - print(' rows="5">'); - print(' <treecols id="myTree2-treeCols">'); - print(' <treecol id="myTree2-treeCol0" primary="true" flex="2" label="Name"'); - print(' persist="width" ordinal="1"/>'); - print(' <splitter class="tree-splitter" ordinal="2"/>'); - print(' <treecol id="myTree2-treeCol1" flex="1" label="Milliseconds"'); - print(' persist="width" ordinal="3"/>'); - print(' <treecol id="myTree2-treeCol2" flex="1" label="Calls"'); - print(' persist="width" ordinal="4"/>'); - print(' </treecols>'); - print(' <treechildren>'); - - dumpData('root', PROFILING_ROOT, ' '); - - print(' </treechildren>'); - print('</tree>'); - print('</window>'); - - // This requires dom.allow_XUL_XBL_for_file -} -Module['printXULProfiling'] = printXULProfiling; #endif //======================================== @@ -335,7 +284,7 @@ var tempI64, tempI64b; #endif function abort(text) { - print(text + ':\n' + (new Error).stack); + Module.print(text + ':\n' + (new Error).stack); ABORT = true; throw "Assertion: " + text; } @@ -603,7 +552,7 @@ var STATICTOP; function enlargeMemory() { // TOTAL_MEMORY is the current size of the actual array, and STATICTOP is the new top. #if ASSERTIONS - printErr('Warning: Enlarging memory arrays, this is not fast! ' + [STATICTOP, TOTAL_MEMORY]); + Module.printErr('Warning: Enlarging memory arrays, this is not fast! ' + [STATICTOP, TOTAL_MEMORY]); assert(STATICTOP >= TOTAL_MEMORY); assert(TOTAL_MEMORY > 4); // So the loop below will not be infinite #endif diff --git a/src/shell.js b/src/shell.js index 1648218a..5b6419c0 100644 --- a/src/shell.js +++ b/src/shell.js @@ -1,9 +1,13 @@ // TODO: " u s e s t r i c t "; +try { + this['Module'] = Module; +} catch(e) { + this['Module'] = Module = {}; +} +// The environment setup code below is customized to use Module. // *** Environment setup code *** -var arguments_ = []; - var ENVIRONMENT_IS_NODE = typeof process === 'object'; var ENVIRONMENT_IS_WEB = typeof window === 'object'; var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function'; @@ -12,16 +16,16 @@ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIR if (ENVIRONMENT_IS_NODE) { // Expose functionality in the same simple way that the shells work // Note that we pollute the global namespace here, otherwise we break in node - print = function(x) { + Module['print'] = function(x) { process['stdout'].write(x + '\n'); }; - printErr = function(x) { + Module['printErr'] = function(x) { process['stderr'].write(x + '\n'); }; var nodeFS = require('fs'); - read = function(filename) { + Module['read'] = function(filename) { var ret = nodeFS['readFileSync'](filename).toString(); if (!ret && filename[0] != '/') { filename = __dirname.split('/').slice(0, -1).join('/') + '/src/' + filename; @@ -30,43 +34,56 @@ if (ENVIRONMENT_IS_NODE) { return ret; }; - load = function(f) { + Module['load'] = function(f) { globalEval(read(f)); }; - arguments_ = process['argv'].slice(2); + Module['arguments'] = process['argv'].slice(2); } else if (ENVIRONMENT_IS_SHELL) { + Module['print'] = print; + Module['printErr'] = printErr; + // Polyfill over SpiderMonkey/V8 differences - if (!this['read']) { - this['read'] = function(f) { snarf(f) }; + if (typeof read != 'undefined') { + Module['read'] = read; + } else { + Module['read'] = function(f) { snarf(f) }; } if (typeof scriptArgs != 'undefined') { - arguments_ = scriptArgs; + Module['arguments'] = scriptArgs; } else if (typeof arguments != 'undefined') { - arguments_ = arguments; + Module['arguments'] = arguments; } } else if (ENVIRONMENT_IS_WEB) { - this['print'] = printErr = function(x) { - console.log(x); - }; + if (!Module['print']) { + Module['print'] = function(x) { + console.log(x); + }; + } + + if (!Module['printErr']) { + Module['printErr'] = function(x) { + console.log(x); + }; + } - this['read'] = function(url) { + Module['read'] = function(url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); xhr.send(null); return xhr.responseText; }; - if (this['arguments']) { - arguments_ = arguments; + if (typeof arguments != 'undefined') { + Module['arguments'] = arguments; } } else if (ENVIRONMENT_IS_WORKER) { // We can do very little here... - this['load'] = importScripts; + Module['load'] = importScripts; } else { throw 'Unknown runtime environment. Where are we?'; @@ -75,34 +92,21 @@ if (ENVIRONMENT_IS_NODE) { function globalEval(x) { eval.call(null, x); } - -if (typeof load == 'undefined' && typeof read != 'undefined') { - this['load'] = function(f) { - globalEval(read(f)); +if (!Module['load'] == 'undefined' && Module['read']) { + Module['load'] = function(f) { + globalEval(Module['read'](f)); }; } - -if (typeof printErr === 'undefined') { - this['printErr'] = function(){}; -} - -if (typeof print === 'undefined') { - this['print'] = printErr; -} -// *** Environment setup code *** - - -try { - this['Module'] = Module; -} catch(e) { - this['Module'] = Module = {}; +if (!Module['printErr']) { + Module['printErr'] = function(){}; } -if (!Module.arguments) { - Module.arguments = arguments_; +if (!Module['print']) { + Module['print'] = Module['printErr']; } -if (Module.print) { - print = Module.print; +if (!Module['arguments']) { + Module['arguments'] = []; } +// *** Environment setup code *** {{BODY}} diff --git a/tests/runner.py b/tests/runner.py index 637a03d8..c3847743 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2187,7 +2187,7 @@ m_divisor is 1091269979 int main() { // EMSCRIPTEN_COMMENT("hello from the source"); - emscripten_run_script("print('hello world' + '!')"); + emscripten_run_script("Module.print('hello world' + '!')"); printf("*%d*\n", emscripten_run_script_int("5*20")); return 0; } @@ -3707,7 +3707,7 @@ def process(filename): var data = [10, 20, 40, 30]; var Module = { stdin: function() { return data.pop() || null }, - stdout: function(x) { print('got: ' + x) } + stdout: function(x) { Module.print('got: ' + x) } }; \'\'\' + open(filename, 'r').read() open(filename, 'w').write(src) @@ -4031,8 +4031,8 @@ def process(filename): ).replace( '// {{POST_RUN_ADDITIONS}}', \'\'\' - print('first changed: ' + (TEST_F1.timestamp == 1200000000000)); - print('second changed: ' + (TEST_F2.timestamp == 1200000000000)); + Module.print('first changed: ' + (TEST_F1.timestamp == 1200000000000)); + Module.print('second changed: ' + (TEST_F2.timestamp == 1200000000000)); \'\'\' ) open(filename, 'w').write(src) @@ -4786,7 +4786,7 @@ def process(filename): \'\'\' FS.createDataFile('/', 'paper.pdf', eval(read('paper.pdf.js')), true, false); run(); - print("Data: " + JSON.stringify(FS.root.contents['filename-1.ppm'].contents.map(function(x) { return unSign(x, 8) }))); + Module.print("Data: " + JSON.stringify(FS.root.contents['filename-1.ppm'].contents.map(function(x) { return unSign(x, 8) }))); \'\'\' ) src.close() @@ -4831,7 +4831,7 @@ def process(filename): )) ).replace( '// {{POST_RUN_ADDITIONS}}', - "print('Data: ' + JSON.stringify(FS.root.contents['image.raw'].contents));" + "Module.print('Data: ' + JSON.stringify(FS.root.contents['image.raw'].contents));" ) open(filename, 'w').write(src) ''' @@ -5089,24 +5089,24 @@ def process(filename): src = \'\'\' var Module = { 'postRun': function() { - print('*'); + Module.print('*'); var ret; - ret = ccall('get_int', 'number'); print([typeof ret, ret]); - ret = ccall('get_float', 'number'); print([typeof ret, ret.toFixed(2)]); - ret = ccall('get_string', 'string'); print([typeof ret, ret]); - ret = ccall('print_int', null, ['number'], [12]); print(typeof ret); - ret = ccall('print_float', null, ['number'], [14.56]); print(typeof ret); - ret = ccall('print_string', null, ['string'], ["cheez"]); print(typeof ret); - ret = ccall('multi', 'number', ['number', 'number', 'number', 'string'], [2, 1.4, 3, 'more']); print([typeof ret, ret]); + ret = ccall('get_int', 'number'); Module.print([typeof ret, ret]); + ret = ccall('get_float', 'number'); Module.print([typeof ret, ret.toFixed(2)]); + ret = ccall('get_string', 'string'); Module.print([typeof ret, ret]); + ret = ccall('print_int', null, ['number'], [12]); Module.print(typeof ret); + ret = ccall('print_float', null, ['number'], [14.56]); Module.print(typeof ret); + ret = ccall('print_string', null, ['string'], ["cheez"]); Module.print(typeof ret); + ret = ccall('multi', 'number', ['number', 'number', 'number', 'string'], [2, 1.4, 3, 'more']); Module.print([typeof ret, ret]); var p = ccall('malloc', 'pointer', ['number'], [4]); setValue(p, 650, 'i32'); - ret = ccall('pointer', 'pointer', ['pointer'], [p]); print([typeof ret, getValue(ret, 'i32')]); - print('*'); + ret = ccall('pointer', 'pointer', ['pointer'], [p]); Module.print([typeof ret, getValue(ret, 'i32')]); + Module.print('*'); // part 2: cwrap var multi = cwrap('multi', 'number', ['number', 'number', 'number', 'string']); - print(multi(2, 1.4, 3, 'atr')); - print(multi(8, 5.4, 4, 'bret')); - print('*'); + Module.print(multi(2, 1.4, 3, 'atr')); + Module.print(multi(8, 5.4, 4, 'bret')); + Module.print('*'); } }; \'\'\' + open(filename, 'r').read() @@ -5146,9 +5146,9 @@ def process(filename): script_src = ''' var sme = Module._.ScriptMe.__new__(83); // malloc(sizeof(ScriptMe)), ScriptMe::ScriptMe(sme, 83) / new ScriptMe(83) (at addr sme) Module._.ScriptMe.mulVal(sme, 2); // ScriptMe::mulVal(sme, 2) sme.mulVal(2) - print('*' + Module._.ScriptMe.getVal(sme) + '*'); + Module.print('*' + Module._.ScriptMe.getVal(sme) + '*'); _free(sme); - print('*ok*'); + Module.print('*ok*'); ''' post = ''' def process(filename): @@ -5232,55 +5232,55 @@ def process(filename): script_src_2 = \'\'\' var sme = new Module.Parent(42); sme.mulVal(2); - print('*') - print(sme.getVal()); + Module.print('*') + Module.print(sme.getVal()); - print('c1'); + Module.print('c1'); var c1 = new Module.Child1(); - print(c1.getVal()); + Module.print(c1.getVal()); c1.mulVal(2); - print(c1.getVal()); - print(c1.getValSqr()); - print(c1.getValSqr(3)); - print(c1.getValTimes()); // default argument should be 1 - print(c1.getValTimes(2)); + Module.print(c1.getVal()); + Module.print(c1.getValSqr()); + Module.print(c1.getValSqr(3)); + Module.print(c1.getValTimes()); // default argument should be 1 + Module.print(c1.getValTimes(2)); - print('c1 v2'); + Module.print('c1 v2'); c1 = new Module.Child1(8); // now with a parameter, we should handle the overloading automatically and properly and use constructor #2 - print(c1.getVal()); + Module.print(c1.getVal()); c1.mulVal(2); - print(c1.getVal()); - print(c1.getValSqr()); - print(c1.getValSqr(3)); + Module.print(c1.getVal()); + Module.print(c1.getValSqr()); + Module.print(c1.getValSqr(3)); - print('c2') + Module.print('c2') var c2 = new Module.Child2(); - print(c2.getVal()); + Module.print(c2.getVal()); c2.mulVal(2); - print(c2.getVal()); - print(c2.getValCube()); + Module.print(c2.getVal()); + Module.print(c2.getValCube()); var succeeded; try { succeeded = 0; - print(c2.doSomethingSecret()); // should fail since private + Module.print(c2.doSomethingSecret()); // should fail since private succeeded = 1; } catch(e) {} - print(succeeded); + Module.print(succeeded); try { succeeded = 0; - print(c2.getValSqr()); // function from the other class + Module.print(c2.getValSqr()); // function from the other class succeeded = 1; } catch(e) {} - print(succeeded); + Module.print(succeeded); try { succeeded = 0; c2.getValCube(); // sanity succeeded = 1; } catch(e) {} - print(succeeded); + Module.print(succeeded); Module.Child2.prototype.printStatic(); // static calls go through the prototype @@ -5294,12 +5294,12 @@ def process(filename): Module.customizeVTable(c3, [{ original: Module.Child2.prototype.virtualFunc, replacement: function() { - print('*js virtualf replacement*'); + Module.print('*js virtualf replacement*'); } }, { original: Module.Child2.prototype.virtualFunc2, replacement: function() { - print('*js virtualf2 replacement*'); + Module.print('*js virtualf2 replacement*'); } }]); c3.virtualFunc(); @@ -5310,7 +5310,7 @@ def process(filename): Module.Child2.prototype.runVirtualFunc(c2); c2.virtualFunc2(); - print('*ok*'); + Module.print('*ok*'); \'\'\' src = open(filename, 'a') src.write(script_src_2 + '\\n') @@ -5433,12 +5433,12 @@ def process(filename): '// {{POST_RUN_ADDITIONS}}', \'\'\' if (Runtime.typeInfo) { - print('|' + Runtime.typeInfo.UserStruct.fields + '|' + Runtime.typeInfo.UserStruct.flatIndexes + '|'); + Module.print('|' + Runtime.typeInfo.UserStruct.fields + '|' + Runtime.typeInfo.UserStruct.flatIndexes + '|'); var t = Runtime.generateStructInfo(['x', { us: ['x', 'y', 'z'] }, 'y'], 'Encloser') - print('|' + [t.x, t.us.x, t.us.y, t.us.z, t.y] + '|'); - print('|' + JSON.stringify(Runtime.generateStructInfo(['x', 'y', 'z'], 'UserStruct')) + '|'); + Module.print('|' + [t.x, t.us.x, t.us.y, t.us.z, t.y] + '|'); + Module.print('|' + JSON.stringify(Runtime.generateStructInfo(['x', 'y', 'z'], 'UserStruct')) + '|'); } else { - print('No type info.'); + Module.print('No type info.'); } \'\'\' ) @@ -6519,7 +6519,7 @@ f.close() if (typeof Module != 'undefined') throw 'This code should run before anything else!'; ''') open(os.path.join(self.get_dir(), 'after.js'), 'w').write(''' - print(MESSAGE); + Module.print(MESSAGE); ''') Popen([EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--pre-js', 'before.js', '--post-js', 'after.js']).communicate() |