Table of Contents

Class CilInstructionExtensions

Namespace
AsmResolver.DotNet.Code.Cil
Assembly
AsmResolver.DotNet.dll

Provides extensions to the CilInstruction class.

public static class CilInstructionExtensions
Inheritance
CilInstructionExtensions
Inherited Members

Methods

GetLocalVariable(CilInstruction, IList<CilLocalVariable>)

When this instruction is using a variant of the ldloc or stloc opcodes, gets the local variable that is referenced by the instruction.

public static CilLocalVariable GetLocalVariable(this CilInstruction instruction, IList<CilLocalVariable> variables)

Parameters

instruction CilInstruction

The instruction.

variables IList<CilLocalVariable>

The local variables defined in the enclosing method body.

Returns

CilLocalVariable

The variable.

Exceptions

ArgumentException

Occurs when the instruction is not using a variant of the ldloc or stloc opcodes.

GetParameter(CilInstruction, ParameterCollection)

When this instruction is using a variant of the ldarg or starg opcodes, gets the parameter that is referenced by the instruction.

public static Parameter GetParameter(this CilInstruction instruction, ParameterCollection parameters)

Parameters

instruction CilInstruction

The instruction.

parameters ParameterCollection

The parameters defined in the enclosing method body.

Returns

Parameter

The parameter.

Exceptions

ArgumentException

Occurs when the instruction is not using a variant of the ldarg or starg opcodes.

GetStackPopCount(CilInstruction, CilMethodBody?)

Determines the number of values that are popped from the stack by this instruction.

public static int GetStackPopCount(this CilInstruction instruction, CilMethodBody? parent)

Parameters

instruction CilInstruction

The instruction.

parent CilMethodBody

The method body that this instruction resides in. When passed on null, a method body of a System.Void method is assumed.

Returns

int

The number of values popped from the stack.

Exceptions

ArgumentOutOfRangeException

Occurs when the instruction's operation code provides an invalid stack behaviour.

GetStackPopCount(CilInstruction, bool)

Determines the number of values that are popped from the stack by this instruction.

public static int GetStackPopCount(this CilInstruction instruction, bool isVoid)

Parameters

instruction CilInstruction

The instruction.

isVoid bool

A value indicating whether the enclosing method is returning System.Void or not.

Returns

int

The number of values popped from the stack.

Exceptions

ArgumentOutOfRangeException

Occurs when the instruction's operation code provides an invalid stack behaviour.

GetStackPushCount(CilInstruction)

Determines the number of values that are pushed onto the stack by this instruction.

public static int GetStackPushCount(this CilInstruction instruction)

Parameters

instruction CilInstruction

The instruction.

Returns

int

The number of values pushed onto the stack.

Exceptions

ArgumentOutOfRangeException

Occurs when the instruction's operation code provides an invalid stack behaviour.