private BlockLogicalConstruct GenerateFinallyBlock()
 {
     V_0             = this.ProcessFinallyNode(this.finallyEntryBlock, this.disposeCallBlock);
     dummyVar0       = V_0.RemoveFromPredecessors(this.conditionBlock);
     dummyVar1       = this.conditionBlock.RemoveFromSuccessors(V_0);
     stackVariable15 = this.logicalContext;
     V_2             = stackVariable15.get_MaxBlockIndex() + 1;
     stackVariable15.set_MaxBlockIndex(V_2);
     V_1 = new EmptyBlockLogicalConstruct(V_2);
     V_1.AddToPredecessors(this.disposeCallBlock);
     V_1.AddToPredecessors(this.conditionBlock);
     this.disposeCallBlock.AddToSuccessors(V_1);
     this.conditionBlock.AddToSuccessors(V_1);
     V_1.set_Parent(this.finallyEntryBlock.get_Parent());
     dummyVar2 = V_1.get_Parent().get_Children().Add(V_1);
     V_3       = 0;
     while (V_3 < (int)this.conditionBlock.get_TheBlock().get_Successors().Length)
     {
         if (InstructionBlock.op_Equality(this.conditionBlock.get_TheBlock().get_Successors()[V_3], V_0.get_TheBlock()))
         {
             this.conditionBlock.get_TheBlock().get_Successors()[V_3] = null;
         }
         V_3 = V_3 + 1;
     }
     dummyVar3 = this.finallyBlocks.Add(V_1);
     return(new BlockLogicalConstruct(this.finallyEntryBlock, this.finallyBlocks));
 }
 private void ProcessMultiWayCFGPredecessor(CFGBlockLogicalConstruct finallyBody, InstructionBlock theBlock, InstructionBlock theNewSuccessor)
 {
     V_0 = finallyBody.get_TheBlock();
     V_2 = 0;
     while (V_2 < (int)theBlock.get_Successors().Length)
     {
         if (InstructionBlock.op_Equality(theBlock.get_Successors()[V_2], V_0))
         {
             theBlock.get_Successors()[V_2] = theNewSuccessor;
         }
         V_2 = V_2 + 1;
     }
     if (this.methodContext.get_ControlFlowGraph().get_SwitchBlocksInformation().TryGetValue(theBlock, out V_1))
     {
         V_3 = V_1.get_OrderedCasesArray();
         V_4 = 0;
         while (V_4 < (int)V_3.Length)
         {
             if (InstructionBlock.op_Equality(V_3[V_4], V_0))
             {
                 V_3[V_4] = theNewSuccessor;
             }
             V_4 = V_4 + 1;
         }
         if (InstructionBlock.op_Equality(V_1.get_DefaultCase(), V_0))
         {
             V_1.set_DefaultCase(theNewSuccessor);
         }
     }
     return;
 }
 private void RedirectSuccessor(InstructionBlock theBlock, InstructionBlock oldSuccessor, InstructionBlock newSuccessor)
 {
     dummyVar0 = oldSuccessor.get_Predecessors().Remove(theBlock);
     V_1       = 0;
     while (V_1 < (int)theBlock.get_Successors().Length)
     {
         if (InstructionBlock.op_Equality(theBlock.get_Successors()[V_1], oldSuccessor))
         {
             theBlock.get_Successors()[V_1] = newSuccessor;
         }
         V_1 = V_1 + 1;
     }
     dummyVar1 = newSuccessor.get_Predecessors().Add(theBlock);
     if (!this.theCFG.get_SwitchBlocksInformation().TryGetValue(theBlock, out V_0))
     {
         return;
     }
     V_2 = 0;
     while (V_2 < (int)V_0.get_OrderedCasesArray().Length)
     {
         if (InstructionBlock.op_Equality(V_0.get_OrderedCasesArray()[V_2], oldSuccessor))
         {
             V_0.get_OrderedCasesArray()[V_2] = newSuccessor;
         }
         V_2 = V_2 + 1;
     }
     if (InstructionBlock.op_Equality(V_0.get_DefaultCase(), oldSuccessor))
     {
         V_0.set_DefaultCase(newSuccessor);
     }
     return;
 }
