Class DetectExitPoints
- Namespace
- ICSharpCode.Decompiler.IL.ControlFlow
- Assembly
- ICSharpCode.Decompiler.dll
Detect suitable exit points for BlockContainers.
An "exit point" is an instruction that causes control flow to leave the container (a branch or leave instruction).
If an "exit point" instruction is placed immediately following a block container, each equivalent exit point within the container can be replaced with a "leave container" instruction.
This transform performs this replacement: any exit points equivalent to the exit point following the container are replaced with a leave instruction. Additionally, if the container is not yet followed by an exit point, but has room to introduce such an exit point (i.e. iff the container's end point is currently unreachable), we pick one of the non-return exit points within the container, move it to the position following the container, and replace all instances within the container with a leave instruction.
This makes it easier for the following transforms to construct control flow that falls out of blocks instead of using goto/break statements.
public class DetectExitPoints : ILVisitor, IILTransform
- Inheritance
-
DetectExitPoints
- Implements
- Inherited Members
Constructors
DetectExitPoints()
public DetectExitPoints()
Methods
Default(ILInstruction)
Called by Visit*() methods that were not overridden
protected override void Default(ILInstruction inst)
Parameters
inst
ILInstruction
Run(ILFunction, ILTransformContext)
public void Run(ILFunction function, ILTransformContext context)
Parameters
function
ILFunctioncontext
ILTransformContext
VisitBlock(Block)
protected override void VisitBlock(Block block)
Parameters
block
Block
VisitBlockContainer(BlockContainer)
protected override void VisitBlockContainer(BlockContainer container)
Parameters
container
BlockContainer
VisitBranch(Branch)
protected override void VisitBranch(Branch inst)
Parameters
inst
Branch
VisitLeave(Leave)
protected override void VisitLeave(Leave inst)
Parameters
inst
Leave