Table of Contents

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

SlotInfo

InstructionSlot

public static readonly SlotInfo InstructionSlot

Field Value

SlotInfo

Instructions

public readonly InstructionCollection<ILInstruction> Instructions

Field Value

InstructionCollection<ILInstruction>

Kind

public readonly BlockKind Kind

Field Value

BlockKind

Properties

DirectFlags

Gets the flags for this instruction only, without considering the child instructions.

public override InstructionFlags DirectFlags { get; }

Property Value

InstructionFlags

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

ILInstruction

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

int

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

string

ResultType

Gets the stack type of the value produced by this instruction.

public override StackType ResultType { get; }

Property Value

StackType

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

ILInstruction

ComputeFlags()

protected override InstructionFlags ComputeFlags()

Returns

InstructionFlags

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

Block

GetChild(int)

protected override ILInstruction GetChild(int index)

Parameters

index int

Returns

ILInstruction

GetChildCount()

protected override int GetChildCount()

Returns

int

GetChildSlot(int)

protected override SlotInfo GetChildSlot(int index)

Parameters

index int

Returns

SlotInfo

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

ILInstruction

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 ILInstruction
trueInst ILInstruction
falseInst ILInstruction

Returns

bool

MatchInlineAssignBlock(out CallInstruction?, out ILInstruction?)

public bool MatchInlineAssignBlock(out CallInstruction? call, out ILInstruction? value)

Parameters

call CallInstruction
value ILInstruction

Returns

bool

PerformMatch(ILInstruction?, ref Match)

protected override bool PerformMatch(ILInstruction? other, ref Match match)

Parameters

other ILInstruction
match Match

Returns

bool

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 int
value 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

ILInstruction

WriteTo(ITextOutput, ILAstWritingOptions)

Writes the ILAst to the text output.

public override void WriteTo(ITextOutput output, ILAstWritingOptions options)

Parameters

output ITextOutput
options ILAstWritingOptions