Class Block
- Namespace
- ICSharpCode.Decompiler.IL
- Assembly
- ICSharpCode.Decompiler.dll
A block of IL instructions.
public sealed class Block : ILInstruction
- Inheritance
-
Block
- Inherited Members
Constructors
Block(BlockKind)
public Block(BlockKind kind = BlockKind.ControlFlow)
Parameters
kind
BlockKind
Fields
FinalInstructionSlot
public static readonly SlotInfo FinalInstructionSlot
Field Value
InstructionSlot
public static readonly SlotInfo InstructionSlot
Field Value
Instructions
public readonly InstructionCollection<ILInstruction> Instructions
Field Value
Kind
public readonly BlockKind Kind
Field Value
Properties
DirectFlags
Gets the flags for this instruction only, without considering the child instructions.
public override InstructionFlags DirectFlags { get; }
Property Value
FinalInstruction
A 'final instruction' that gets executed after the Instructions
collection.
Provides the return value for the block.
public ILInstruction FinalInstruction { get; set; }
Property Value
Remarks
Blocks in containers must have 'Nop' as a final instruction.
Note that the FinalInstruction is included in Block.Children, but not in Block.Instructions!
IncomingEdgeCount
For blocks in a block container, this field holds the number of incoming control flow edges to this block.
public int IncomingEdgeCount { get; }
Property Value
Remarks
This variable is automatically updated when adding/removing branch instructions from the ILAst, or when adding the block as an entry point to a BlockContainer.
Label
Gets the name of this block.
public string Label { get; }
Property Value
ResultType
Gets the stack type of the value produced by this instruction.
public override StackType ResultType { get; }
Property Value
Methods
AcceptVisitor(ILVisitor)
Calls the Visit*-method on the visitor corresponding to the concrete type of this instruction.
public override void AcceptVisitor(ILVisitor visitor)
Parameters
visitor
ILVisitor
AcceptVisitor<T>(ILVisitor<T>)
Calls the Visit*-method on the visitor corresponding to the concrete type of this instruction.
public override T AcceptVisitor<T>(ILVisitor<T> visitor)
Parameters
visitor
ILVisitor<T>
Returns
- T
Type Parameters
T
AcceptVisitor<C, T>(ILVisitor<C, T>, C)
Calls the Visit*-method on the visitor corresponding to the concrete type of this instruction.
public override T AcceptVisitor<C, T>(ILVisitor<C, T> visitor, C context)
Parameters
visitor
ILVisitor<C, T>context
C
Returns
- T
Type Parameters
C
T
Clone()
public override ILInstruction Clone()
Returns
ComputeFlags()
protected override InstructionFlags ComputeFlags()
Returns
FindClosestBlock(ILInstruction?)
Gets the closest parent Block. Returns null, if the instruction is not a descendant of a Block.
public static Block? FindClosestBlock(ILInstruction? inst)
Parameters
inst
ILInstruction
Returns
GetChild(int)
protected override ILInstruction GetChild(int index)
Parameters
index
int
Returns
GetChildCount()
protected override int GetChildCount()
Returns
GetChildSlot(int)
protected override SlotInfo GetChildSlot(int index)
Parameters
index
int
Returns
GetPredecessor(ILInstruction)
Gets the predecessor of the given instruction. Returns null if inst.Parent is not a block.
public static ILInstruction? GetPredecessor(ILInstruction inst)
Parameters
inst
ILInstruction
Returns
InstructionCollectionUpdateComplete()
Called when a series of add/remove operations on the InstructionCollection is complete.
protected override void InstructionCollectionUpdateComplete()
MatchIfAtEndOfBlock(out ILInstruction?, out ILInstruction?, out ILInstruction?)
public bool MatchIfAtEndOfBlock(out ILInstruction? condition, out ILInstruction? trueInst, out ILInstruction? falseInst)
Parameters
condition
ILInstructiontrueInst
ILInstructionfalseInst
ILInstruction
Returns
MatchInlineAssignBlock(out CallInstruction?, out ILInstruction?)
public bool MatchInlineAssignBlock(out CallInstruction? call, out ILInstruction? value)
Parameters
call
CallInstructionvalue
ILInstruction
Returns
PerformMatch(ILInstruction?, ref Match)
protected override bool PerformMatch(ILInstruction? other, ref Match match)
Parameters
other
ILInstructionmatch
Match
Returns
Remove()
Deletes this block from its parent container. This may cause the indices of other blocks in that container to change.
It is an error to call this method on blocks that are not directly within a container. It is also an error to call this method on the entry-point block.
public void Remove()
RunTransforms(IEnumerable<IBlockTransform>, BlockTransformContext)
Apply a list of transforms to this function.
public void RunTransforms(IEnumerable<IBlockTransform> transforms, BlockTransformContext context)
Parameters
transforms
IEnumerable<IBlockTransform>context
BlockTransformContext
SetChild(int, ILInstruction)
protected override void SetChild(int index, ILInstruction value)
Parameters
index
intvalue
ILInstruction
Unwrap(ILInstruction?)
If inst is a block consisting of a single instruction, returns that instruction. Otherwise, returns the input instruction.
public static ILInstruction? Unwrap(ILInstruction? inst)
Parameters
inst
ILInstruction
Returns
WriteTo(ITextOutput, ILAstWritingOptions)
Writes the ILAst to the text output.
public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
Parameters
output
ITextOutputoptions
ILAstWritingOptions