Table of Contents

Namespace ICSharpCode.Decompiler.IL.Transforms

Classes

AssignVariableNames
BlockILTransform

IL transform that runs a list of per-block transforms.

BlockTransformContext

Parameter class holding various arguments for Run(Block, BlockTransformContext).

CachedDelegateInitialization
CopyPropagation

Runs a very simple form of copy propagation. Copy propagation is used in two cases:

  1. assignments from arguments to local variables If the target variable is assigned to only once (so always is that argument) and the argument is never changed (no ldarga/starg), then we can replace the variable with the argument.
  2. assignments of address-loading instructions to local variables
DelegateConstruction

Transforms anonymous methods and lambdas by creating nested ILFunctions.

DetectCatchWhenConditionBlocks
DynamicCallSiteTransform

Transforms the "callsite initialization pattern" into DynamicInstructions.

DynamicIsEventAssignmentTransform
EarlyExpressionTransforms
ExpressionTransforms

Collection of transforms that detect simple expression patterns (e.g. 'cgt.un(..., ld.null)') and replace them with different instructions.

FixLoneIsInst

C# cannot represent isinst T directly for value-types. This transform un-inlines the argument of isinst instructions that can't be directly translated to C#, thus allowing the emulation via "expr is T ? (T)expr : null".

FixRemainingIncrements
HighLevelLoopTransform

If possible, transforms plain ILAst loops into while (condition), do-while and for-loops. For the invariants of the transforms CheckInvariant(ILPhase).

ILInlining

Performs inlining transformations.

ILTransformContext

Parameter class holding various arguments for Run(ILFunction, ILTransformContext).

InterpolatedStringTransform
LocalFunctionDecompiler

Decompiler step for C# 7.0 local functions

LockTransform
NamedArgumentTransform
NullCoalescingTransform

Transform for constructing the NullCoalescingInstruction (if.notnull(a,b), or in C#: ??) Note that this transform only handles the case where a,b are reference types.

The ?? operator for nullable value types is handled by NullableLiftingTransform.

NullPropagationStatementTransform
NullableLiftingStatementTransform
RemoveDeadVariableInit

Remove HasInitialValue from locals that are definitely assigned before every use (=the initial value is a dead store).

In yield return generators, additionally removes dead 'V = null;' assignments.

Additionally infers IType of stack slots that have StackType.Ref

SplitVariables

Live range splitting for IL variables.

StatementTransform

Block transform that runs a list of statement transforms.

StatementTransformContext

Parameter class holding various arguments for Run(Block, int, StatementTransformContext).

StepLimitReachedException

Exception thrown when an IL transform runs into the StepLimit.

Stepper

Helper class that manages recording transform steps.

Stepper.Node
SwitchOnNullableTransform

Detects switch-on-nullable patterns employed by the C# compiler and transforms them to an ILAst-switch-instruction.

SwitchOnStringTransform

Detects switch-on-string patterns employed by the C# compiler and transforms them to an ILAst-switch-instruction.

TransformArrayInitializers

Transforms array initialization pattern of System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray. For collection and object initializers see TransformCollectionAndObjectInitializers

TransformAssignment

Constructs compound assignments and inline assignments.

TransformCollectionAndObjectInitializers

Transforms collection and object initialization patterns.

TransformDisplayClassUsage

Transforms closure fields to local variables.

This is a post-processing step of DelegateConstruction, LocalFunctionDecompiler and TransformExpressionTrees.

In general we can perform SROA (scalar replacement of aggregates) on any variable that satisfies the following conditions:

  1. It is initialized by an empty/default constructor call.
  2. The variable is never passed to another method.
  3. The variable is never the target of an invocation.

Note that 2) and 3) apply because declarations and uses of lambdas and local functions are already transformed by the time this transform is applied.

TransformExpressionTrees

Converts LINQ Expression Trees to ILFunctions/ILAst instructions.

We build a tree of Func{ILInstruction}s, which are only executed, if the whole transform succeeds.

UserDefinedLogicTransform
UsingTransform

Structs

AccessPathElement

Interfaces

IBlockTransform

Per-block IL transform.

IILTransform

Per-function IL transform.

IStatementTransform

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

Enums

AccessPathKind
InliningOptions