-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArrayManipulation.tt
32 lines (30 loc) · 1.41 KB
/
ArrayManipulation.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
32
<#@ 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=".autogen.cs" #>
using System;
using System.Reflection.Emit;
using JetBrains.Annotations;
namespace ILGeneratorExtensions
{
public static partial class ArrayManipulation
{
<# foreach (var type in new [] { typeof(bool), typeof(char), typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double) }) { #>
/// <summary>
/// Pops an array reference (containing elements of <see cref="<#= type.FullName #>" />), and stores the given <see cref="<#= type.FullName #>" /> value at the given index
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
/// <param name="value">The <see cref="<#= type.Name #>" /> value to store in the array</param>
/// <param name="index">The index to store the value at</param>
[PublicAPI]
public static ILGenerator StoreElementAtIndex(this ILGenerator generator, <#= type.Name #> value, uint index)
{
return generator.LoadConstant(index)
.LoadConstant(value)
.StoreElement<<#= type.Name #>>();
}
<# } #>
}
}