aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-16 17:02:43 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-08-21 17:09:16 -0700
commitd705c37e34ad11b01ad33e7c985818a14623dff7 (patch)
treebb1a48ff1208f5a4efda08d6f2a5c1827e55a0b3 /src/jsifier.js
parentab506b38dbb9acb2db4f1a1b8c1608cc57409a6b (diff)
emit switches in relooper1.5.6
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 683b1874..31e066ab 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -795,7 +795,13 @@ function JSify(data, functionsOnly, givenFunctions) {
var label = block.labels[i];
var content = getLabelLines(label, '', true);
//printErr(func.ident + ' : ' + label.ident + ' : ' + content + '\n');
- blockMap[label.ident] = Relooper.addBlock(content);
+ var last = label.lines[label.lines.length-1];
+ if (last.intertype != 'switch') {
+ blockMap[label.ident] = Relooper.addBlock(content);
+ } else {
+ assert(last.signedIdent);
+ blockMap[label.ident] = Relooper.addBlock(content, last.signedIdent);
+ }
}
// add branchings
function relevant(x) { return x && x.length > 2 ? x : 0 } // ignores ';' which valueJS and label*JS can be if empty
@@ -1125,7 +1131,7 @@ function JSify(data, functionsOnly, givenFunctions) {
}
});
makeFuncLineActor('switch', function(item) {
- var useIfs = RELOOP || item.switchLabels.length < 1024; // with a huge number of cases, if-else which looks nested to js parsers can cause problems
+ var useIfs = false;
var phiSets = calcPhiSets(item);
// Consolidate checks that go to the same label. This is important because it makes the relooper simpler and faster.
var targetLabels = {}; // for each target label, the list of values going to it
@@ -1139,7 +1145,8 @@ function JSify(data, functionsOnly, givenFunctions) {
});
var ret = '';
var first = true;
- var signedIdent = makeSignOp(item.ident, item.type, 're'); // we need to standardize for purpose of comparison
+ signedIdent = makeSignOp(item.ident, item.type, 're'); // we need to standardize for purpose of comparison
+ if (!useIfs) item.signedIdent = signedIdent;
if (RELOOP) {
item.groupedLabels = [];
}