diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 11:12:15 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 11:12:15 -0800 |
commit | acf077c620074ee40727cfea7137e647454bd392 (patch) | |
tree | 4d031f6803d4ff5d47f57155762d9fa9908e9e8a | |
parent | d4d0f6d9fbfca9c70e183a49a195dc13c0d9236e (diff) |
external globals and not indexable
-rw-r--r-- | src/intertyper.js | 1 | ||||
-rw-r--r-- | src/parseTools.js | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 9dd47c72..35ad0e4c 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -512,6 +512,7 @@ function intertyper(data, sidePass, baseLineNums) { }; if (!NAMED_GLOBALS) { Variables.globals[ret.ident].type = ret.type; + Variables.globals[ret.ident].external = external; } Types.needAnalysis[ret.type] = 0; if (ident == '@llvm.global_ctors') { diff --git a/src/parseTools.js b/src/parseTools.js index 4c91a20c..350f36b7 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -356,13 +356,19 @@ function hasVarArgs(params) { return false; } +function isIndexableGlobal(ident) { + if (!(ident in Variables.globals)) return false; + var data = Variables.globals[ident]; + return !data.alias && !data.external; +} + function makeGlobalDef(ident) { - if (!NAMED_GLOBALS && ident in Variables.globals && !Variables.globals[ident].alias) return ''; + if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return ''; return 'var ' + ident + ';'; // TODO: add option for namespacing or offsetting to allow reducing the number of globals } function makeGlobalUse(ident) { - if (!NAMED_GLOBALS && ident in Variables.globals && !Variables.globals[ident].alias) { + if (!NAMED_GLOBALS && isIndexableGlobal(ident)) { if (!(ident in Variables.indexedGlobals)) { Variables.indexedGlobals[ident] = Variables.nextIndexedOffset; Variables.nextIndexedOffset += Runtime.alignMemory(calcAllocatedSize(Variables.globals[ident].type)); |