コード例 #1
0
 internal static nint DangerousGetPinnedObjectDataSizeCore(object obj)
 {
     unsafe {
         var            p   = ObjectReferenceUnsafe.AsPointer <GCArrayBase>(obj);
         GCMethodTable *pMT = p->m_base.m_pMethTab;
         return(unchecked ((int)pMT->m_baseSize - 2 * CilVerifiable.SizeOf <nint>() + (nint)pMT->GetComponentSize() * (nint)(nuint)p->m_dwLength));
     }
 }
コード例 #2
0
 public static nint AsIntPtr(object?handle)
 {
     unsafe {
         return(handle is null ? default : unchecked ((nint)Unsafe.AsPointer(ref Unsafe.As <ObjectRawView>(handle).Data) - CilVerifiable.SizeOf <nint>()));
     }
 }
コード例 #3
0
 public static nint GetNativeLength <T>(this T[] array)
 {
     return(unchecked ((nint)CilVerifiable.GetLength(array)));
 }
コード例 #4
0
 public static T Invoke <T>(T arg1, T arg2)
 {
     if (typeof(Int32) == typeof(T))
     {
         return((T)(object)checked ((Int32)(object)arg1 + (Int32)(object)arg2));
     }
     if (typeof(Int64) == typeof(T))
     {
         return((T)(object)checked ((Int64)(object)arg1 + (Int64)(object)arg2));
     }
     if (typeof(UInt32) == typeof(T))
     {
         return((T)(object)checked ((UInt32)(object)arg1 + (UInt32)(object)arg2));
     }
     if (typeof(UInt64) == typeof(T))
     {
         return((T)(object)checked ((UInt64)(object)arg1 + (UInt64)(object)arg2));
     }
     if (typeof(Int16) == typeof(T))
     {
         return((T)(object)checked ((Int16) unchecked ((Int16)(object)arg1 + (Int16)(object)arg2)));
     }
     if (typeof(UInt16) == typeof(T))
     {
         return((T)(object)checked ((UInt16) unchecked ((UInt16)(object)arg1 + (UInt16)(object)arg2)));
     }
     if (typeof(Byte) == typeof(T))
     {
         return((T)(object)checked ((Byte) unchecked ((Byte)(object)arg1 + (Byte)(object)arg2)));
     }
     if (typeof(SByte) == typeof(T))
     {
         return((T)(object)checked ((SByte) unchecked ((SByte)(object)arg1 + (SByte)(object)arg2)));
     }
     if (typeof(IntPtr) == typeof(T))
     {
         return((T)(object)CilVerifiable.Add((IntPtr)(object)arg1, (IntPtr)(object)arg2));
     }
     if (typeof(UIntPtr) == typeof(T))
     {
         return((T)(object)CilVerifiable.Add((UIntPtr)(object)arg1, (UIntPtr)(object)arg2));
     }
     if (typeof(Int128) == typeof(T))
     {
         return((T)(object)Int128.Add((Int128)(object)arg1, (Int128)(object)arg2));
     }
     if (typeof(UInt128) == typeof(T))
     {
         return((T)(object)UInt128.Add((UInt128)(object)arg1, (UInt128)(object)arg2));
     }
     if (typeof(Double) == typeof(T))
     {
         return((T)(object)((Double)(object)arg1 + (Double)(object)arg2));
     }
     if (typeof(Single) == typeof(T))
     {
         return((T)(object)(Single)((Single)(object)arg1 + (Single)(object)arg2));
     }
     if (typeof(Quadruple) == typeof(T))
     {
         return((T)(object)((Quadruple)(object)arg1 + (Quadruple)(object)arg2));
     }
     return(StandardFunctor <T>().Invoke(arg1, arg2));
 }
コード例 #5
0
 public static UIntPtr Invoke(UIntPtr arg1, UIntPtr arg2)
 {
     return(CilVerifiable.Add(arg1, arg2));
 }
コード例 #6
0
 public IntPtr Invoke(IntPtr arg1, IntPtr arg2)
 {
     return(CilVerifiable.Add(arg1, arg2));
 }