Example #1
0
        internal unsafe static IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            ModuleHandle.ValidateModulePointer(module);
            if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken))
            {
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[]
                {
                    fieldToken,
                    new ModuleHandle(module)
                }));
            }
            int typeInstCount;

            IntPtr[] array = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount);
            int      methodInstCount;

            IntPtr[] array2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount);
            fixed(IntPtr *ptr = array)
            {
                fixed(IntPtr *ptr2 = array2)
                {
                    IRuntimeFieldInfo result = null;

                    ModuleHandle.ResolveField(module.GetNativeHandle(), fieldToken, ptr, typeInstCount, ptr2, methodInstCount, JitHelpers.GetObjectHandleOnStack <IRuntimeFieldInfo>(ref result));
                    GC.KeepAlive(typeInstantiationContext);
                    GC.KeepAlive(methodInstantiationContext);
                    return(result);
                }
            }
        }
Example #2
0
        internal static unsafe RuntimeType ResolveTypeHandleInternal(RuntimeModule module, int typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            ModuleHandle.ValidateModulePointer(module);
            if (!ModuleHandle.GetMetadataImport(module).IsValidToken(typeToken))
            {
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", (object)typeToken, (object)new ModuleHandle(module)));
            }
            int length1;

            IntPtr[] numArray1 = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out length1);
            int      length2;

            IntPtr[] numArray2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out length2);
            IntPtr[] numArray3 = numArray1;
            // ISSUE: cast to a reference type
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            fixed(IntPtr *typeInstArgs = & ^ (numArray1 == null || numArray3.Length == 0 ? (IntPtr&)IntPtr.Zero : @numArray3[0]))
            fixed(IntPtr * methodInstArgs = numArray2)
            {
                RuntimeType o = (RuntimeType)null;

                ModuleHandle.ResolveType(module, typeToken, typeInstArgs, length1, methodInstArgs, length2, JitHelpers.GetObjectHandleOnStack <RuntimeType>(ref o));
                GC.KeepAlive((object)typeInstantiationContext);
                GC.KeepAlive((object)methodInstantiationContext);
                return(o);
            }
        }
Example #3
0
        internal static unsafe IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            int num;
            int num2;

            ValidateModulePointer(module);
            if (!GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken))
            {
                throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[] { fieldToken, new ModuleHandle(module) }));
            }
            IntPtr[] ptrArray  = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out num);
            IntPtr[] ptrArray2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out num2);
            fixed(IntPtr *ptrRef = ptrArray)
            {
                fixed(IntPtr *ptrRef2 = ptrArray2)
                {
                    IRuntimeFieldInfo o = null;

                    ResolveField(module.GetNativeHandle(), fieldToken, ptrRef, num, ptrRef2, num2, JitHelpers.GetObjectHandleOnStack <IRuntimeFieldInfo>(ref o));
                    GC.KeepAlive(typeInstantiationContext);
                    GC.KeepAlive(methodInstantiationContext);
                    return(o);
                }
            }
        }
Example #4
0
        internal unsafe RuntimeType Instantiate(Type[] inst)
        {
            int length;

            fixed(IntPtr *pInst = RuntimeTypeHandle.CopyRuntimeTypeHandles(inst, out length))
            {
                RuntimeType o = (RuntimeType)null;

                RuntimeTypeHandle.Instantiate(this.GetNativeHandle(), pInst, length, JitHelpers.GetObjectHandleOnStack <RuntimeType>(ref o));
                GC.KeepAlive((object)inst);
                return(o);
            }
        }
        internal unsafe RuntimeType Instantiate(Type[] inst)
        {
            int numGenericArgs;

            IntPtr[] array = RuntimeTypeHandle.CopyRuntimeTypeHandles(inst, out numGenericArgs);
            fixed(IntPtr *ptr = array)
            {
                RuntimeType result = null;

                RuntimeTypeHandle.Instantiate(this.GetNativeHandle(), ptr, numGenericArgs, JitHelpers.GetObjectHandleOnStack <RuntimeType>(ref result));
                GC.KeepAlive(inst);
                return(result);
            }
        }
