diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 17:26:25 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 17:26:25 -0800 |
commit | f5d9728cff02741a8e4dddc4e1da54602e88b718 (patch) | |
tree | dc77825f65df2b4b186b8754ae5e68680f86e055 /src/parseTools.js | |
parent | 52cc5c714d852d39a8bfd652f331b4f9b76b2f36 (diff) |
fix global indexing bugs
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 78ff934e..5d0131dc 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -368,10 +368,19 @@ function makeGlobalDef(ident) { } function makeGlobalUse(ident) { - if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return getFastValue('GLOBAL_BASE', '+', Variables.indexedGlobals[ident]); + if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return '(' + getFastValue('GLOBAL_BASE', '+', Variables.indexedGlobals[ident]) + ')'; return ident; // TODO: add option for namespacing or offsetting to allow reducing the number of globals } +function sortGlobals(globals) { + var ks = keys(globals); + ks.sort(); + var inv = invertArray(ks); + return values(globals).sort(function(a, b) { + return inv[b.ident] - inv[a.ident]; + }); +} + function finalizeParam(param) { if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { return finalizeLLVMFunctionCall(param); |