diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-11-26 12:08:27 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-11-26 12:08:27 -0800 |
commit | 749092eb2942001f1fa2f8b6fcdcbce80f1e8e37 (patch) | |
tree | 84456630d78255e8f60dd1eaeca10c0b19ed2d95 /src/postamble.js | |
parent | 2c8e0810292289eb17055a4fe793c24d72033dfb (diff) |
flatten global constants at compile time
Diffstat (limited to 'src/postamble.js')
-rw-r--r-- | src/postamble.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/postamble.js b/src/postamble.js index b9ccb69b..72233980 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -8,19 +8,23 @@ function run(args) { {{GLOBAL_VARS}} - var counter = Math.pow(globalFuncs.length,2)+1; - while (globalFuncs.length > 0 && counter >= 0) { - counter--; + var failures = 0; + while (globalFuncs.length > 0) { var func = globalFuncs.pop(); try { var x = func(); if (x == undefined) throw 'undefined'; + failures = 0; } catch (e) { + failures++; + if (failures > 2*globalFuncs.length) { + throw 'Failed to generate global values'; + } globalFuncs.unshift(func); // We will try again later. The global vars we depend on should be resolved by then } } - assert(counter > 0); + assert(globalFuncs.length === 0); var argc = args.length+1; function pad() { |