Example #6
0
        internal static IRuntimeMethodInfo ResolveMethodHandleInternal(RuntimeModule module, int methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            int num;
            int num2;

            IntPtr[] ptrArray  = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out num);
            IntPtr[] ptrArray2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out num2);
            RuntimeMethodHandleInternal methodHandleValue = ResolveMethodHandleInternalCore(module, methodToken, ptrArray, num, ptrArray2, num2);
            IRuntimeMethodInfo          info = new RuntimeMethodInfoStub(methodHandleValue, RuntimeMethodHandle.GetLoaderAllocator(methodHandleValue));

            GC.KeepAlive(typeInstantiationContext);
            GC.KeepAlive(methodInstantiationContext);
            return(info);
        }
Example #7
0
        internal static IRuntimeMethodInfo ResolveMethodHandleInternal(RuntimeModule module, int methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            int length1;

            IntPtr[] typeInstantiationContext1 = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out length1);
            int      length2;

            IntPtr[] methodInstantiationContext1              = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out length2);
            RuntimeMethodHandleInternal methodHandleInternal  = ModuleHandle.ResolveMethodHandleInternalCore(module, methodToken, typeInstantiationContext1, length1, methodInstantiationContext1, length2);
            RuntimeMethodInfoStub       runtimeMethodInfoStub = new RuntimeMethodInfoStub(methodHandleInternal, (object)RuntimeMethodHandle.GetLoaderAllocator(methodHandleInternal));

            GC.KeepAlive((object)typeInstantiationContext);
            GC.KeepAlive((object)methodInstantiationContext);
            return((IRuntimeMethodInfo)runtimeMethodInfoStub);
        }
Example #8
0
        internal static IRuntimeMethodInfo ResolveMethodHandleInternal(RuntimeModule module, int methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
        {
            int typeInstCount;

            IntPtr[] typeInstantiationContext2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount);
            int      methodInstCount;

            IntPtr[] methodInstantiationContext2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount);
            RuntimeMethodHandleInternal runtimeMethodHandleInternal = ModuleHandle.ResolveMethodHandleInternalCore(module, methodToken, typeInstantiationContext2, typeInstCount, methodInstantiationContext2, methodInstCount);
            IRuntimeMethodInfo          result = new RuntimeMethodInfoStub(runtimeMethodHandleInternal, RuntimeMethodHandle.GetLoaderAllocator(runtimeMethodHandleInternal));

            GC.KeepAlive(typeInstantiationContext);
            GC.KeepAlive(methodInstantiationContext);
            return(result);
        }
        internal unsafe static bool SatisfiesConstraints(RuntimeType paramType, RuntimeType[] typeContext, RuntimeType[] methodContext, RuntimeType toType)
        {
            int typeContextLength;

            IntPtr[] array = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeContext, out typeContextLength);
            int      methodContextLength;

            IntPtr[] array2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodContext, out methodContextLength);
            fixed(IntPtr *ptr = array)
            {
                fixed(IntPtr *ptr2 = array2)
                {
                    bool result = RuntimeTypeHandle.SatisfiesConstraints(paramType, ptr, typeContextLength, ptr2, methodContextLength, toType);

                    GC.KeepAlive(typeContext);
                    GC.KeepAlive(methodContext);
                    return(result);
                }
            }
        }
Example #10
0
        internal static unsafe bool SatisfiesConstraints(RuntimeType paramType, RuntimeType[] typeContext, RuntimeType[] methodContext, RuntimeType toType)
        {
            int length1;

            IntPtr[] numArray1 = RuntimeTypeHandle.CopyRuntimeTypeHandles((Type[])typeContext, out length1);
            int      length2;

            IntPtr[] numArray2 = RuntimeTypeHandle.CopyRuntimeTypeHandles((Type[])methodContext, out length2);
            IntPtr[] numArray3 = numArray1;
            // ISSUE: cast to a reference type
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            fixed(IntPtr *pTypeContext = & ^ (numArray1 == null || numArray3.Length == 0 ? (IntPtr&)IntPtr.Zero : @numArray3[0]))
            fixed(IntPtr * pMethodContext = numArray2)
            {
                int num = RuntimeTypeHandle.SatisfiesConstraints(paramType, pTypeContext, length1, pMethodContext, length2, toType) ? 1 : 0;

                GC.KeepAlive((object)typeContext);
                GC.KeepAlive((object)methodContext);
                return(num != 0);
            }
        }