Table of Contents

Interface IStatementTransform

Namespace
ICSharpCode.Decompiler.IL.Transforms
Assembly
ICSharpCode.Decompiler.dll

IL transform that runs on a sequence of statements within a block.

public interface IStatementTransform

Remarks

Interleaving different statement-combining transforms on a per-statement level improves detection of nested constructs. For example, array initializers can assume that each element assignment was already reduced to a single statement, even if the element contains a high-level construct detected by a different transform (e.g. object initializer).

Methods

Run(Block, int, StatementTransformContext)

Runs the transform on the statements within a block.

Note: the transform may only modify block.Instructions[pos..]. The transform will be called repeatedly for pos=block.Instructions.Count-1, pos=block.Instructions.Count-2, ..., pos=0.

void Run(Block block, int pos, StatementTransformContext context)

Parameters

block Block

The current block.

pos int

The starting position where the transform is allowed to work.

context StatementTransformContext

Additional parameters.

Remarks

Instructions prior to block.Instructions[pos] must not be modified. It is valid to read such instructions, but not recommended as those have not been transformed yet.

This function is only called on control-flow blocks with unreachable end-point. Thus, the last instruction in the block always must have the EndPointUnreachable flag. ==> Instructions with reachable end can't be last. Some transforms use this to save some bounds checks.