本文整理汇总了C#中EEType类的典型用法代码示例。如果您正苦于以下问题:C# EEType类的具体用法?C# EEType怎么用?C# EEType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EEType类属于命名空间,在下文中一共展示了EEType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RhResolveDispatchWorker
private static IntPtr RhResolveDispatchWorker(object pObject, EEType* pInterfaceType, ushort slot)
{
// Type of object we're dispatching on.
EEType* pInstanceType = pObject.EEType;
// Type whose DispatchMap is used. Usually the same as the above but for types which implement ICastable
// we may repeat this process with an alternate type.
EEType* pResolvingInstanceType = pInstanceType;
IntPtr pTargetCode = DispatchResolve.FindInterfaceMethodImplementationTarget(pResolvingInstanceType,
pInterfaceType,
slot);
if (pTargetCode == IntPtr.Zero && pInstanceType->IsICastable)
{
// Dispatch not resolved through normal dispatch map, try using the ICastable
IntPtr pfnGetImplTypeMethod = pInstanceType->ICastableGetImplTypeMethod;
pResolvingInstanceType = (EEType*)CalliIntrinsics.Call<IntPtr>(pfnGetImplTypeMethod, pObject, new IntPtr(pInterfaceType));
pTargetCode = DispatchResolve.FindInterfaceMethodImplementationTarget(pResolvingInstanceType,
pInterfaceType,
slot);
}
return pTargetCode;
}
示例2: CastableTargetLookup
// cache must be a size which is a power of two.
internal static unsafe object CastableTargetLookup(CastableObjectCacheEntry[] cache, EEType* interfaceType)
{
uint cacheMask = (uint)cache.Length - 1;
uint bucket = interfaceType->HashCode & cacheMask;
uint curbucket = bucket;
// hash algorithm is open addressing with linear probing
while (curbucket < cache.Length)
{
if (cache[curbucket].Type == interfaceType)
return cache[curbucket].InstanceObjectForType;
if (cache[curbucket].Type == null)
return null;
curbucket++;
}
// Handle wrap-around case
curbucket = 0;
while (curbucket < bucket)
{
if (cache[curbucket].Type == interfaceType)
return cache[curbucket].InstanceObjectForType;
if (cache[curbucket].Type == null)
return null;
curbucket++;
}
return null;
}
示例3: FindInterfaceMethodImplementationTarget
#pragma warning restore
public static IntPtr FindInterfaceMethodImplementationTarget(EEType* pTgtType,
EEType* pItfType,
ushort itfSlotNumber)
{
DynamicModule* dynamicModule = pTgtType->DynamicModule;
// Use the dynamic module resolver if it's present
if ((dynamicModule != null) && (dynamicModule->DynamicTypeSlotDispatchResolve != IntPtr.Zero))
{
return CalliIntrinsics.Call<IntPtr>(dynamicModule->DynamicTypeSlotDispatchResolve,
(IntPtr)pTgtType, (IntPtr)pItfType, itfSlotNumber);
}
// Start at the current type and work up the inheritance chain
EEType* pCur = pTgtType;
UInt32 iCurInheritanceChainDelta = 0;
if (pItfType->IsCloned)
pItfType = pItfType->CanonicalEEType;
while (pCur != null)
{
UInt16 implSlotNumber;
if (FindImplSlotForCurrentType(
pCur, pItfType, itfSlotNumber, &implSlotNumber))
{
IntPtr targetMethod;
if (implSlotNumber < pCur->NumVtableSlots)
{
// true virtual - need to get the slot from the target type in case it got overridden
targetMethod = pTgtType->GetVTableStartAddress()[implSlotNumber];
}
else
{
// sealed virtual - need to get the slot form the implementing type, because
// it's not present on the target type
targetMethod = pCur->GetSealedVirtualSlot((ushort)(implSlotNumber - pCur->NumVtableSlots));
}
return targetMethod;
}
if (pCur->IsArray)
pCur = pCur->GetArrayEEType();
else
pCur = pCur->NonArrayBaseType;
iCurInheritanceChainDelta++;
}
return IntPtr.Zero;
}
示例4: FindImplSlotForCurrentType
private static bool FindImplSlotForCurrentType(EEType* pTgtType,
EEType* pItfType,
UInt16 itfSlotNumber,
UInt16* pImplSlotNumber)
{
bool fRes = false;
// If making a call and doing virtual resolution don't look into the dispatch map,
// take the slot number directly.
if (!pItfType->IsInterface)
{
*pImplSlotNumber = itfSlotNumber;
// Only notice matches if the target type and search types are the same
// This will make dispatch to sealed slots work correctly
return pTgtType == pItfType;
}
if (pTgtType->HasDispatchMap)
{
// For variant interface dispatch, the algorithm is to walk the parent hierarchy, and at each level
// attempt to dispatch exactly first, and then if that fails attempt to dispatch variantly. This can
// result in interesting behavior such as a derived type only overriding one particular instantiation
// and funneling all the dispatches to it, but its the algorithm.
bool fDoVariantLookup = false; // do not check variance for first scan of dispatch map
fRes = FindImplSlotInSimpleMap(
pTgtType, pItfType, itfSlotNumber, pImplSlotNumber, fDoVariantLookup);
if (!fRes)
{
fDoVariantLookup = true; // check variance for second scan of dispatch map
fRes = FindImplSlotInSimpleMap(
pTgtType, pItfType, itfSlotNumber, pImplSlotNumber, fDoVariantLookup);
}
}
return fRes;
}
示例5: TypesAreCompatibleViaGenericVariance
// Compare two types to see if they are compatible via generic variance.
static private unsafe bool TypesAreCompatibleViaGenericVariance(EEType* pSourceType, EEType* pTargetType)
{
EEType* pTargetGenericType = pTargetType->GenericDefinition;
EEType* pSourceGenericType = pSourceType->GenericDefinition;
// If the generic types aren't the same then the types aren't compatible.
if (pSourceGenericType == pTargetGenericType)
{
// Get generic instantiation metadata for both types.
EETypeRef* pTargetInstantiation = pTargetType->GenericArguments;
int targetArity = (int)pTargetType->GenericArity;
GenericVariance* pTargetVarianceInfo = pTargetType->GenericVariance;
Debug.Assert(pTargetVarianceInfo != null, "did not expect empty variance info");
EETypeRef* pSourceInstantiation = pSourceType->GenericArguments;
int sourceArity = (int)pSourceType->GenericArity;
GenericVariance* pSourceVarianceInfo = pSourceType->GenericVariance;
Debug.Assert(pSourceVarianceInfo != null, "did not expect empty variance info");
// The types represent different instantiations of the same generic type. The
// arity of both had better be the same.
Debug.Assert(targetArity == sourceArity, "arity mismatch betweeen generic instantiations");
// Compare the instantiations to see if they're compatible taking variance into account.
if (TypeParametersAreCompatible(targetArity,
pSourceInstantiation,
pTargetInstantiation,
pTargetVarianceInfo,
false))
{
return true;
}
}
return false;
}
示例6: IsInstanceOfInterfaceViaICastable
unsafe static bool IsInstanceOfInterfaceViaICastable(object obj, EEType* pTargetType)
{
// Call the ICastable.IsInstanceOfInterface method directly rather than via an interface
// dispatch since we know the method address statically. We ignore any cast error exception
// object passed back on failure (result == false) since IsInstanceOfInterface never throws.
IntPtr pfnIsInstanceOfInterface = obj.EEType->ICastableIsInstanceOfInterfaceMethod;
Exception castError = null;
if (CalliIntrinsics.Call<bool>(pfnIsInstanceOfInterface, obj, pTargetType, out castError))
return true;
return false;
}
示例7: RhpGetICastableIsInstanceOfInterfaceMethod
internal extern static unsafe IntPtr RhpGetICastableIsInstanceOfInterfaceMethod(EEType* pEEType);
示例8: RhpGetNullableEETypeValueOffset
internal extern static unsafe byte RhpGetNullableEETypeValueOffset(EEType* pEEType);
示例9: RhpUpdateDispatchCellCache
internal unsafe extern static IntPtr RhpUpdateDispatchCellCache(IntPtr pCell, IntPtr pTargetCode, EEType* pInstanceType, ref DispatchCellInfo newCellInfo);
示例10: RhpGetSealedVirtualSlot
internal unsafe extern static IntPtr RhpGetSealedVirtualSlot(EEType* pEEType, ushort slot);
示例11: IsSystemArray
// Returns true if the passed in EEType is the EEType for System.Array.
// The binder sets a special CorElementType for this well known type
internal static unsafe bool IsSystemArray(EEType* pEEType)
{
return (pEEType->CorElementType == CorElementType.ELEMENT_TYPE_ARRAY);
}
示例12: IsSystemObject
// Returns true if the passed in EEType is the EEType for System.Object
// This is recognized by the fact that System.Object and interfaces are the only ones without a base type
internal static unsafe bool IsSystemObject(EEType* pEEType)
{
if (pEEType->IsArray)
return false;
return (pEEType->NonArrayBaseType == null) && !pEEType->IsInterface;
}
示例13: IsEquivalentTo
internal bool IsEquivalentTo(EEType* pOtherEEType)
{
fixed (EEType* pThis = &this)
{
if (pThis == pOtherEEType)
return true;
EEType* pThisEEType = pThis;
if (pThisEEType->IsCloned)
pThisEEType = pThisEEType->CanonicalEEType;
if (pOtherEEType->IsCloned)
pOtherEEType = pOtherEEType->CanonicalEEType;
if (pThisEEType == pOtherEEType)
return true;
if (pThisEEType->IsParameterizedType && pOtherEEType->IsParameterizedType)
{
return pThisEEType->RelatedParameterType->IsEquivalentTo(pOtherEEType->RelatedParameterType) &&
pThisEEType->ParameterizedTypeShape == pOtherEEType->ParameterizedTypeShape;
}
}
return false;
}
示例14: BothSimpleCasting
/// <summary>
/// Return true if both types are good for simple casting: canonical, no related type via IAT, no generic variance
/// </summary>
internal static bool BothSimpleCasting(EEType* pThis, EEType* pOther)
{
return ((pThis->_usFlags | pOther->_usFlags) & (ushort)EETypeFlags.ComplexCastingMask) == (ushort)EETypeKind.CanonicalEEType;
}
示例15: ShouldTypedClauseCatchThisException
private static bool ShouldTypedClauseCatchThisException(object exception, EEType* pClauseType)
{
if (TypeCast.IsInstanceOfClass(exception, pClauseType) != null)
return true;
if (s_pLowLevelObjectType == null)
{
// TODO: Avoid allocating here as that may fail
s_pLowLevelObjectType = new System.Object().EEType;
}
// This allows the typical try { } catch { }--which expands to a typed catch of System.Object--to work on
// all objects when the clause is in the low level runtime code. This special case is needed because
// objects from foreign type systems are sometimes throw back up at runtime code and this is the only way
// to catch them outside of having a filter with no type check in it, which isn't currently possible to
// write in C#. See https://github.com/dotnet/roslyn/issues/4388
if (pClauseType->IsEquivalentTo(s_pLowLevelObjectType))
return true;
return false;
}