aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-15 14:50:13 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-15 14:50:13 -0800
commitb39052c106288d1c8717bb2000ceb316daebe231 (patch)
tree9ec503d13fb5b241e4dac75000007a525f954817 /src/jsifier.js
parentcb4c2bf13fcc9f7b4fda2e7ac4d8646702838e15 (diff)
handle phis from indirectbr
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 5fbea5ba..3c17b847 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1242,7 +1242,12 @@ function JSify(data, functionsOnly, givenFunctions) {
return ret + item.ident + '.f' + item.indexes[0][0].text + ' = ' + finalizeLLVMParameter(item.value) + ', ' + item.ident + ')';
});
makeFuncLineActor('indirectbr', function(item) {
- return makeBranch(finalizeLLVMParameter(item.value), item.currLabelId, true);
+ var phiSets = calcPhiSets(item);
+ var js = 'var ibr = ' + finalizeLLVMParameter(item.value) + ';\n';
+ for (var targetLabel in phiSets) {
+ js += 'if (ibr == ' + targetLabel + ') { ' + getPhiSetsForLabel(phiSets, targetLabel) + ' }\n';
+ }
+ return js + makeBranch('ibr', item.currLabelId, true);
});
makeFuncLineActor('alloca', function(item) {
if (typeof item.allocatedIndex === 'number') {