当前位置: 首页>>代码示例>>C#>>正文


C# BasicBlock.Delete方法代码示例

本文整理汇总了C#中BasicBlock.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# BasicBlock.Delete方法的具体用法?C# BasicBlock.Delete怎么用?C# BasicBlock.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BasicBlock的用法示例。


在下文中一共展示了BasicBlock.Delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryReduceJump

 private string TryReduceJump(BasicBlock root, JumpBasicBlock jumpbb)
 {
     // Try to find a linear chain of branches of length > 1
     var group = new Set<BasicBlock> { jumpbb };
     var chain = new Seq<BasicBlock> { jumpbb };
     var start = jumpbb;
     while (start.Sources.Count == 1 && start.Sources[0] is JumpBasicBlock &&
            !group.Contains(start.Sources[0]))
     {
         // Extend chain upwards
         start = (JumpBasicBlock)start.Sources[0];
         group.Add(start);
         chain.Insert(0, start);
     }
     var endjump = jumpbb;
     while (endjump.Target.Sources.Count == 1 && endjump.Target is JumpBasicBlock && !group.Contains(endjump.Target))
     {
         // Extend chain downwards
         endjump = (JumpBasicBlock)endjump.Target;
         group.Add(endjump);
         chain.Add(endjump);
     }
     var end = (BasicBlock)endjump;
     if (endjump.Target.Sources.Count == 1 && endjump.Target.AcceptsInstructions && !group.Contains(endjump.Target))
     {
         // Extend chain downwards to include a final non jump basic block, provided we can put all
         // the accumulated instructions there
         end = endjump.Target;
         group.Add(end);
         chain.Add(end);
     }
     if (chain.Count > 1)
     {
         // Coalesce and peephole
         var instructions = new Seq<Instruction>();
         foreach (var bb in chain)
             bb.Block.AccumInstructions(instructions);
         var newbb = end.CloneWithInstructions(nextBlockId++, Peephole(chain[0].Block.BeforeState, instructions));
         root.Coalesce(start, group, newbb);
         return String.Format("collapsed chain of {0} jump blocks from B{1}", chain.Count, start.Id); 
     }
     else if (start.Block.Count == 0 && !start.Target.Equals(start))
     {
         // Short-circuit a trivial jump
         root.Delete(start);
         return String.Format("short-circuited trivial jump at B{0}", start.Id);
     }
     else if (start.Target.Equals(start))
     {
         // loop
         var li = new LoopInstruction(NextInstructionId--, start.Block)
                   { BeforeState = jumpbb.Block.BeforeState, AfterState = jumpbb.Block.AfterState };
         var newbb = new NonReturningBasicBlock(nextBlockId++, new Instructions(li));
         root.Coalesce(start, new Set<BasicBlock> { start }, newbb);
         return String.Format("trival loop at B{0}", start.Id);
     }
     else
         return null;
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:59,代码来源:ControlFlowRecovery.cs


注:本文中的BasicBlock.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。