diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-25 10:21:27 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-25 10:21:27 -0800 |
commit | 72c0fb8cdb7d430039a67308e798212def8c2b08 (patch) | |
tree | 970b68e46e1b5a10776c571dd35961ec2e1d52bc | |
parent | 0bdac9f178cb4aefdd7b11eee93110324c76f9a2 (diff) |
fix some spacing stuff
-rw-r--r-- | src/intertyper.js | 2 | ||||
-rw-r--r-- | src/jsifier.js | 9 | ||||
-rw-r--r-- | src/parseTools.js | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 010b0d71..ae9794b8 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -83,7 +83,7 @@ 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 = /^[^"]+c\"[^"]+"/.exec( line ); + var testString = /^[^"]+c\"[^"]+"/.exec(line); Variables.globals[globalIdent] = { name: globalIdent, alias: !!testAlias, diff --git a/src/jsifier.js b/src/jsifier.js index 6548e87f..657a9673 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -265,7 +265,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) { + if (!(item.ident in Variables.globals) || !Variables.globals[item.ident].isString) { item.JS = 'var ' + item.ident + ';'; } } @@ -317,12 +317,15 @@ function JSify(data, functionsOnly, givenFunctions) { constant = makePointer(constant, null, BUILD_AS_SHARED_LIB ? 'ALLOC_NORMAL' : 'ALLOC_STATIC', item.type); var js; - - if(Variables.globals[ item.ident ].isString) { + + // 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 + ';'; } + // Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations if (item.ident.substr(0, 5) == '__ZTV') { js += '\n' + makePointer('[0]', null, BUILD_AS_SHARED_LIB ? 'ALLOC_NORMAL' : 'ALLOC_STATIC', ['void*']) + ';'; diff --git a/src/parseTools.js b/src/parseTools.js index 0eaf4e0b..ad6f2830 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1434,7 +1434,7 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { } } else if (param.intertype == 'value') { ret = param.ident; - if(ret in Variables.globals && Variables.globals[ret].isString) { + if (ret in Variables.globals && Variables.globals[ret].isString) { ret = "STRING_TABLE." + ret; } if (param.type == 'i64' && I64_MODE == 1) { |