Ejemplo n.º 4
0
 private void SetTrueAndFalseSuccessors(CFGBlockLogicalConstruct cfgConditionBlock)
 {
     stackVariable1 = cfgConditionBlock.get_TheBlock();
     V_0            = stackVariable1.get_Successors()[0];
     V_1            = stackVariable1.get_Successors()[1];
     V_2            = cfgConditionBlock.get_CFGSuccessors().GetEnumerator();
     try
     {
         while (V_2.MoveNext())
         {
             V_3 = V_2.get_Current();
             if (InstructionBlock.op_Equality(V_3.get_TheBlock(), V_0))
             {
                 this.set_TrueCFGSuccessor(V_3);
             }
             if (!InstructionBlock.op_Equality(V_3.get_TheBlock(), V_1))
             {
                 continue;
             }
             this.set_FalseCFGSuccessor(V_3);
         }
     }
     finally
     {
         ((IDisposable)V_2).Dispose();
     }
     return;
 }
Ejemplo n.º 5
0
 protected override Queue <InstructionBlock> InitializeTheTraversalQueue()
 {
     V_0 = this.InitializeTheTraversalQueue();
     if (InstructionBlock.op_Equality(this.debugStateCheckBlock, null) || !this.theCFG.get_SwitchBlocksInformation().TryGetValue(this.debugStateCheckBlock, out V_1))
     {
         return(V_0);
     }
     V_2 = 0;
     while (V_2 + this.stateCheckOffset < (int)V_1.get_OrderedCasesArray().Length)
     {
         this.stateToStartBlock[V_2] = this.SkipBranchChain(V_1.get_OrderedCasesArray()[V_2 + this.stateCheckOffset]);
         V_0.Enqueue(this.stateToStartBlock[V_2]);
         V_2 = V_2 + 1;
     }
     return(V_0);
 }
 private void ReattachDefaultSuccessor(InstructionBlock initialBlock, InstructionBlock currentBlock)
 {
     if (InstructionBlock.op_Inequality(initialBlock, currentBlock))
     {
         this.RedirectNonControllerPredecessors(initialBlock, currentBlock);
         this.SwapCFGBlocks(initialBlock.get_Index(), currentBlock.get_Index());
         V_0 = 0;
         while (V_0 < (int)this.stateToStartBlock.Length)
         {
             if (InstructionBlock.op_Equality(this.stateToStartBlock[V_0], initialBlock))
             {
                 this.stateToStartBlock[V_0] = currentBlock;
             }
             V_0 = V_0 + 1;
         }
     }
     return;
 }
 private void CreateControllerSwitchData()
 {
     V_0            = this.GetIndexOfLastNonNullElement(this.stateToStartBlock);
     stackVariable6 = V_0 + 1;
     V_0            = stackVariable6;
     V_1            = new InstructionBlock[stackVariable6];
     V_2            = 0;
     while (V_2 < V_0)
     {
         if (!InstructionBlock.op_Equality(this.stateToStartBlock[V_2], null))
         {
             V_1[V_2] = this.stateToStartBlock[V_2];
         }
         else
         {
             V_1[V_2] = this.defaultStateEntry;
         }
         V_2 = V_2 + 1;
     }
     this.switchData = new Telerik.JustDecompiler.Cil.SwitchData(null, this.defaultStateEntry, V_1);
     return;
 }
 private bool TryRemoveStateSavingBlock(InstructionBlock theBlock)
 {
     V_0 = this.GetFirst <InstructionBlock>(theBlock.get_Predecessors());
     if ((int)V_0.get_Successors().Length != 2 || !this.CheckForIsCompletedCall(V_0))
     {
         return(false);
     }
     if (InstructionBlock.op_Equality(V_0.get_Successors()[0], theBlock))
     {
         stackVariable22 = V_0.get_Successors()[1];
     }
     else
     {
         stackVariable22 = V_0.get_Successors()[0];
     }
     V_1 = stackVariable22;
     theBlock.set_Successors(new InstructionBlock[0]);
     stackVariable28    = new InstructionBlock[1];
     stackVariable28[0] = V_1;
     V_0.set_Successors(stackVariable28);
     dummyVar0 = this.toBeRemoved.Add(theBlock);
     return(true);
 }
        protected bool RemoveControllerChain()
        {
            V_0 = this.InitializeTheTraversalQueue();
            while (V_0.get_Count() > 0)
            {
                V_1 = V_0.Dequeue();
                V_2 = V_1;
                while (this.IsStateMachineControllerBlock(ref V_2, out V_4, out V_3))
                {
                    switch (V_4 - 1)
                    {
                    case 0:
                    {
                        V_6 = this.theCFG.get_SwitchBlocksInformation().get_Item(V_2);
                        V_7 = V_6.get_OrderedCasesArray();
                        V_8 = 0;
                        while (V_8 < (int)V_7.Length)
                        {
                            if (!this.toBeRemoved.Contains(V_7[V_8]))
                            {
                                V_9 = this.TryGetStateEntry(V_7[V_8], out V_5);
                                switch (V_9)
                                {
                                case 0:
                                {
                                    return(false);
                                }

                                case 1:
                                {
                                    this.stateToStartBlock[V_8 + V_3] = V_5;
                                    break;
                                }

                                case 2:
                                {
                                    this.stateToStartBlock[V_8 + V_3] = V_5;
                                    V_0.Enqueue(V_5);
                                    break;
                                }
                                }
                            }
                            V_8 = V_8 + 1;
                        }
                        V_0.Enqueue(this.SkipBranchChain(V_6.get_DefaultCase()));
                        break;
                    }

                    case 1:
                    {
                        V_9 = this.TryGetStateEntry(V_2.get_Successors()[0], out V_10);
                        switch (V_9)
                        {
                        case 0:
                        {
                            return(false);
                        }

                        case 1:
                        {
                            this.stateToStartBlock[V_3] = V_10;
                            break;
                        }

                        case 2:
                        {
                            this.stateToStartBlock[V_3] = V_10;
                            V_0.Enqueue(V_10);
                            break;
                        }
                        }
                        break;
                    }

                    case 2:
                    {
                        V_12 = 1;
                        if (V_3 == -1)
                        {
                            V_3  = 0;
                            V_12 = 0;
                        }
                        V_9 = this.TryGetStateEntry(V_2.get_Successors()[V_12], out V_11);
                        if (V_9 == StateControllerRemover.ControllerTraversalSearchResult.PatternFailed)
                        {
                            return(false);
                        }
                        if (V_9 - 1 > 1)
                        {
                            break;
                        }
                        this.stateToStartBlock[V_3] = V_11;
                        break;
                    }
                    }
                    dummyVar0 = this.toBeRemoved.Add(V_2);
                    if (V_4 != 3)
                    {
                        V_2 = V_2.get_Successors()[(int)V_2.get_Successors().Length - 1];
                    }
                    else
                    {
                        V_2 = V_2.get_Successors()[0];
                    }
                    V_2 = this.SkipBranchChain(V_2);
                }
                if (InstructionBlock.op_Equality(this.defaultStateEntry, null))
                {
                    this.defaultStateEntry = V_2;
                }
                this.ReattachDefaultSuccessor(V_1, V_2);
                while (V_0.get_Count() > 0 && this.toBeRemoved.Contains(V_0.Peek()))
                {
                    dummyVar1 = V_0.Dequeue();
                }
            }
            if (this.toBeRemoved.get_Count() == 0)
            {
                return(false);
            }
            this.CreateControllerSwitchData();
            return(true);
        }