diff options
-rw-r--r-- | src/intertyper.js | 4 | ||||
-rw-r--r-- | src/jsifier.js | 14 | ||||
-rw-r--r-- | src/parseTools.js | 17 | ||||
-rw-r--r-- | src/preamble.js | 2 | ||||
-rw-r--r-- | src/preamble_sharedlib.js | 1 |
5 files changed, 16 insertions, 22 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 8e7bb418..1ad51b96 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -74,12 +74,10 @@ function intertyper(data, sidePass, baseLineNums) { var global = /([@%\w\d\.\" $-]+) = .*/.exec(line); var globalIdent = toNiceIdent(global[1]); var testAlias = /[@%\w\d\.\" $-]+ = alias .*/.exec(line); - var testString = /[@%\w\d\.\" $-]+ = [\w ]+ \[\d+ x i8] c".*/.exec(line); Variables.globals[globalIdent] = { name: globalIdent, alias: !!testAlias, - impl: VAR_EMULATED, - isString : !!testString + impl: VAR_EMULATED }; unparsedGlobals.lines.push(line); } else { diff --git a/src/jsifier.js b/src/jsifier.js index 595e057c..c361278a 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -250,7 +250,7 @@ function JSify(data, functionsOnly, givenFunctions) { processItem: function(item) { function needsPostSet(value) { return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW' - || value.substr(0, 13) === 'STRING_TABLE.'; + || false; // TODO: interact with output of makeGlobalUse/makeGlobalDef } item.intertype = 'GlobalVariableStub'; @@ -267,9 +267,7 @@ function JSify(data, functionsOnly, givenFunctions) { // they would shadow similarly-named globals in the parent. item.JS = ''; } else { - if (!(item.ident in Variables.globals) || !Variables.globals[item.ident].isString) { - item.JS = 'var ' + item.ident + ';'; - } + item.JS = makeGlobalDef(item.ident); } var constant = null; if (item.external) { @@ -320,13 +318,7 @@ function JSify(data, functionsOnly, givenFunctions) { var js; - // Strings are held in STRING_TABLE, to not clutter up the main namespace (in some cases we have - // many many strings, possibly exceeding the js engine limit on global vars). - if (Variables.globals[item.ident].isString) { - js = 'STRING_TABLE.' + item.ident + '=' + constant + ';'; - } else { - js = item.ident + '=' + constant + ';'; - } + js = makeGlobalUse(item.ident) + '=' + constant + ';'; // Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations if (item.ident.substr(0, 5) == '__ZTV') { diff --git a/src/parseTools.js b/src/parseTools.js index c70b511a..2591a94a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -356,6 +356,14 @@ function hasVarArgs(params) { return false; } +function makeGlobalDef(ident) { + return 'var ' + ident + ';'; // TODO: add option for namespacing or offsetting to allow reducing the number of globals +} + +function makeGlobalUse(ident) { + return ident; // TODO: add option for namespacing or offsetting to allow reducing the number of globals +} + function finalizeParam(param) { if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { return finalizeLLVMFunctionCall(param); @@ -368,10 +376,9 @@ function finalizeParam(param) { return parseI64Constant(param.ident); } var ret = toNiceIdent(param.ident); - if (ret in Variables.globals && Variables.globals[ret].isString) { - ret = "STRING_TABLE." + ret; + if (ret in Variables.globals) { + ret = makeGlobalUse(ret); } - return ret; } } @@ -1472,8 +1479,8 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { } } else if (param.intertype == 'value') { ret = param.ident; - if (ret in Variables.globals && Variables.globals[ret].isString) { - ret = "STRING_TABLE." + ret; + if (ret in Variables.globals) { + ret = makeGlobalUse(ret); } if (param.type == 'i64' && USE_TYPED_ARRAYS == 2) { ret = parseI64Constant(ret); diff --git a/src/preamble.js b/src/preamble.js index d2bbc6a4..14bf4d36 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -813,8 +813,6 @@ function writeArrayToMemory(array, buffer) { } Module['writeArrayToMemory'] = writeArrayToMemory; -var STRING_TABLE = []; - {{{ unSign }}} {{{ reSign }}} diff --git a/src/preamble_sharedlib.js b/src/preamble_sharedlib.js index af204e2f..2a071f6b 100644 --- a/src/preamble_sharedlib.js +++ b/src/preamble_sharedlib.js @@ -16,7 +16,6 @@ function callRuntimeCallbacks(callbacks) { } var __ATINIT__ = []; // functions called during startup -var STRING_TABLE = []; function initRuntime() { callRuntimeCallbacks(__ATINIT__); |