C# Класс CK.Reflection.ILGeneratorExtension

Provides extension methods on ILGenerator class.
Показать файл Открыть проект

Открытые методы

Метод Описание
CreateObjectArrayFromInstanceParameters ( this g, LocalBuilder array, Type parameters ) : void

Emits the IL to create a new array (OpCodes.Newarr) of objects and fills it with the actual arguments of the method (parameters are boxed if needed) skipping the very first one: this must be used only inside a method with System.Reflection.CallingConventions.HasThis set.

LdArg ( this g, int i ) : void

Emits the IL to push (OpCodes.Ldarg) the actual argument at the given index onto the stack.

LdArgBox ( this g, ParameterInfo p ) : void

Emits a LdArg with an optional OpCodes.Box if p's type is a value type or a generic parameter (after a OpCodes.Ldobj if the parameter is by ref). Handles static or instance methods (takes care of System.Reflection.CallingConventions.HasThis bit of the method's CallingConvention).

LdArgBox ( this g, int idxParameter, Type parameterType ) : void

Emits a LdArg with a OpCodes.Box if parameterType is a value type or a generic parameter (after a OpCodes.Ldobj if the parameter is by ref).

LdInt32 ( this g, int i ) : void

Emits the IL to push the integer (emits the best opcode depending on the value: OpCodes.Ldc_I4_0 or OpCodes.Ldc_I4_M1 for instance) value onto the stack.

LdLoc ( this g, LocalBuilder local ) : void

Emits the IL to push (OpCodes.Ldloc) the given local on top of the stack.

RepushActualParameters ( this g, bool startAtArgument0, int count ) : void

Emits the optimal IL to push the actual parameter values on the stack (OpCodes.Ldarg_0... OpCodes.Ldarg).

StArg ( this g, int i ) : void

Emits the IL to pop (OpCodes.Starg) the top of the stack into the actual argument at the given index.

StLoc ( this g, LocalBuilder local ) : void

Emits the IL to pop (OpCodes.Stloc) the top of the stack into a local variable.

StoreDefaultValueForOutParameter ( this g, ParameterInfo byRefParameter ) : void

Emits code that sets the parameter (that must be a 'ref' or 'out' parameter) to the default of its type. Handles static or instance methods and value or reference type.

Описание методов

CreateObjectArrayFromInstanceParameters() публичный статический Метод

Emits the IL to create a new array (OpCodes.Newarr) of objects and fills it with the actual arguments of the method (parameters are boxed if needed) skipping the very first one: this must be used only inside a method with System.Reflection.CallingConventions.HasThis set.
public static CreateObjectArrayFromInstanceParameters ( this g, LocalBuilder array, Type parameters ) : void
g this This object.
array System.Reflection.Emit.LocalBuilder The local variable.
parameters System.Type Type of the method parameters.
Результат void

LdArg() публичный статический Метод

Emits the IL to push (OpCodes.Ldarg) the actual argument at the given index onto the stack.
public static LdArg ( this g, int i ) : void
g this This object.
i int Parameter index (0 being the 'this' for instance method).
Результат void

LdArgBox() публичный статический Метод

Emits a LdArg with an optional OpCodes.Box if p's type is a value type or a generic parameter (after a OpCodes.Ldobj if the parameter is by ref). Handles static or instance methods (takes care of System.Reflection.CallingConventions.HasThis bit of the method's CallingConvention).
public static LdArgBox ( this g, ParameterInfo p ) : void
g this This object.
p System.Reflection.ParameterInfo Parameter of the current method.
Результат void

LdArgBox() публичный статический Метод

Emits a LdArg with a OpCodes.Box if parameterType is a value type or a generic parameter (after a OpCodes.Ldobj if the parameter is by ref).
public static LdArgBox ( this g, int idxParameter, Type parameterType ) : void
g this This object.
idxParameter int Index of the parameter to load on the stack.
parameterType System.Type Type of the parameter.
Результат void

LdInt32() публичный статический Метод

Emits the IL to push the integer (emits the best opcode depending on the value: OpCodes.Ldc_I4_0 or OpCodes.Ldc_I4_M1 for instance) value onto the stack.
public static LdInt32 ( this g, int i ) : void
g this This object.
i int The integer value to push.
Результат void

LdLoc() публичный статический Метод

Emits the IL to push (OpCodes.Ldloc) the given local on top of the stack.
public static LdLoc ( this g, LocalBuilder local ) : void
g this This object.
local System.Reflection.Emit.LocalBuilder The local variable to push.
Результат void

RepushActualParameters() публичный статический Метод

Emits the optimal IL to push the actual parameter values on the stack (OpCodes.Ldarg_0... OpCodes.Ldarg).
public static RepushActualParameters ( this g, bool startAtArgument0, int count ) : void
g this This object.
startAtArgument0 bool False to skip the very first argument: for a method instance Arg0 is the 'this' object (see ) HasThis and ExplicitThis).
count int Number of parameters to push.
Результат void

StArg() публичный статический Метод

Emits the IL to pop (OpCodes.Starg) the top of the stack into the actual argument at the given index.
public static StArg ( this g, int i ) : void
g this This object.
i int Parameter index (0 being the 'this' for instance method).
Результат void

StLoc() публичный статический Метод

Emits the IL to pop (OpCodes.Stloc) the top of the stack into a local variable.
public static StLoc ( this g, LocalBuilder local ) : void
g this This object.
local System.Reflection.Emit.LocalBuilder The local variable to pop.
Результат void

StoreDefaultValueForOutParameter() публичный статический Метод

Emits code that sets the parameter (that must be a 'ref' or 'out' parameter) to the default of its type. Handles static or instance methods and value or reference type.
public static StoreDefaultValueForOutParameter ( this g, ParameterInfo byRefParameter ) : void
g this This object.
byRefParameter System.Reflection.ParameterInfo The 'by ref' parameter.
Результат void