当前位置: 首页>>代码示例>>C#>>正文


C# EEType类代码示例

本文整理汇总了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;
        }
开发者ID:shahid-pk,项目名称:corert,代码行数:26,代码来源:CachedInterfaceDispatch.cs

示例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;
        }
开发者ID:krytarowski,项目名称:corert,代码行数:31,代码来源:CastableObjectSupport.cs

示例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;
        }
开发者ID:krytarowski,项目名称:corert,代码行数:50,代码来源:DispatchResolve.cs

示例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;
        }
开发者ID:krytarowski,项目名称:corert,代码行数:40,代码来源:DispatchResolve.cs

示例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;
        }
开发者ID:BruceForstall,项目名称:corert,代码行数:40,代码来源:TypeCast.cs

示例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;
 }
开发者ID:BruceForstall,项目名称:corert,代码行数:11,代码来源:TypeCast.cs

示例7: RhpGetICastableIsInstanceOfInterfaceMethod

 internal extern static unsafe IntPtr RhpGetICastableIsInstanceOfInterfaceMethod(EEType* pEEType);
开发者ID:hoyMS,项目名称:corert,代码行数:1,代码来源:InternalCalls.cs

示例8: RhpGetNullableEETypeValueOffset

 internal extern static unsafe byte RhpGetNullableEETypeValueOffset(EEType* pEEType);
开发者ID:hoyMS,项目名称:corert,代码行数:1,代码来源:InternalCalls.cs

示例9: RhpUpdateDispatchCellCache

 internal unsafe extern static IntPtr RhpUpdateDispatchCellCache(IntPtr pCell, IntPtr pTargetCode, EEType* pInstanceType, ref DispatchCellInfo newCellInfo);
开发者ID:hoyMS,项目名称:corert,代码行数:1,代码来源:InternalCalls.cs

示例10: RhpGetSealedVirtualSlot

 internal unsafe extern static IntPtr RhpGetSealedVirtualSlot(EEType* pEEType, ushort slot);
开发者ID:hoyMS,项目名称:corert,代码行数:1,代码来源:InternalCalls.cs

示例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);
 }
开发者ID:stephentoub,项目名称:corert,代码行数:6,代码来源:EEType.Runtime.cs

示例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;
 }
开发者ID:stephentoub,项目名称:corert,代码行数:8,代码来源:EEType.Runtime.cs

示例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;
        }
开发者ID:stephentoub,项目名称:corert,代码行数:27,代码来源:EEType.Runtime.cs

示例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;
 }
开发者ID:stephentoub,项目名称:corert,代码行数:7,代码来源:EEType.Runtime.cs

示例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;
        }
开发者ID:justinvp,项目名称:corert,代码行数:21,代码来源:ExceptionHandling.cs


注:本文中的EEType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。