/// <summary> /// Generates the finally block. /// </summary> /// <remarks> /// Since the condition block and the dispose invocation block should have a common successor, a new EmptyBlockLogicalConstruct /// is added to the logical tree. /// </remarks> /// <returns></returns> private BlockLogicalConstruct GenerateFinallyBlock() { CFGBlockLogicalConstruct finallySuccessor = ProcessFinallyNode(finallyEntryBlock, disposeCallBlock); finallySuccessor.RemoveFromPredecessors(conditionBlock); conditionBlock.RemoveFromSuccessors(finallySuccessor); EmptyBlockLogicalConstruct emptyCommonNode = new EmptyBlockLogicalConstruct(++logicalContext.MaxBlockIndex); emptyCommonNode.AddToPredecessors(disposeCallBlock); emptyCommonNode.AddToPredecessors(conditionBlock); disposeCallBlock.AddToSuccessors(emptyCommonNode); conditionBlock.AddToSuccessors(emptyCommonNode); emptyCommonNode.Parent = finallyEntryBlock.Parent; emptyCommonNode.Parent.Children.Add(emptyCommonNode); for (int i = 0; i < conditionBlock.TheBlock.Successors.Length; i++) { if (conditionBlock.TheBlock.Successors[i] == finallySuccessor.TheBlock) { conditionBlock.TheBlock.Successors[i] = null; } } finallyBlocks.Add(emptyCommonNode); return(new BlockLogicalConstruct(finallyEntryBlock, finallyBlocks)); }
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)); }
/// <summary> /// Generates the finally block. /// </summary> /// <remarks> /// Since the condition block and the dispose invocation block should have a common successor, a new EmptyBlockLogicalConstruct /// is added to the logical tree. /// </remarks> /// <returns></returns> private BlockLogicalConstruct GenerateFinallyBlock() { CFGBlockLogicalConstruct finallySuccessor = ProcessFinallyNode(finallyEntryBlock, disposeCallBlock); finallySuccessor.RemoveFromPredecessors(conditionBlock); conditionBlock.RemoveFromSuccessors(finallySuccessor); EmptyBlockLogicalConstruct emptyCommonNode = new EmptyBlockLogicalConstruct(++logicalContext.MaxBlockIndex); emptyCommonNode.AddToPredecessors(disposeCallBlock); emptyCommonNode.AddToPredecessors(conditionBlock); disposeCallBlock.AddToSuccessors(emptyCommonNode); conditionBlock.AddToSuccessors(emptyCommonNode); emptyCommonNode.Parent = finallyEntryBlock.Parent; emptyCommonNode.Parent.Children.Add(emptyCommonNode); for (int i = 0; i < conditionBlock.TheBlock.Successors.Length; i++) { if(conditionBlock.TheBlock.Successors[i] == finallySuccessor.TheBlock) { conditionBlock.TheBlock.Successors[i] = null; } } finallyBlocks.Add(emptyCommonNode); return new BlockLogicalConstruct(finallyEntryBlock, finallyBlocks); }