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); }
public static bool TryGetParentConstructWithGivenParent(ILogicalConstruct initialNode, ILogicalConstruct parent, out ILogicalConstruct desiredNode) { if (initialNode == null || parent == null) { desiredNode = null; return(false); } desiredNode = initialNode; while (desiredNode.get_Parent() != null) { if (desiredNode.get_Parent() == parent) { return(true); } desiredNode = desiredNode.get_Parent() as ILogicalConstruct; } desiredNode = null; return(false); }
private HashSet <ILogicalConstruct> GetLogicalConstructsInRange(BlockRange blockRange, out ILogicalConstruct theCommonParent) { V_0 = new HashSet <ILogicalConstruct>(); V_1 = new HashSet <ISingleEntrySubGraph>(); V_2 = blockRange.Start.get_First().get_Offset(); V_3 = blockRange.End.get_First().get_Offset(); V_5 = 0; while (V_5 < (int)this.context.get_CFG().get_Blocks().Length) { V_6 = this.context.get_CFG().get_Blocks()[V_5]; if (V_6.get_First().get_Offset() >= V_2 && V_6.get_First().get_Offset() <= V_3) { V_7 = this.context.get_CFGBlockToLogicalConstructMap().get_Item(V_6); V_8 = 0; while (V_8 < (int)V_7.Length) { dummyVar0 = V_1.Add((ILogicalConstruct)V_7[V_8].get_Parent()); dummyVar1 = V_0.Add(V_7[V_8]); V_8 = V_8 + 1; } } V_5 = V_5 + 1; } if (V_1.get_Count() == 1) { theCommonParent = (ILogicalConstruct)V_1.ToArray <ISingleEntrySubGraph>()[0]; return(V_0); } theCommonParent = (ILogicalConstruct)LogicalFlowUtilities.FindFirstCommonParent(V_1); V_4 = new HashSet <ILogicalConstruct>(); V_9 = V_0.GetEnumerator(); try { while (V_9.MoveNext()) { dummyVar2 = LogicalFlowUtilities.TryGetParentConstructWithGivenParent(V_9.get_Current(), theCommonParent, out V_10); dummyVar3 = V_4.Add(V_10); } } finally { ((IDisposable)V_9).Dispose(); } if (theCommonParent as ExceptionHandlingLogicalConstruct != null) { V_4.Clear(); dummyVar4 = V_4.Add(theCommonParent); theCommonParent = theCommonParent.get_Parent() as ILogicalConstruct; } return(V_4); }
public static BlockLogicalConstruct GetNearestGuardedBlock(ILogicalConstruct start) { V_0 = start; while (V_0 != null && V_0 as ExceptionHandlingLogicalConstruct == null) { V_0 = (ILogicalConstruct)V_0.get_Parent(); } if (V_0 == null) { return(null); } if ((V_0 as ExceptionHandlingLogicalConstruct).get_Try().get_CFGBlocks().Contains(start.get_FirstBlock())) { return((V_0 as ExceptionHandlingLogicalConstruct).get_Try()); } if (V_0 as TryCatchFilterLogicalConstruct == null) { if (V_0 as TryFinallyLogicalConstruct != null) { return((V_0 as TryFinallyLogicalConstruct).get_Finally()); } if (V_0 as TryFaultLogicalConstruct == null) { throw new Exception("Unknown type of exception handling logical construct encountered."); } return((V_0 as TryFaultLogicalConstruct).get_Fault()); } V_1 = (V_0 as TryCatchFilterLogicalConstruct).get_Handlers(); V_2 = 0; while (V_2 < (int)V_1.Length) { V_3 = V_1[V_2]; if (V_3.get_HandlerType() == 1) { if ((V_3 as ExceptionHandlingBlockFilter).get_Filter().get_CFGBlocks().Contains(start.get_FirstBlock())) { return((V_3 as ExceptionHandlingBlockFilter).get_Filter()); } return((V_3 as ExceptionHandlingBlockFilter).get_Handler()); } if (V_3.get_HandlerType() == FilteringExceptionHandlerType.Catch) { return(V_3 as ExceptionHandlingBlockCatch); } V_2 = V_2 + 1; } return(null); }