aboutsummaryrefslogtreecommitdiff
path: root/src/postamble.js
diff options
context:
space:
mode:
authorAnthony Pesch <inolen@gmail.com>2013-07-31 17:33:42 -0700
committerAnthony Pesch <inolen@gmail.com>2013-07-31 20:59:41 -0700
commitc1e78765a6380a38f6e69cb4cd808edc1d21a81b (patch)
tree820cf7affdc03b9bec563a884ea198ad52ae730a /src/postamble.js
parentb786b5ed8a1d709b67d7dc80e8ba41bbaf6e58ae (diff)
added addOnPreRun and addOnPostRun
Diffstat (limited to 'src/postamble.js')
-rw-r--r--src/postamble.js26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 8fe3b65d..25a50bfc 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -6,7 +6,7 @@ var inMain;
Module['callMain'] = Module.callMain = function callMain(args) {
assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
- assert(!Module['preRun'] || Module['preRun'].length == 0, 'cannot call main when preRun functions remain to be called');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
args = args || [];
@@ -74,17 +74,11 @@ function run(args) {
return;
}
- if (Module['preRun']) {
- if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
- var toRun = Module['preRun'];
- Module['preRun'] = [];
- for (var i = toRun.length-1; i >= 0; i--) {
- toRun[i]();
- }
- if (runDependencies > 0) {
- // a preRun added a dependency, run will be called later
- return;
- }
+ preRun();
+
+ if (runDependencies > 0) {
+ // a preRun added a dependency, run will be called later
+ return;
}
function doRun() {
@@ -96,12 +90,8 @@ function run(args) {
if (Module['_main'] && shouldRunNow) {
Module['callMain'](args);
}
- if (Module['postRun']) {
- if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
- while (Module['postRun'].length > 0) {
- Module['postRun'].pop()();
- }
- }
+
+ postRun();
}
if (Module['setStatus']) {