aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorjulien.hamaide <julien.hamaide@fishingcactus.com>2012-01-25 15:56:27 +0100
committerjulien.hamaide <julien.hamaide@fishingcactus.com>2012-01-25 15:56:27 +0100
commit0040353a176fac6eff5091556afe87c1955e51c3 (patch)
treeb9b2510d4616df4ce7578067ef80e7c739e6131e /src/jsifier.js
parent61e4b6b9d40c966ead0198e9a9a32d1067273ef7 (diff)
String constants are store in a table to limit variable count
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 69a64d1a..6548e87f 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -247,7 +247,8 @@ function JSify(data, functionsOnly, givenFunctions) {
substrate.addActor('GlobalVariable', {
processItem: function(item) {
function needsPostSet(value) {
- return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW';
+ return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW'
+ || value.substr(0, 13) === 'STRING_TABLE.';
}
item.intertype = 'GlobalVariableStub';
@@ -264,7 +265,9 @@ function JSify(data, functionsOnly, givenFunctions) {
// they would shadow similarly-named globals in the parent.
item.JS = '';
} else {
- item.JS = 'var ' + item.ident + ';';
+ if(!(item.ident in Variables.globals ) || !Variables.globals[item.ident].isString) {
+ item.JS = 'var ' + item.ident + ';';
+ }
}
var constant = null;
if (item.external) {
@@ -313,7 +316,13 @@ function JSify(data, functionsOnly, givenFunctions) {
// allocations in a shared library.
constant = makePointer(constant, null, BUILD_AS_SHARED_LIB ? 'ALLOC_NORMAL' : 'ALLOC_STATIC', item.type);
- var js = item.ident + '=' + constant + ';';
+ var js;
+
+ 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*']) + ';';