diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-09 20:34:37 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-09 20:34:37 -0700 |
commit | f58e77da332cb0f8123c0c062c275c63783736a7 (patch) | |
tree | 518251ccf13fd13e62604306f0e121034a79f82d /src | |
parent | 064206f86c62c546b1860cb14e4f303b6056b5bc (diff) |
make noInitialRun and INVOKE_RUN refer to main(), not run(). run() need not call main(), and is necessary to set things up even if you call main() manually
Diffstat (limited to 'src')
-rw-r--r-- | src/postamble.js | 8 | ||||
-rw-r--r-- | src/settings.js | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/postamble.js b/src/postamble.js index ea520eae..8dd01589 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -3,6 +3,7 @@ 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'); args = args || []; @@ -82,7 +83,7 @@ function run(args) { var ret = 0; calledRun = true; - if (Module['_main']) { + if (Module['_main'] && shouldRunNow) { ret = Module.callMain(args); if (!Module['noExitRuntime']) { exitRuntime(); @@ -121,6 +122,7 @@ if (Module['preInit']) { } } +// shouldRunNow refers to calling main(), not run(). #if INVOKE_RUN var shouldRunNow = true; #else @@ -130,9 +132,7 @@ if (Module['noInitialRun']) { shouldRunNow = false; } -if (shouldRunNow) { - run(); -} +run(); // {{POST_RUN_ADDITIONS}} diff --git a/src/settings.js b/src/settings.js index f9b47228..78a21616 100644 --- a/src/settings.js +++ b/src/settings.js @@ -35,8 +35,8 @@ var ASSERTIONS = 1; // Whether we should add runtime assertions, for example to // if code flow runs into a fault var VERBOSE = 0; // When set to 1, will generate more verbose output during compilation. -var INVOKE_RUN = 1; // Whether we will call run(). Disable if you embed the generated - // code in your own, and will call run() yourself at the right time +var INVOKE_RUN = 1; // Whether we will run the main() function. Disable if you embed the generated + // code in your own, and will call main() yourself at the right time. var INIT_HEAP = 0; // Whether to initialize memory anywhere other than the stack to 0. var TOTAL_STACK = 5*1024*1024; // The total stack size. There is no way to enlarge the stack, so this // value must be large enough for the program's requirements. If |