/// <summary> /// Emits optimal <see cref="OpCodes.Stloc"/> instructions by a given <paramref name="index"/>. /// </summary> /// <remarks> /// Optimal meaning creating the special OpCodes(e.g. <see cref="OpCodes.Stloc_0"/>...) /// if <paramref name="index"/> is smaller than 4. /// </remarks> /// <param name="processor">The <see cref="ILProcessor"/>.</param> /// <param name="index">The index of the variable to store in.</param> public static void EmitStloc(this ILProcessor processor, int index) { processor.Append(processor.CreateStloc(index)); }
/// <summary> /// Emits optimal <see cref="OpCodes.Stloc"/> instructions by a given <paramref name="variable"/>. /// </summary> /// <remarks> /// <see cref="CreateStloc(ILProcessor, int)"/> /// </remarks> /// <param name="processor">The <see cref="ILProcessor"/>.</param> /// <param name="variable">The variable to store in.</param> public static void EmitStloc(this ILProcessor processor, VariableDefinition variable) { processor.Append(processor.CreateStloc(variable)); }
/// <summary> /// Creates optimal <see cref="OpCodes.Stloc"/> instructions by a given <paramref name="variable"/>. /// </summary> /// <remarks> /// <see cref="CreateStloc(ILProcessor, int)"/> /// </remarks> /// <param name="processor">The <see cref="ILProcessor"/>.</param> /// <param name="variable">The variable to store in.</param> /// <returns>The created <see cref="Instruction"/>.</returns> public static Instruction CreateStloc(this ILProcessor processor, VariableDefinition variable) { return(processor.CreateStloc(variable.Index)); }