aboutsummaryrefslogtreecommitdiff
path: root/src/shell.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/shell.js')
-rw-r--r--src/shell.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/shell.js b/src/shell.js
index be23b3c1..b41fbb51 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -38,17 +38,17 @@ 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
- Module['print'] = function(x) {
+ Module['print'] = function print(x) {
process['stdout'].write(x + '\n');
};
- Module['printErr'] = function(x) {
+ Module['printErr'] = function printErr(x) {
process['stderr'].write(x + '\n');
};
var nodeFS = require('fs');
var nodePath = require('path');
- Module['read'] = function(filename, binary) {
+ Module['read'] = function read(filename, binary) {
filename = nodePath['normalize'](filename);
var ret = nodeFS['readFileSync'](filename);
// The path is absolute if the normalized version is the same as the resolved.
@@ -60,9 +60,9 @@ if (ENVIRONMENT_IS_NODE) {
return ret;
};
- Module['readBinary'] = function(filename) { return Module['read'](filename, true) };
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
- Module['load'] = function(f) {
+ Module['load'] = function load(f) {
globalEval(read(f));
};
@@ -77,10 +77,10 @@ else if (ENVIRONMENT_IS_SHELL) {
if (typeof read != 'undefined') {
Module['read'] = read;
} else {
- Module['read'] = function() { throw 'no read() available (jsc?)' };
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
}
- Module['readBinary'] = function(f) {
+ Module['readBinary'] = function readBinary(f) {
return read(f, 'binary');
};
@@ -91,9 +91,11 @@ else if (ENVIRONMENT_IS_SHELL) {
}
this['{{{ EXPORT_NAME }}}'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
}
else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
- Module['read'] = function(url) {
+ Module['read'] = function read(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);
@@ -105,10 +107,10 @@ else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
}
if (typeof console !== 'undefined') {
- Module['print'] = function(x) {
+ Module['print'] = function print(x) {
console.log(x);
};
- Module['printErr'] = function(x) {
+ Module['printErr'] = function printErr(x) {
console.log(x);
};
} else {
@@ -136,7 +138,7 @@ function globalEval(x) {
eval.call(null, x);
}
if (!Module['load'] == 'undefined' && Module['read']) {
- Module['load'] = function(f) {
+ Module['load'] = function load(f) {
globalEval(Module['read'](f));
};
}