private Dictionary <ILogicalConstruct, HashSet <ISingleEntrySubGraph> > GetValidCases(DominatorTree dominatorTree, ILogicalConstruct switchCFGBlock) { V_0 = new SwitchBuilder.u003cu003ec__DisplayClass9_0(); V_0.caseEntriesToDominatedNodesMap = new Dictionary <ILogicalConstruct, HashSet <ISingleEntrySubGraph> >(); V_1 = new HashSet <ISingleEntrySubGraph>(); dummyVar0 = V_1.Add(switchCFGBlock); V_4 = switchCFGBlock.get_SameParentSuccessors().GetEnumerator(); try { while (V_4.MoveNext()) { V_5 = (ILogicalConstruct)V_4.get_Current(); if (V_5 == switchCFGBlock || dominatorTree.GetImmediateDominator(V_5) != switchCFGBlock) { continue; } V_6 = dominatorTree.GetDominatedNodes(V_5); V_0.caseEntriesToDominatedNodesMap.Add(V_5, V_6); V_1.UnionWith(V_6); } } finally { ((IDisposable)V_4).Dispose(); } stackVariable34 = DFSTBuilder.BuildTree(switchCFGBlock.get_Parent(), switchCFGBlock).get_ReversePostOrder(); stackVariable35 = SwitchBuilder.u003cu003ec.u003cu003e9__9_0; if (stackVariable35 == null) { dummyVar1 = stackVariable35; stackVariable35 = new Func <DFSTNode, ILogicalConstruct>(SwitchBuilder.u003cu003ec.u003cu003e9.u003cGetValidCasesu003eb__9_0); SwitchBuilder.u003cu003ec.u003cu003e9__9_0 = stackVariable35; } V_2 = new List <ILogicalConstruct>(stackVariable34.Select <DFSTNode, ILogicalConstruct>(stackVariable35).Where <ILogicalConstruct>(new Func <ILogicalConstruct, bool>(V_0.u003cGetValidCasesu003eb__1))); do { V_3 = false; V_7 = V_2.GetEnumerator(); try { while (V_7.MoveNext()) { V_8 = V_7.get_Current(); if (!V_0.caseEntriesToDominatedNodesMap.TryGetValue(V_8, out V_9) || this.IsCaseValid(V_8, V_1)) { continue; } V_1.ExceptWith(V_9); dummyVar2 = V_0.caseEntriesToDominatedNodesMap.Remove(V_8); V_3 = true; } } finally { ((IDisposable)V_7).Dispose(); } }while (V_3); return(V_0.caseEntriesToDominatedNodesMap); }
private Dictionary <ILogicalConstruct, HashSet <ISingleEntrySubGraph> > GetValidCases(DominatorTree dominatorTree, ILogicalConstruct switchCFGBlock) { Dictionary <ILogicalConstruct, HashSet <ISingleEntrySubGraph> > caseEntriesToDominatedNodesMap = new Dictionary <ILogicalConstruct, HashSet <ISingleEntrySubGraph> >(); HashSet <ISingleEntrySubGraph> legalPredecessors = new HashSet <ISingleEntrySubGraph>(); legalPredecessors.Add(switchCFGBlock); foreach (ILogicalConstruct successor in switchCFGBlock.SameParentSuccessors) { if (successor != switchCFGBlock && dominatorTree.GetImmediateDominator(successor) == switchCFGBlock) { HashSet <ISingleEntrySubGraph> dominatedNodes = dominatorTree.GetDominatedNodes(successor); caseEntriesToDominatedNodesMap.Add(successor, dominatedNodes); legalPredecessors.UnionWith(dominatedNodes); } } DFSTree dfsTree = DFSTBuilder.BuildTree(switchCFGBlock.Parent, switchCFGBlock); List <ILogicalConstruct> orderedCaseEntries = new List <ILogicalConstruct>(dfsTree.ReversePostOrder.Select(node => node.Construct as ILogicalConstruct).Where(construct => caseEntriesToDominatedNodesMap.ContainsKey(construct))); bool changed; do { changed = false; foreach (ILogicalConstruct caseEntry in orderedCaseEntries) { HashSet <ISingleEntrySubGraph> dominatedNodes; if (caseEntriesToDominatedNodesMap.TryGetValue(caseEntry, out dominatedNodes) && !IsCaseValid(caseEntry, legalPredecessors)) { legalPredecessors.ExceptWith(dominatedNodes); caseEntriesToDominatedNodesMap.Remove(caseEntry); changed = true; } } } while (changed); return(caseEntriesToDominatedNodesMap); }