diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 09:51:36 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 09:51:36 -0800 |
commit | 6782b5e97fcfb6a6da94b9ecc2fa57b76e943206 (patch) | |
tree | 42cc44c1b90a7af08b98de4d592029c8648a3db5 /src/parseTools.js | |
parent | 9d20f0799c3eb4136e2048274bf523cb9a81ed1e (diff) |
switch to all or nothing named globals, and add testing
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 786d55c8..5770a0d7 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -357,12 +357,18 @@ function hasVarArgs(params) { } function makeGlobalDef(ident) { - if (ident in Variables.indexedGlobals) return ''; + if (!NAMED_GLOBALS) return ''; return 'var ' + ident + ';'; // TODO: add option for namespacing or offsetting to allow reducing the number of globals } function makeGlobalUse(ident) { - if (ident in Variables.indexedGlobals) return getFastValue('GLOBAL_BASE', '+', Variables.indexedGlobals[ident]); + if (!NAMED_GLOBALS) { + if (!(ident in Variables.indexedGlobals)) { + Variables.indexedGlobals[ident] = Variables.nextIndexedOffset; + Variables.nextIndexedOffset += Runtime.alignMemory(calcAllocatedSize(Variables.globals[ident].type)); + } + return getFastValue('GLOBAL_BASE', '+', Variables.indexedGlobals[ident]); + } return ident; // TODO: add option for namespacing or offsetting to allow reducing the number of globals } |