本文整理汇总了C#中System.RuntimeTypeHandle.ToIntPtr方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle.ToIntPtr方法的具体用法?C# RuntimeTypeHandle.ToIntPtr怎么用?C# RuntimeTypeHandle.ToIntPtr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.RuntimeTypeHandle
的用法示例。
在下文中一共展示了RuntimeTypeHandle.ToIntPtr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetNonUnboxingFunctionPointerFromUnboxingAndInstantiatingStub
public static unsafe bool TryGetNonUnboxingFunctionPointerFromUnboxingAndInstantiatingStub(IntPtr potentialStub, RuntimeTypeHandle exactType, out IntPtr nonUnboxingMethod)
{
IntPtr callConversionId;
IntPtr commonStubDataPtr;
if (!RuntimeAugments.TryGetThunkData(s_thunkPoolHeap, potentialStub, out callConversionId, out commonStubDataPtr))
{
// This isn't a call conversion stub
nonUnboxingMethod = IntPtr.Zero;
return false;
}
CallConversionInfo conversionInfo = CallConversionInfo.GetConverter(callConversionId.ToInt32());
if (conversionInfo.IsUnboxingThunk)
{
// In this case the call converter is serving as an unboxing/instantiating stub
// This case is not yet handled, and we don't need support for it yet.
throw NotImplemented.ByDesign;
}
IntPtr underlyingTargetMethod;
IntPtr newInstantiatingArg;
if (conversionInfo.CalleeHasParamType)
{
// In this case the call converter is an instantiating stub wrapping an unboxing thunk.
// Use the redhawk GetCodeTarget to see through the unboxing stub and get the real underlying method
// and the instantiation arg does not need changing.
underlyingTargetMethod = RuntimeAugments.GetCodeTarget(conversionInfo.TargetFunctionPointer);
newInstantiatingArg = conversionInfo.InstantiatingStubArgument;
}
else
{
// At this point we've got a standard to generic converter wrapping an unboxing and instantiating
// stub. We need to convert that into a fat function pointer directly calling the underlying method
// or a calling convention converter instantiating stub wrapping the underlying method
IntPtr underlyingUnboxingAndInstantiatingMethod = RuntimeAugments.GetCodeTarget(conversionInfo.TargetFunctionPointer);
if (!TypeLoaderEnvironment.TryGetTargetOfUnboxingAndInstantiatingStub(underlyingUnboxingAndInstantiatingMethod, out underlyingTargetMethod))
{
// We aren't wrapping an unboxing and instantiating stub. This should never happen
throw new NotSupportedException();
}
newInstantiatingArg = exactType.ToIntPtr();
}
Debug.Assert(conversionInfo.CallerForcedByRefData == null);
bool canUseFatFunctionPointerInsteadOfThunk = true;
if (conversionInfo.CalleeForcedByRefData != null)
{
foreach (bool forcedByRef in conversionInfo.CalleeForcedByRefData)
{
if (forcedByRef)
{
canUseFatFunctionPointerInsteadOfThunk = false;
break;
}
}
}
if (canUseFatFunctionPointerInsteadOfThunk)
{
nonUnboxingMethod = FunctionPointerOps.GetGenericMethodFunctionPointer(underlyingTargetMethod, newInstantiatingArg);
return true;
}
else
{
// Construct a new StandardToGenericInstantiating thunk around the underlyingTargetMethod
nonUnboxingMethod = MakeThunk(ThunkKind.StandardToGenericInstantiating,
underlyingTargetMethod,
newInstantiatingArg,
conversionInfo.ArgIteratorData,
conversionInfo.CalleeForcedByRefData);
return true;
}
}