aboutsummaryrefslogtreecommitdiff
path: root/src/postamble.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/postamble.js')
-rw-r--r--src/postamble.js49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/postamble.js b/src/postamble.js
index cf863669..10ac1888 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -32,28 +32,47 @@ Module.callMain = function callMain(args) {
function run(args) {
args = args || Module['arguments'];
- if (Module['setStatus']) {
- Module['setStatus'](''); // clear the status from "Downloading.." etc.
- }
-
if (Module['preRun']) {
- Module['preRun']();
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length > 0) {
+ Module['preRun'].pop()();
+ if (runDependencies > 0) {
+ // preRun added a dependency, run will be called later
+ return 0;
+ }
+ }
}
- var ret = null;
- if (Module['_main']) {
- preMain();
- ret = Module.callMain(args);
- if (!Module['noExitRuntime']) {
- exitRuntime();
+ function doRun() {
+ var ret = 0;
+ if (Module['_main']) {
+ preMain();
+ ret = Module.callMain(args);
+ if (!Module['noExitRuntime']) {
+ exitRuntime();
+ }
}
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length > 0) {
+ Module['postRun'].pop()();
+ }
+ }
+ return ret;
}
- if (Module['postRun']) {
- Module['postRun']();
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ doRun();
+ }, 1);
+ return 0;
+ } else {
+ return doRun();
}
-
- return ret;
}
Module['run'] = run;