diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-10 19:08:28 -0400 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-10 19:08:28 -0400 |
commit | 894db65d7dd8d6bef9595b1e2e49f069b857c5b8 (patch) | |
tree | 96a18c11793279ac5e7bf143334ddb2a46142095 /src | |
parent | 1c9032b9b8b4c32dbeca31691447ad574a75f815 (diff) |
do not emit postSets for function indexing etc., bake them into the memory initializer
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 6 | ||||
-rw-r--r-- | src/parseTools.js | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 1219bbae..a126994b 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -234,8 +234,8 @@ function JSify(data, functionsOnly, givenFunctions) { function globalVariableHandler(item) { function needsPostSet(value) { if (typeof value !== 'string') return false; - return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW' - || value.substr(0, 6) === 'GLOBAL'; + // (' is ok, as it is something we can indexize later into a concrete int: ('{{ FI_ ... + return /^([(_][^']|CHECK_OVERFLOW|GLOBAL).*/.test(value); } item.intertype = 'GlobalVariableStub'; @@ -308,6 +308,8 @@ function JSify(data, functionsOnly, givenFunctions) { JS: makeSetValue(makeGlobalUse(item.ident), i, value, structTypes[i], false, true) + ';' // ignore=true, since e.g. rtti and statics cause lots of safe_heap errors }); constant[i] = '0'; + } else { + if (typeof value === 'string') constant[i] = deParenCarefully(value); } }); diff --git a/src/parseTools.js b/src/parseTools.js index 1f875584..0ea8bc8d 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -2574,6 +2574,11 @@ function deParen(text) { return text; } +function deParenCarefully(text) { + if (text[0] === '(' && text.indexOf('(', 1) < 0 && text[text.length-1] === ')') return text.substr(1, text.length-2); + return text; +} + function addVariable(ident, type, funcData) { funcData = funcData || Framework.currItem.funcData; assert(type); |