-
Notifications
You must be signed in to change notification settings - Fork 1
/
Arguments.tt
31 lines (29 loc) · 1.13 KB
/
Arguments.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".codegen.cs" #>
using System;
using System.Reflection.Emit;
using JetBrains.Annotations;
namespace ILGeneratorExtensions
{
public static partial class Arguments
{
<# foreach (var type in new [] { typeof(char), typeof(bool), typeof(int), typeof(uint), typeof(long), typeof(ulong) }) { #>
/// <summary>
/// Overwrite the specified argument with the given value.
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
/// <param name="argNum">The index of the argument to store the value in</param>
/// <param name="value">The value to store in the argument</param>
[PublicAPI]
public static ILGenerator OverwriteArgument(this ILGenerator generator, ushort argNum, <#= type.Name #> value)
{
return generator.LoadConstant(value)
.StoreInArgument(argNum);
}
<# } #>
}
}