diff options
Diffstat (limited to 'src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs')
-rw-r--r-- | src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs b/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs index 705193a3c..c63760b39 100644 --- a/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs +++ b/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs @@ -21,8 +21,22 @@ namespace Internal.Runtime.CompilerServices /// <summary> /// Contains generic, low-level functionality for manipulating pointers. /// </summary> - public static class Unsafe + public static unsafe class Unsafe { + /// <summary> + /// Returns a pointer to the given by-ref parameter. + /// </summary> + [Intrinsic] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void* AsPointer<T>(ref T value) + { + throw new PlatformNotSupportedException(); + + // ldarg.0 + // conv.u + // ret + } + [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int SizeOf<T>() @@ -83,5 +97,15 @@ namespace Internal.Runtime.CompilerServices { return ref AddByteOffset(ref source, (IntPtr)(elementOffset * (nint)SizeOf<T>())); } + + /// <summary> + /// Reinterprets the given location as a reference to a value of type <typeparamref name="T"/>. + /// </summary> + [Intrinsic] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T AsRef<T>(in T source) + { + throw new PlatformNotSupportedException(); + } } } |