aboutsummaryrefslogtreecommitdiff
path: root/src/postamble.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/postamble.js')
-rw-r--r--src/postamble.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 142ee013..448ee0fb 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -4,6 +4,23 @@
function run(args) {
__initializeRuntime__();
+ var globalFuncs = [];
+
+{{GLOBAL_VARS}}
+
+ var counter = Math.pow(globalFuncs.length,2)+1;
+ while (globalFuncs.length > 0 && counter >= 0) {
+ counter--;
+ var func = globalFuncs.pop();
+ try {
+ func();
+ } catch (e) {
+ globalFuncs.unshift(func);
+ // We will try again later. The global vars we depend on should be resolved by then
+ // XXX: We leak here, as we malloc, then fail and catch...
+ }
+ }
+
var argc = args.length+1;
function pad() {
for (var i = 0; i < QUANTUM_SIZE-1; i++) {