Esempio n. 1
0
 private bool CanBeLoopCondition(ILogicalConstruct node, HashSet <ILogicalConstruct> loopBody)
 {
     if (!loopBody.Contains(node))
     {
         return(false);
     }
     if (node as ConditionLogicalConstruct == null)
     {
         return(false);
     }
     V_0 = 0;
     V_1 = node.get_SameParentSuccessors().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = (ILogicalConstruct)V_1.get_Current();
             if (!loopBody.Contains(V_2))
             {
                 continue;
             }
             V_0 = V_0 + 1;
         }
     }
     finally
     {
         ((IDisposable)V_1).Dispose();
     }
     return(V_0 == 1);
 }
 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);
 }
Esempio n. 3
0
 private IEnumerable <ILogicalConstruct> GetNodeSuccessors(ILogicalConstruct node)
 {
     V_0 = new List <ILogicalConstruct>();
     V_1 = node.get_SameParentSuccessors().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = (ILogicalConstruct)V_1.get_Current();
             if (this.removedEdges.ContainsKey(node) && this.removedEdges.get_Item(node).Contains(V_2))
             {
                 continue;
             }
             V_0.Add(V_2);
         }
     }
     finally
     {
         ((IDisposable)V_1).Dispose();
     }
     return(V_0);
 }
 private void ProcessCurrentNode(YieldExceptionHandlerInfo handlerInfo, Queue <ILogicalConstruct> bfsQueue, ILogicalConstruct currentNode)
 {
     if (currentNode as CFGBlockLogicalConstruct == null)
     {
         if (currentNode as TryFinallyLogicalConstruct != null && this.createdConstructsToIntervalMap.TryGetValue(currentNode as TryFinallyLogicalConstruct, out V_10) && V_10.get_TryStates().IsProperSupersetOf(handlerInfo.get_TryStates()))
         {
             throw new Exception("This try/finally construct cannot be nested in the current construct");
         }
     }
     else
     {
         V_0 = currentNode as CFGBlockLogicalConstruct;
         V_1 = 0;
         while (V_1 < V_0.get_LogicalConstructExpressions().get_Count())
         {
             V_2 = V_0.get_LogicalConstructExpressions().get_Item(V_1);
             if (!this.TryGetStateAssignValue(V_2, out V_3))
             {
                 if (handlerInfo.get_HandlerType() == YieldExceptionHandlerType.Method && V_2.get_CodeNodeType() == 19 && (object)(V_2 as MethodInvocationExpression).get_MethodExpression().get_MethodDefinition() == (object)handlerInfo.get_FinallyMethodDefinition())
                 {
                     if (V_0.get_LogicalConstructExpressions().get_Count() == 1)
                     {
                         if (this.newFinallyBody == null)
                         {
                             this.newFinallyBody = V_0;
                         }
                         dummyVar0 = this.finallyBlocks.Add(this.newFinallyBody);
                         dummyVar1 = this.orderedCFGNodes.Remove(V_0);
                         return;
                     }
                     if (V_1 != 0)
                     {
                         if (V_1 >= V_0.get_LogicalConstructExpressions().get_Count() - 1)
                         {
                             V_8       = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_0, V_1);
                             dummyVar3 = this.newTryBody.Add(V_8.get_Key());
                             V_4       = V_8.get_Value();
                             dummyVar4 = this.orderedCFGNodes.Remove(V_0);
                         }
                         else
                         {
                             V_6       = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_0, V_1);
                             dummyVar2 = this.newTryBody.Add(V_6.get_Key());
                             V_7       = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_6.get_Value(), 1);
                             V_4       = V_7.get_Key();
                             this.orderedCFGNodes.set_Item(this.orderedCFGNodes.IndexOf(V_0), V_7.get_Value());
                         }
                     }
                     else
                     {
                         V_5 = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_0, V_1 + 1);
                         V_4 = V_5.get_Key();
                         this.orderedCFGNodes.set_Item(this.orderedCFGNodes.IndexOf(V_0), V_5.get_Value());
                     }
                     if (this.newFinallyBody == null)
                     {
                         this.newFinallyBody = V_4;
                     }
                     dummyVar5 = this.finallyBlocks.Add(V_4);
                     return;
                 }
             }
             else
             {
                 if (!handlerInfo.get_TryStates().Contains(V_3))
                 {
                     if (handlerInfo.get_HandlerType() == YieldExceptionHandlerType.Method || !this.TryProcessConditionalDisposeHandler(handlerInfo, V_0))
                     {
                         throw new Exception("Invalid state value");
                     }
                     return;
                 }
             }
             V_1 = V_1 + 1;
         }
     }
     dummyVar6 = this.newTryBody.Add(currentNode);
     V_11      = currentNode.get_SameParentSuccessors().GetEnumerator();
     try
     {
         while (V_11.MoveNext())
         {
             V_12 = (ILogicalConstruct)V_11.get_Current();
             bfsQueue.Enqueue(V_12);
         }
     }
     finally
     {
         ((IDisposable)V_11).Dispose();
     }
     return;
 }