aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-05 17:57:54 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-05 17:57:54 -0800
commit0591fabb67954257cfa3a024b78f46a392fd4a31 (patch)
treef987a75683a7fd3ec726ab3182ff84872d14bbd8 /src/jsifier.js
parentb2c5374402ae4e952c652772e9907a8f1c0efec9 (diff)
support for external variables in runtime linking
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index f4e0ef50..a2ca03eb 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -321,10 +321,10 @@ function JSify(data, functionsOnly, givenFunctions) {
if (item.ident in EXPORTED_GLOBALS) {
js += '\nModule["' + item.ident + '"] = ' + item.ident + ';';
}
- // TODO: Support exporting BUILD_AS_SHARED_LIB == 2 globals. The problem now is that they override the main file's globals.
- //if (BUILD_AS_SHARED_LIB == 2) {
- // js += 'if (globalScope) globalScope["' + item.ident + '"] = ' + item.ident + ';'; // XXX: assert not overriding
- //}
+ if (BUILD_AS_SHARED_LIB == 2 && !item.private_) {
+ // TODO: make the assert conditional on ASSERTIONS
+ js += 'if (globalScope) { assert(!globalScope["' + item.ident + '"]); globalScope["' + item.ident + '"] = ' + item.ident + ' }';
+ }
return ret.concat({
intertype: 'GlobalVariable',
JS: js,
@@ -620,6 +620,7 @@ function JSify(data, functionsOnly, givenFunctions) {
}
if (BUILD_AS_SHARED_LIB == 2) {
+ // TODO: make the assert conditional on ASSERTIONS
func.JS += 'if (globalScope) { assert(!globalScope["' + func.ident + '"]); globalScope["' + func.ident + '"] = ' + func.ident + ' }';
}