private LNode GenerateIfElseChain(PredictionTree tree, LNode[] branchCode, ref LNode laVar, MSet <int> switchCases) { // From the prediction table, generate a chain of if-else // statements in reverse, starting with the final "else" clause. // Skip any branches that have been claimed for use in a switch() LNode ifChain = null; bool usedTest = false; for (int i = tree.Children.Count - 1; i >= 0; i--) { if (switchCases.Contains(i)) { continue; } if (ifChain == null) { ifChain = branchCode[i]; } else { usedTest = true; var branch = tree.Children[i]; LNode test; if (tree.IsAssertionLevel) { test = GenerateTest(branch.AndPreds, tree.Lookahead, laVar); } else { var set = CGH.Optimize(branch.Set, branch.Covered); test = CGH.GenerateTest(set, laVar); } LNode @if = F.Call(S.If, test, branchCode[i]); if (!ifChain.IsIdWithoutPAttrs(S.Missing)) { @if = @if.PlusArg(ifChain); } ifChain = @if; } } if (!usedTest) { laVar = null; // unnecessary } return(ifChain); }