本文整理汇总了C#中System.Reflection.Emit.ILGenerator.EmitLoadValue方法的典型用法代码示例。如果您正苦于以下问题:C# ILGenerator.EmitLoadValue方法的具体用法?C# ILGenerator.EmitLoadValue怎么用?C# ILGenerator.EmitLoadValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.ILGenerator
的用法示例。
在下文中一共展示了ILGenerator.EmitLoadValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RestoreByReferenceArguments
/// <summary>
/// Restores the by reference arguments.
/// </summary>
/// <param name="ilGenerator">The intermediate language generator.</param>
/// <param name="parameterTypes">The parameter types.</param>
/// <param name="parametersLocalBuilder">The parameters local builder.</param>
private static void RestoreByReferenceArguments(ILGenerator ilGenerator, IList<Type> parameterTypes, LocalBuilder parametersLocalBuilder)
{
for (var index = 0; index < parameterTypes.Count; index++)
{
var argumentType = parameterTypes[index];
if (!argumentType.IsByRef)
continue;
var elementType = argumentType.GetElementType();
ilGenerator.EmitLoadArgument(index + 1);
ilGenerator.Emit(OpCodes.Ldloc, parametersLocalBuilder);
ilGenerator.EmitLoadValue(index);
ilGenerator.Emit(OpCodes.Ldelem_Ref);
ilGenerator.EmitUnbox(elementType);
ilGenerator.EmitStoreIndirect(argumentType);
}
}
示例2: RestoreByReferenceParameterValues
/// <summary>
/// Restores the by reference parameter values.
/// </summary>
/// <param name="ilGenerator">The intermediate language generator.</param>
/// <param name="argumentIndex">The argument index.</param>
/// <param name="parameterTypes">The parameter types.</param>
/// <param name="parameterValueLocalBuilders">The parameter value local builders.</param>
private static void RestoreByReferenceParameterValues(ILGenerator ilGenerator, int argumentIndex, IList<Type> parameterTypes, IList<LocalBuilder> parameterValueLocalBuilders)
{
for (var index = 0; index < parameterTypes.Count; index++)
{
var parameterType = parameterTypes[index];
if (!parameterType.IsByRef)
continue;
var parameterLocalBuilder = parameterValueLocalBuilders[index];
var elementType = parameterType.GetElementType();
ilGenerator.EmitLoadArgument(argumentIndex);
ilGenerator.EmitLoadValue(index);
ilGenerator.Emit(OpCodes.Ldloc, parameterLocalBuilder);
ilGenerator.EmitBox(elementType);
ilGenerator.Emit(OpCodes.Stelem_Ref);
}
}
示例3: LoadArguments
/// <summary>
/// Loads the arguments onto the stack.
/// </summary>
/// <param name="ilGenerator">The intermediate language generator.</param>
/// <param name="parameterTypes">The parameter types.</param>
/// <param name="parametersLocalBuilder">The parameters local builder.</param>
private static void LoadArguments(ILGenerator ilGenerator, IList<Type> parameterTypes, LocalBuilder parametersLocalBuilder)
{
for (var index = 0; index < parameterTypes.Count; index++)
{
var parameterType = parameterTypes[index];
ilGenerator.Emit(OpCodes.Ldloc, parametersLocalBuilder);
ilGenerator.EmitLoadValue(index);
ilGenerator.EmitLoadArgument(index + 1);
if (parameterType.IsByRef)
{
var elementType = parameterType.GetElementType();
ilGenerator.EmitLoadIndirect(parameterType);
ilGenerator.EmitBox(elementType);
}
else
{
ilGenerator.EmitBox(parameterType);
}
ilGenerator.Emit(OpCodes.Stelem_Ref);
}
}
示例4: LoadParameterValues
/// <summary>
/// Loads the parameter values onto the stack.
/// </summary>
/// <param name="ilGenerator">The intermediate language generator.</param>
/// <param name="argumentIndex">The argument index.</param>
/// <param name="parameterTypes">The parameter types.</param>
/// <param name="parameterValueLocalBuilders">The parameter value local builders.</param>
private static void LoadParameterValues(ILGenerator ilGenerator, int argumentIndex, IList<Type> parameterTypes, IList<LocalBuilder> parameterValueLocalBuilders)
{
for (var index = 0; index < parameterTypes.Count; index++)
{
var parameterType = parameterTypes[index];
ilGenerator.EmitLoadArgument(argumentIndex);
ilGenerator.EmitLoadValue(index);
ilGenerator.Emit(OpCodes.Ldelem_Ref);
if (parameterType.IsByRef)
{
var elementType = parameterType.GetElementType();
var parameterLocalBuilder = ilGenerator.DeclareLocal(elementType);
ilGenerator.EmitUnbox(elementType);
ilGenerator.Emit(OpCodes.Stloc, parameterLocalBuilder);
ilGenerator.Emit(OpCodes.Ldloca, parameterLocalBuilder);
parameterValueLocalBuilders[index] = parameterLocalBuilder;
}
else
{
ilGenerator.EmitUnbox(parameterType);
}
}
}