public static KeyValuePair <CFGBlockLogicalConstruct, CFGBlockLogicalConstruct> SplitCFGBlockAt(LogicalFlowBuilderContext logicalContext, CFGBlockLogicalConstruct cfgBlock, int expressionIndex)
 {
     V_0 = cfgBlock.get_LogicalConstructExpressions();
     if (V_0 == null)
     {
         throw new ArgumentNullException("blockExpressions");
     }
     if (expressionIndex <= 0 || expressionIndex >= V_0.get_Count())
     {
         throw new ArgumentOutOfRangeException("expressionIndex");
     }
     V_1 = logicalContext.get_CFGBlockToLogicalConstructMap().get_Item(cfgBlock.get_TheBlock());
     V_2 = (int)V_1.Length;
     V_3 = 0;
     while (V_3 < V_2 && cfgBlock != V_1[V_3])
     {
         V_3 = V_3 + 1;
     }
     if (V_3 == V_2)
     {
         throw new ArgumentException("cfgBlock");
     }
     V_4 = cfgBlock.get_LogicalConstructExpressions().GetRange(0, expressionIndex);
     V_5 = new PartialCFGBlockLogicalConstruct(cfgBlock, V_4);
     V_5.RedirectPredecessors();
     V_6 = cfgBlock.get_LogicalConstructExpressions().GetRange(expressionIndex, V_0.get_Count() - expressionIndex);
     V_7 = new PartialCFGBlockLogicalConstruct(cfgBlock, V_6);
     V_7.RedirectSuccessors();
     V_5.AddToSuccessors(V_7);
     V_7.AddToPredecessors(V_5);
     V_8  = new CFGBlockLogicalConstruct[V_2 + 1];
     V_9  = 0;
     V_10 = 0;
     while (V_9 < V_2)
     {
         if (V_9 == V_3)
         {
             V_8[V_10]            = V_5;
             stackVariable68      = V_10 + 1;
             V_10                 = stackVariable68;
             V_8[stackVariable68] = V_7;
         }
         else
         {
             V_8[V_10] = V_1[V_9];
         }
         V_9  = V_9 + 1;
         V_10 = V_10 + 1;
     }
     logicalContext.get_CFGBlockToLogicalConstructMap().set_Item(cfgBlock.get_TheBlock(), V_8);
     return(new KeyValuePair <CFGBlockLogicalConstruct, CFGBlockLogicalConstruct>(V_5, V_7));
 }
Ejemplo n.º 2
0
 public PartialCFGBlockLogicalConstruct(CFGBlockLogicalConstruct originalCFGConstruct, IEnumerable <Expression> expressions)
 {
     base(originalCFGConstruct.get_TheBlock(), expressions);
     this.set_OriginalCFGConstruct(originalCFGConstruct);
     this.RedirectParent();
     return;
 }
 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;
 }
Ejemplo n.º 4
0
 protected string NodeILOffset(LogicalFlowBuilderContext context, CFGBlockLogicalConstruct node)
 {
     if (node == null)
     {
         return("null");
     }
     V_0 = node as PartialCFGBlockLogicalConstruct;
     if (V_0 == null)
     {
         V_2 = node.get_TheBlock().get_First().get_Offset();
         return(String.Format("IL_{0}", V_2.ToString("x4")));
     }
     V_1 = Array.IndexOf <CFGBlockLogicalConstruct>(context.get_CFGBlockToLogicalConstructMap().get_Item(V_0.get_TheBlock()), V_0);
     if (V_1 == -1)
     {
         throw new Exception("Invalid partial block data.");
     }
     V_2 = V_0.get_TheBlock().get_First().get_Offset();
     return(String.Format("IL_{0}_{1}", V_2.ToString("x4"), V_1));
 }
 private void DetachFromLogicalTree(CFGBlockLogicalConstruct node)
 {
     if (node.get_CFGPredecessors().get_Count() > 0 || node.get_CFGSuccessors().get_Count() > 0)
     {
         throw new Exception("This node cannot be detached from the logical tree.");
     }
     dummyVar0 = node.get_Parent().get_Children().Remove(node);
     V_0       = this.logicalContext.get_CFGBlockToLogicalConstructMap().get_Item(node.get_TheBlock());
     if ((int)V_0.Length == 1)
     {
         if (V_0[0] != node)
         {
             throw new Exception("Logical tree is inconsistent.");
         }
         dummyVar1 = this.logicalContext.get_CFGBlockToLogicalConstructMap().Remove(node.get_TheBlock());
     }
     V_1 = new CFGBlockLogicalConstruct[(int)V_0.Length - 1];
     V_2 = 0;
     V_3 = 0;
     while (V_2 < (int)V_0.Length)
     {
         if (V_0[V_2] != node)
         {
             if (V_3 == (int)V_0.Length)
             {
                 throw new Exception("Logical tree is inconsistent.");
             }
             V_1[V_3] = V_0[V_2];
         }
         else
         {
             V_3 = V_3 - 1;
         }
         V_2 = V_2 + 1;
         V_3 = V_3 + 1;
     }
     this.logicalContext.get_CFGBlockToLogicalConstructMap().set_Item(node.get_TheBlock(), V_1);
     return;
 }
 private CFGBlockLogicalConstruct ProcessFinallyNode(CFGBlockLogicalConstruct finallyBlockEntry, CFGBlockLogicalConstruct finallyBlockEnd)
 {
     V_1 = finallyBlockEntry.get_SameParentPredecessors().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = (ILogicalConstruct)V_1.get_Current();
             if (this.newTryBody.Contains(V_2))
             {
                 continue;
             }
             throw new Exception("Invalid entry to the finally block");
         }
     }
     finally
     {
         ((IDisposable)V_1).Dispose();
     }
     V_3 = finallyBlockEnd.get_CFGSuccessors().GetEnumerator();
     try
     {
         dummyVar0 = V_3.MoveNext();
         V_0       = V_3.get_Current();
         if (V_3.MoveNext())
         {
             throw new Exception("Invalid count of successors");
         }
     }
     finally
     {
         if (V_3 != null)
         {
             V_3.Dispose();
         }
     }
     V_4 = (new HashSet <CFGBlockLogicalConstruct>(finallyBlockEntry.get_CFGPredecessors())).GetEnumerator();
     try
     {
         while (V_4.MoveNext())
         {
             V_5 = V_4.get_Current();
             if (InstructionBlock.op_Inequality(V_5.get_TheBlock(), finallyBlockEntry.get_TheBlock()) && (int)V_5.get_TheBlock().get_Successors().Length > 1)
             {
                 this.ProcessMultiWayCFGPredecessor(finallyBlockEntry, V_5.get_TheBlock(), V_0.get_TheBlock());
             }
             V_6 = V_5;
             while (V_6 != finallyBlockEntry.get_Parent())
             {
                 dummyVar1 = V_6.RemoveFromSuccessors(finallyBlockEntry);
                 V_6.AddToSuccessors(V_0);
                 V_6 = V_6.get_Parent() as LogicalConstructBase;
             }
             V_0.AddToPredecessors(V_5);
             dummyVar2 = finallyBlockEntry.RemoveFromPredecessors(V_5);
         }
     }
     finally
     {
         ((IDisposable)V_4).Dispose();
     }
     dummyVar3 = V_0.RemoveFromPredecessors(finallyBlockEnd);
     dummyVar4 = finallyBlockEnd.RemoveFromSuccessors(V_0);
     return(V_0);
 }