-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNativeInteger.cs
More file actions
68 lines (60 loc) · 3.78 KB
/
NativeInteger.cs
File metadata and controls
68 lines (60 loc) · 3.78 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.Reflection.Emit;
using JetBrains.Annotations;
namespace ILGeneratorExtensions
{
/// <summary>
/// Contains extension methods for the manipulation of native integer values
/// </summary>
[PublicAPI]
public static class NativeInteger
{
/// <summary>
/// Pops an address off the evaluation stack, loads a native integer from it and pushes it onto the evaluation stack
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator LoadNativeIntegerFromAddress(this ILGenerator generator) => generator.FluentEmit(OpCodes.Ldind_I);
/// <summary>
/// Pops an address and a native integer off the evaluation stack and stores the native integer at the address
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator StoreNativeIntegerFromStack(this ILGenerator generator) => generator.FluentEmit(OpCodes.Stind_I);
/// <summary>
/// Pops an array reference, an array index and a native integer off the evaluation stack, storing it in the array at the index
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator StoreNativeIntegerElement(this ILGenerator generator) => generator.FluentEmit(OpCodes.Stelem_I);
/// <summary>
/// Pops an array reference and an array index, pushing the native integer stored in the array at that index onto the evaluation stack
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator LoadNativeIntegerElement(this ILGenerator generator) => generator.FluentEmit(OpCodes.Ldelem_I);
/// <summary>
/// Pops an integer off the evaluation stack and pushes the equivalent native integer
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator ConvertToNativeInteger(this ILGenerator generator) => generator.FluentEmit(OpCodes.Conv_I);
/// <summary>
/// Pops an integer off the evaluation stack and pushes the equivalent unsigned native integer
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator ConvertToUnsignedNativeInteger(this ILGenerator generator) => generator.FluentEmit(OpCodes.Conv_U);
/// <summary>
/// Pops an integer off the evaluation stack and pushes the equivalent native integer, with a check for overflow
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator ConvertToNativeIntegerWithOverflow(this ILGenerator generator) => generator.FluentEmit(OpCodes.Conv_Ovf_I);
/// <summary>
/// Pops an integer off the evaluation stack and pushes the equivalent unsigned native integer, with a check for overflow
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator ConvertToUnsignedNativeIntegerWithOverflow(this ILGenerator generator) => generator.FluentEmit(OpCodes.Conv_Ovf_U);
}
}