aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-25 10:21:27 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-25 10:21:27 -0800
commit72c0fb8cdb7d430039a67308e798212def8c2b08 (patch)
tree970b68e46e1b5a10776c571dd35961ec2e1d52bc /src/jsifier.js
parent0bdac9f178cb4aefdd7b11eee93110324c76f9a2 (diff)
fix some spacing stuff
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js9
1 files changed, 6 insertions, 3 deletions
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*']) + ';';