Class ILFunction
- Namespace
- ICSharpCode.Decompiler.IL
- Assembly
- ICSharpCode.Decompiler.dll
A container of IL blocks.
public sealed class ILFunction : ILInstruction
- Inheritance
-
ILFunction
- Inherited Members
Constructors
ILFunction(IMethod, int, GenericContext, ILInstruction, ILFunctionKind)
Constructs a new ILFunction from the given metadata and with the given ILAst body.
public ILFunction(IMethod method, int codeSize, GenericContext genericContext, ILInstruction body, ILFunctionKind kind = ILFunctionKind.TopLevelFunction)
Parameters
method
IMethodcodeSize
intgenericContext
GenericContextbody
ILInstructionkind
ILFunctionKind
Remarks
Use ILReader to create ILAst.
Fields
AsyncDebugInfo
public AsyncDebugInfo AsyncDebugInfo
Field Value
AsyncReturnType
Return element type -- if the async method returns Task{T}, this field stores T. If the async method returns Task or void, this field stores void.
public IType? AsyncReturnType
Field Value
BodySlot
public static readonly SlotInfo BodySlot
Field Value
CodeSize
Size of the IL code in this function. Note: after async/await transform, this is the code size of the MoveNext function.
public int CodeSize
Field Value
DelegateType
If this is an expression tree or delegate, returns the expression tree type Expression{T} or T. T is the delegate type that matches the signature of this method. Otherwise this must be null.
public IType? DelegateType
Field Value
GenericContext
Gets the generic context of this function.
public readonly GenericContext GenericContext
Field Value
IsIterator
Gets whether this function is a decompiled iterator (is using yield). This flag gets set by the YieldReturnDecompiler.
If set, the 'return' instruction has the semantics of 'yield break;' instead of a normal return.
public bool IsIterator
Field Value
LocalFunctionsSlot
public static readonly SlotInfo LocalFunctionsSlot
Field Value
Method
Gets the method definition from metadata. May be null for functions that were not constructed from metadata, e.g., expression trees.
public readonly IMethod? Method
Field Value
MoveNextMethod
If this function is an iterator/async, this field stores the compiler-generated MoveNext() method.
public IMethod? MoveNextMethod
Field Value
Name
Gets the name of this function, usually this returns the name from metadata.
For local functions: This is the name that is used to declare and use the function. It may not conflict with the names of local variables of ancestor functions and may be overwritten by the AssignVariableNames step.
For top-level functions, delegates and expressions trees modifying this usually has no effect, as the name should not be used in the final AST construction.
public string? Name
Field Value
Parameters
List of parameters of this function.
public readonly IReadOnlyList<IParameter> Parameters
Field Value
ReturnType
Return type of this function.
public readonly IType ReturnType
Field Value
StateMachineCompiledWithLegacyVisualBasic
Gets whether the YieldReturnDecompiler determined that the Legacy VB compiler was used to compile this function.
public bool StateMachineCompiledWithLegacyVisualBasic
Field Value
StateMachineCompiledWithMono
Gets whether the YieldReturnDecompiler determined that the Mono C# compiler was used to compile this function.
public bool StateMachineCompiledWithMono
Field Value
Variables
List of ILVariables used in this function.
public readonly ILVariableCollection Variables
Field Value
Properties
Body
public ILInstruction Body { get; set; }
Property Value
CapturedVariables
Gets the set of captured variables by this ILFunction.
public HashSet<ILVariable> CapturedVariables { get; }
Property Value
Remarks
This is populated by the TransformDisplayClassUsage step.
DeclarationScope
Gets the scope in which the local function is declared. Returns null, if this is not a local function.
public BlockContainer? DeclarationScope { get; }
Property Value
DirectFlags
Gets the flags for this instruction only, without considering the child instructions.
public override InstructionFlags DirectFlags { get; }
Property Value
IsAsync
Gets whether this function is async. This flag gets set by the AsyncAwaitDecompiler.
public bool IsAsync { get; }
Property Value
Kind
Gets which kind of function this is.
public ILFunctionKind Kind { get; }
Property Value
LocalFunctions
public InstructionCollection<ILFunction> LocalFunctions { get; }
Property Value
ResultType
Gets the stack type of the value produced by this instruction.
public override StackType ResultType { get; }
Property Value
SequencePointCandidates
List of candidate locations for sequence points. Includes any offset where the stack is empty, nop instructions, and the instruction following a call instruction
public List<int>? SequencePointCandidates { get; set; }
Property Value
Warnings
List of warnings of ILReader.
public List<string> Warnings { 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 sealed ILInstruction Clone()
Returns
ComputeFlags()
protected override InstructionFlags ComputeFlags()
Returns
GetChild(int)
protected override sealed ILInstruction GetChild(int index)
Parameters
index
int
Returns
GetChildCount()
protected override sealed int GetChildCount()
Returns
GetChildSlot(int)
protected override sealed SlotInfo GetChildSlot(int index)
Parameters
index
int
Returns
PerformMatch(ILInstruction?, ref Match)
protected override bool PerformMatch(ILInstruction? other, ref Match match)
Parameters
other
ILInstructionmatch
Match
Returns
RegisterVariable(VariableKind, IType, string?)
public ILVariable RegisterVariable(VariableKind kind, IType type, string? name = null)
Parameters
kind
VariableKindtype
ITypename
string
Returns
RunTransforms(IEnumerable<IILTransform>, ILTransformContext)
Apply a list of transforms to this function.
public void RunTransforms(IEnumerable<IILTransform> transforms, ILTransformContext context)
Parameters
transforms
IEnumerable<IILTransform>context
ILTransformContext
SetChild(int, ILInstruction)
protected override sealed void SetChild(int index, ILInstruction value)
Parameters
index
intvalue
ILInstruction
WriteTo(ITextOutput, ILAstWritingOptions)
Writes the ILAst to the text output.
public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
Parameters
output
ITextOutputoptions
ILAstWritingOptions