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;
 }
 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 bool IsUnconditionJumpBlock(InstructionBlock block)
 {
     if ((object)block.get_First() != (object)block.get_Last() || block.get_First().get_OpCode().get_Code() != 55 && block.get_First().get_OpCode().get_Code() != 42)
     {
         return(false);
     }
     return((int)block.get_Successors().Length == 1);
 }
 public AssignmentFlowNode(InstructionBlock theBlock)
 {
     base();
     this.set_CFGBlock(theBlock);
     this.set_NodeState(0);
     this.set_Successors(new AssignmentFlowNode[(int)theBlock.get_Successors().Length]);
     return;
 }
Ejemplo n.º 5
0
 private static InstructionBlock SkipSingleNopInstructionBlock(InstructionBlock theBlock)
 {
     V_0 = theBlock;
     if ((object)theBlock.get_First() == (object)theBlock.get_Last() && theBlock.get_First().get_OpCode().get_Code() == null && (int)theBlock.get_Successors().Length == 1)
     {
         V_0 = theBlock.get_Successors()[0];
     }
     return(V_0);
 }
 protected InstructionBlock SkipBranchChain(InstructionBlock initialBlock)
 {
     V_0 = initialBlock;
     while (this.IsUnconditionalBranchBlock(V_0))
     {
         V_0 = V_0.get_Successors()[0];
     }
     return(V_0);
 }
 private InstructionBlock MarkSecondSuccessorForRemovalIfItIsUnconditionalJump(InstructionBlock block)
 {
     V_0 = block.get_Successors()[1];
     if (this.IsUnconditionJumpBlock(V_0))
     {
         block.RemoveFromSuccessors(V_0);
         block.AddToSuccessors(V_0.get_Successors()[0]);
         this.blocksToBeRemoved.Add(V_0.get_First().get_Offset());
         V_0 = V_0.get_Successors()[0];
     }
     return(V_0);
 }
 private void MarkOptimizationAndCaseBlocks(InstructionBlock block, RemoveCompilerOptimizationsStep.SwitchData data)
 {
     V_0 = new Queue <InstructionBlock>();
     V_1 = new HashSet <int>();
     V_2 = block.get_Successors();
     V_3 = 0;
     while (V_3 < (int)V_2.Length)
     {
         V_0.Enqueue(V_2[V_3]);
         V_3 = V_3 + 1;
     }
     while (V_0.get_Count() > 0)
     {
         V_5       = V_0.Dequeue();
         dummyVar0 = V_1.Add(V_5.get_First().get_Offset());
         if (!this.IsOptimizationBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_OptimizationVariable()))
         {
             if (!this.IsCaseBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_SwitchExpression()) && !this.IsNullCaseBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_SwitchExpression()))
             {
                 continue;
             }
             this.switchBlocksToCasesMap.get_Item(block.get_First().get_Offset()).Add(V_5.get_First().get_Offset());
             V_8 = V_5.get_Successors()[1];
             if (this.IsEmptyStringCaseBlock(this.blockExpressions.get_Item(V_8.get_First().get_Offset()), data.get_SwitchExpression()))
             {
                 V_5.set_Last(V_8.get_Last());
                 V_5.set_Successors(V_8.get_Successors());
                 V_9 = this.blockExpressions.get_Item(V_5.get_First().get_Offset()).get_Item(0) as BinaryExpression;
                 V_9.set_Right(new LiteralExpression("", this.methodContext.get_Method().get_Module().get_TypeSystem(), null));
                 V_10 = this.blockExpressions.get_Item(V_8.get_First().get_Offset()).get_Item(0).get_UnderlyingSameMethodInstructions();
                 V_9  = V_9.CloneAndAttachInstructions(V_10) as BinaryExpression;
                 this.blockExpressions.get_Item(V_5.get_First().get_Offset()).set_Item(0, new UnaryExpression(11, V_9, null));
                 this.blocksToBeRemoved.Add(V_8.get_First().get_Offset());
             }
             dummyVar1 = this.MarkSecondSuccessorForRemovalIfItIsUnconditionalJump(V_5);
         }
         else
         {
             V_6 = V_5.get_Successors()[0];
             if (!V_1.Contains(V_6.get_First().get_Offset()))
             {
                 V_0.Enqueue(V_6);
             }
             V_7 = this.MarkSecondSuccessorForRemovalIfItIsUnconditionalJump(V_5);
             if (!V_1.Contains(V_7.get_First().get_Offset()) && this.IsOptimizationBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_OptimizationVariable()))
             {
                 V_0.Enqueue(V_7);
             }
             this.blocksToBeRemoved.Add(V_5.get_First().get_Offset());
         }
     }
     return;
 }
		private void RecursiveDfs(InstructionBlock currentBlock, int[] initialStack)
		{
			this.traversed[currentBlock.get_Index()] = true;
			this.blockToInitialStackMap[currentBlock.get_Index()] = initialStack;
			this.ComputeStackUsage(currentBlock);
			V_0 = this.blockToExitStackMap[currentBlock.get_Index()];
			V_1 = currentBlock.get_Successors();
			V_2 = 0;
			while (V_2 < (int)V_1.Length)
			{
				V_3 = V_1[V_2];
				if (this.traversed[V_3.get_Index()])
				{
					this.UpdateCurrentStackVariables(currentBlock, V_3);
				}
				else
				{
					this.RecursiveDfs(V_3, V_0);
				}
				V_2 = V_2 + 1;
			}
			return;
		}
Ejemplo n.º 10
0
 protected override StateControllerRemover.ControllerTraversalSearchResult TryGetStateEntry(InstructionBlock theBlock, out InstructionBlock actualSuccessor)
 {
     actualSuccessor = this.SkipBranchChain(theBlock);
     if (!this.IsDisposingBlock(actualSuccessor))
     {
         return(2);
     }
     dummyVar0 = this.toBeRemoved.Add(actualSuccessor);
     if (!this.IsFalseReturnBlock(actualSuccessor.get_Successors()[1]))
     {
         if (!this.IsFalseReturnBlock(actualSuccessor.get_Successors()[0]))
         {
             return(0);
         }
         dummyVar2       = this.toBeRemoved.Add(actualSuccessor.get_Successors()[0]);
         actualSuccessor = actualSuccessor.get_Successors()[1];
     }
     else
     {
         dummyVar1       = this.toBeRemoved.Add(actualSuccessor.get_Successors()[1]);
         actualSuccessor = actualSuccessor.get_Successors()[0];
     }
     return(1);
 }