aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-15 16:40:29 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-17 12:43:59 -0700
commiteb466e688fb95efe4bdf32facb99c1b668e6cb4e (patch)
tree1d95d9f6c63971a92c567b3b1d80cdf25398a163 /src/jsifier.js
parent844faf36ebb89698bb6db042f366ec851b89ddbe (diff)
improve runtimelink handling of function aliases
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index b76579cc..02459193 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -358,11 +358,21 @@ function JSify(data, functionsOnly, givenFunctions) {
item.JS = 'var ' + item.ident + ';';
// Set the actual value in a postset, since it may be a global variable. We also order by dependencies there
var value = Variables.globals[item.ident].resolvedAlias = finalizeLLVMParameter(item.value);
+ var fix = '';
+ if (BUILD_AS_SHARED_LIB == 2 && !item.private_) {
+ var target = item.ident;
+ if (isFunctionType(item.type)) {
+ target = item.value.ident; // the other side does not know this is an alias/function table index. So make it the alias target.
+ var varData = Variables.globals[target];
+ assert(!varData, 'multi-level aliasing does not work yet in shared lib 2 exports');
+ }
+ fix = '\nif (globalScope) { assert(!globalScope["' + item.ident + '"]); globalScope["' + item.ident + '"] = ' + target + ' }'
+ }
ret.push({
intertype: 'GlobalVariablePostSet',
ident: item.ident,
dependencies: set([value]),
- JS: item.ident + ' = ' + value + ';'
+ JS: item.ident + ' = ' + value + ';' + fix
});
return ret;
}