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


C# RuntimeTypeHandle.ToEETypePtr方法代码示例

本文整理汇总了C#中System.RuntimeTypeHandle.ToEETypePtr方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle.ToEETypePtr方法的具体用法?C# RuntimeTypeHandle.ToEETypePtr怎么用?C# RuntimeTypeHandle.ToEETypePtr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.RuntimeTypeHandle的用法示例。


在下文中一共展示了RuntimeTypeHandle.ToEETypePtr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenMethodResolver

 public OpenMethodResolver(RuntimeTypeHandle declaringTypeOfSlot, int slot, int handle)
 {
     _resolveType = DispatchResolve;
     _declaringType = declaringTypeOfSlot.ToEETypePtr();
     _methodHandleOrSlotOrCodePointer = new IntPtr(slot);
     _handle = handle;
 }
开发者ID:nguerrera,项目名称:corert,代码行数:7,代码来源:OpenMethodResolver.cs

示例2: NoMetadataType

        public NoMetadataType(TypeSystemContext context, RuntimeTypeHandle genericTypeDefinition, DefType genericTypeDefinitionAsDefType, Instantiation instantiation, int hashcode)
        {
            _hashcode = hashcode;
            _context = context;
            _genericTypeDefinition = genericTypeDefinition;
            _genericTypeDefinitionAsDefType = genericTypeDefinitionAsDefType;
            if (_genericTypeDefinitionAsDefType == null)
                _genericTypeDefinitionAsDefType = this;
            _instantiation = instantiation;

            // Instantiation must either be:
            // Something valid (if the type is generic, or a generic type definition)
            // or Empty (if the type isn't a generic of any form)
            unsafe
            {
                Debug.Assert(((_instantiation.Length > 0) && _genericTypeDefinition.ToEETypePtr()->IsGenericTypeDefinition) ||
                             ((_instantiation.Length == 0) && !_genericTypeDefinition.ToEETypePtr()->IsGenericTypeDefinition));
            }
        }
开发者ID:nattress,项目名称:corert,代码行数:19,代码来源:RuntimeNoMetadataType.cs

示例3: TryGetNonGcStaticFieldDataDirect

        // Various functions in static access need to create permanent pointers for use by thread static lookup.
        #region GC/Non-GC Statics
        /// <summary>
        /// Get a pointer to the nongc static field data of a type. This function works for dynamic
        /// types, reflectable types, and for all generic types
        /// </summary>
        public IntPtr TryGetNonGcStaticFieldDataDirect(RuntimeTypeHandle runtimeTypeHandle)
        {
            unsafe
            {
                EEType* typeAsEEType = runtimeTypeHandle.ToEETypePtr();
                // Non-generic, non-dynamic types need special handling.
                if (!typeAsEEType->IsDynamicType && !typeAsEEType->IsGeneric)
                {
                    if (typeAsEEType->HasCctor)
                    {
                        // The non-gc area for a type is immediately following its cctor context if it has one
                        IntPtr dataAddress = TryGetStaticClassConstructionContext(runtimeTypeHandle);
                        if (dataAddress != IntPtr.Zero)
                        {
                            return (IntPtr)(((byte*)dataAddress.ToPointer()) + sizeof(System.Runtime.CompilerServices.StaticClassConstructionContext));
                        }
                    }
                    else
                    {
                        // If the type does not have a Cctor context, search for the field on the type in the field map which has the lowest offset,
                        // yet has the the correct type of storage. 
                        IntPtr staticAddress;
                        if (TryGetStaticFieldBaseFromFieldAccessMap(runtimeTypeHandle, FieldAccessStaticDataKind.NonGC, out staticAddress))
                        {
                            return staticAddress;
                        }
                    }
                }
            }

            IntPtr nonGcStaticsAddress;
            IntPtr gcStaticsAddress;
            if (TryGetStaticsInfoForNamedType(runtimeTypeHandle, out nonGcStaticsAddress, out gcStaticsAddress))
            {
                return nonGcStaticsAddress;
            }

            // The indirected helper function can be used to find all dynamic types not found via 
            // TryGetStaticsInfoForNamedType as well as generics
            IntPtr ptrToStaticFieldData = TryGetNonGcStaticFieldData(runtimeTypeHandle);
            if (ptrToStaticFieldData == IntPtr.Zero)
            {
                return IntPtr.Zero;
            }
            else
            {
                unsafe
                {
                    return *(IntPtr*)ptrToStaticFieldData;
                }
            }
        }
开发者ID:justinvp,项目名称:corert,代码行数:58,代码来源:TypeLoaderEnvironment.StaticsLookup.cs

示例4: Equals

 public bool Equals(RuntimeTypeHandle handle)
 {
     if (_value == handle._value)
     {
         return true;
     }
     else if (this.IsNull || handle.IsNull)
     {
         return false;
     }
     else
     {
         return RuntimeImports.AreTypesEquivalent(this.ToEETypePtr(), handle.ToEETypePtr());
     }
 }
开发者ID:noahfalk,项目名称:corert,代码行数:15,代码来源:RuntimeTypeHandle.cs

示例5: GVMLookupForSlotWorker

        private static unsafe IntPtr GVMLookupForSlotWorker(RuntimeTypeHandle type, RuntimeTypeHandle declaringType, RuntimeTypeHandle[] genericArguments, MethodNameAndSignature methodNameAndSignature)
        {
            bool slotChanged = false;

            IntPtr resolution = IntPtr.Zero;

            // Otherwise, walk parent hierarchy attempting to resolve
            EETypePtr eetype = type.ToEETypePtr();

            IntPtr functionPointer = IntPtr.Zero;
            IntPtr genericDictionary = IntPtr.Zero;

            while (!eetype.IsNull)
            {
                RuntimeTypeHandle handle = new RuntimeTypeHandle(eetype);
                string methodName = methodNameAndSignature.Name;
                RuntimeMethodSignature methodSignature = methodNameAndSignature.Signature;
                if (RuntimeAugments.TypeLoaderCallbacks.TryGetGenericVirtualTargetForTypeAndSlot(handle, ref declaringType, genericArguments, ref methodName, ref methodSignature, out functionPointer, out genericDictionary, out slotChanged))
                {
                    methodNameAndSignature = new MethodNameAndSignature(methodName, methodSignature);

                    if (!slotChanged)
                        resolution = FunctionPointerOps.GetGenericMethodFunctionPointer(functionPointer, genericDictionary);
                    break;
                }

                eetype = eetype.BaseType;
            }

            // If the current slot to examine has changed, restart the lookup.
            // This happens when there is an interface call.
            if (slotChanged)
            {
                return GVMLookupForSlotWorker(type, declaringType, genericArguments, methodNameAndSignature);
            }

            if (resolution == IntPtr.Zero)
            {
                Environment.FailFast("GVM resolution failure");
            }

            return resolution;
        }
开发者ID:justinvp,项目名称:corert,代码行数:43,代码来源:GenericVirtualMethodSupport.cs

示例6: Equals

        public bool Equals(RuntimeTypeHandle handle)
        {
#if CORERT
            return Object.ReferenceEquals(_type, handle._type);
#else
            if (_value == handle._value)
            {
                return true;
            }
            else if (this.IsNull || handle.IsNull)
            {
                return false;
            }
            else
            {
                return RuntimeImports.AreTypesEquivalent(this.ToEETypePtr(), handle.ToEETypePtr());
            }
#endif
        }
开发者ID:huamichaelchen,项目名称:corert,代码行数:19,代码来源:RuntimeTypeHandle.cs

示例7: GetDefaultValue

        private static unsafe object GetDefaultValue(RuntimeTypeHandle thType, int argIndex)
        {
            // Group index of 0 indicates there are no default parameters
            if (s_defaultValueString == null)
            {
                throw new ArgumentException(SR.Arg_DefaultValueMissingException);
            }
            StringDataParser dataParser = new StringDataParser(s_defaultValueString);

            // Skip to current argument
            int curArgIndex = 0;
            while (curArgIndex != argIndex)
            {
                int skip = dataParser.GetInt();
                dataParser.Skip(skip);
                curArgIndex++;
            }

            // Discard size of current argument
            int sizeOfCurrentArg = dataParser.GetInt();

            int defaultValueType = dataParser.GetInt();

            switch (defaultValueType)
            {
                case DefaultParamTypeNone:
                default:
                    throw new ArgumentException(SR.Arg_DefaultValueMissingException);

                case DefaultParamTypeString:
                    return dataParser.GetString();

                case DefaultParamTypeDefault:
                    if (thType.ToEETypePtr().IsValueType)
                    {
                        if (RuntimeImports.RhIsNullable(thType.ToEETypePtr()))
                        {
                            return null;
                        }
                        else
                        {
                            return RuntimeImports.RhNewObject(thType.ToEETypePtr());
                        }
                    }
                    else
                    {
                        return null;
                    }

                case DefaultParamTypeBool:
                    return (dataParser.GetInt() == 1);
                case DefaultParamTypeChar:
                    return (char)dataParser.GetInt();
                case DefaultParamTypeI1:
                    return (sbyte)dataParser.GetInt();
                case DefaultParamTypeI2:
                    return (short)dataParser.GetInt();
                case DefaultParamTypeI4:
                    return dataParser.GetInt();
                case DefaultParamTypeI8:
                    return dataParser.GetLong();
                case DefaultParamTypeR4:
                    return dataParser.GetFloat();
                case DefaultParamTypeR8:
                    return dataParser.GetDouble();
                case DefaultParamTypeDecimal:
                    int[] decimalBits = new int[4];
                    decimalBits[0] = dataParser.GetInt();
                    decimalBits[1] = dataParser.GetInt();
                    decimalBits[2] = dataParser.GetInt();
                    decimalBits[3] = dataParser.GetInt();
                    return new Decimal(decimalBits);
                case DefaultParamTypeDateTime:
                    return new DateTime(dataParser.GetLong());
            }
        }
开发者ID:noahfalk,项目名称:corert,代码行数:76,代码来源:InvokeUtils.cs

示例8: TryGetGcStaticFieldDataDirect

        /// <summary>
        /// Get a pointer to the gc static field data of a type. This function works for dynamic
        /// types, reflectable types, and for all generic types
        /// </summary>
        public IntPtr TryGetGcStaticFieldDataDirect(RuntimeTypeHandle runtimeTypeHandle)
        {
            unsafe
            {
                // Non-generic, non-dynamic static data is found via the FieldAccessMap
                EEType* typeAsEEType = runtimeTypeHandle.ToEETypePtr();
                // Non-generic, non-dynamic types need special handling.
                if (!typeAsEEType->IsDynamicType && !typeAsEEType->IsGeneric)
                {
                    //search for the field on the type in the field map which has the lowest offset,
                    // yet has the the correct type of storage. 
                    IntPtr staticAddress;
                    if (TryGetStaticFieldBaseFromFieldAccessMap(runtimeTypeHandle, FieldAccessStaticDataKind.GC, out staticAddress))
                    {
                        return staticAddress;
                    }
                    else
                    {
                        return IntPtr.Zero;
                    }
                }
            }

            IntPtr nonGcStaticsAddress;
            IntPtr gcStaticsAddress;
            if (TryGetStaticsInfoForNamedType(runtimeTypeHandle, out nonGcStaticsAddress, out gcStaticsAddress))
            {
                return gcStaticsAddress;
            }

            // The indirected helper function can be used to find all dynamic types not found via 
            // TryGetStaticsInfoForNamedType as well as generics
            IntPtr ptrToStaticFieldData = TryGetGcStaticFieldData(runtimeTypeHandle);
            if (ptrToStaticFieldData == IntPtr.Zero)
            {
                return IntPtr.Zero;
            }
            else
            {
                unsafe
                {
                    return *(IntPtr*)ptrToStaticFieldData;
                }
            }
        }
开发者ID:justinvp,项目名称:corert,代码行数:49,代码来源:TypeLoaderEnvironment.StaticsLookup.cs

示例9: TryGetNonGcStaticFieldData

        /// <summary>
        /// Get a pointer to a pointer to the nongc static field data of a type. This function works for all generic types
        /// </summary>
        public IntPtr TryGetNonGcStaticFieldData(RuntimeTypeHandle runtimeTypeHandle)
        {
            unsafe
            {
                // Non-generic, non-dynamic static data is found via the FieldAccessMap
                EEType* typeAsEEType = runtimeTypeHandle.ToEETypePtr();
                // Non-generic, non-dynamic types need special handling.
                Debug.Assert(typeAsEEType->IsDynamicType || typeAsEEType->IsGeneric);
            }

            // Search hashtable for static entry
            ExternalReferencesTable staticInfoLookup;
            var parser = GetStaticInfo(runtimeTypeHandle, out staticInfoLookup);
            if (!parser.IsNull)
            {
                var index = parser.GetUnsignedForBagElementKind(BagElementKind.NonGcStaticData);

                return index.HasValue ? staticInfoLookup.GetIntPtrFromIndex(index.Value) : IntPtr.Zero;
            }

            // Not found in hashtable... must be a dynamically created type
            Debug.Assert(runtimeTypeHandle.IsDynamicType());
            return RuntimeAugments.GetNonGcStaticFieldData(runtimeTypeHandle);
        }
开发者ID:justinvp,项目名称:corert,代码行数:27,代码来源:TypeLoaderEnvironment.StaticsLookup.cs

示例10: GetFieldAlignmentAndSize

        public unsafe static void GetFieldAlignmentAndSize(RuntimeTypeHandle fieldType, out int alignment, out int size)
        {
            EEType* typePtr = fieldType.ToEETypePtr();
            if (typePtr->IsValueType)
            {
                size = (int)typePtr->ValueTypeSize;
            }
            else
            {
                size = IntPtr.Size;
            }

            alignment = (int)typePtr->FieldAlignmentRequirement;
        }
开发者ID:nattress,项目名称:corert,代码行数:14,代码来源:TypeLoaderEnvironment.cs

示例11: SetBaseType

 public static unsafe void SetBaseType(this RuntimeTypeHandle rtth, RuntimeTypeHandle baseTypeHandle)
 {
     rtth.ToEETypePtr()->BaseType = baseTypeHandle.ToEETypePtr();
 }
开发者ID:justinvp,项目名称:corert,代码行数:4,代码来源:EETypeCreator.cs

示例12: SetNullableType

 public static unsafe void SetNullableType(this RuntimeTypeHandle rtth, RuntimeTypeHandle T_typeHandle)
 {
     rtth.ToEETypePtr()->NullableType = T_typeHandle.ToEETypePtr();
 }
开发者ID:justinvp,项目名称:corert,代码行数:4,代码来源:EETypeCreator.cs

示例13: SetGenericDefinition

 public static unsafe void SetGenericDefinition(this RuntimeTypeHandle rtth, RuntimeTypeHandle genericDefinitionHandle)
 {
     rtth.ToEETypePtr()->GenericDefinition = genericDefinitionHandle.ToEETypePtr();
 }
开发者ID:justinvp,项目名称:corert,代码行数:4,代码来源:EETypeCreator.cs

示例14: IsPregeneratedOrTemplateRuntimeTypeHandle

        public unsafe static bool IsPregeneratedOrTemplateRuntimeTypeHandle(RuntimeTypeHandle rtth)
        {
#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
            if (!rtth.IsDynamicType())
                return true;

            if (rtth.ToEETypePtr()->DynamicModule == null)
                return true;

            return rtth.ToEETypePtr()->DynamicModule->DynamicTypeSlotDispatchResolve == IntPtr.Zero;
#else
            return true;
#endif
        }
开发者ID:nattress,项目名称:corert,代码行数:14,代码来源:TypeLoaderEnvironment.GVMResolution.cs

示例15: TryGetDefaultParameterValue

        /// <summary>
        /// Retrieves the default value for a parameter of the delegate.
        /// </summary>
        /// <param name="thType">The type of the parameter to retrieve.</param>
        /// <param name="argIndex">The index of the parameter on the method to retrieve.</param>
        /// <param name="defaultValue">The default value of the parameter if available.</param>
        /// <returns>true if the default parameter value is available, otherwise false.</returns>
        internal bool TryGetDefaultParameterValue(RuntimeTypeHandle thType, int argIndex, out object defaultValue)
        {
            defaultValue = null;

            // The LoadDefaultValueString() has the following contract
            // If it returns false, the delegate invoke does not have default values.
            // If it returns true, then the s_DefaultValueString variable is set to 
            // describe the default values for this invoke.
            string defaultValueString = null;
            if (LoadDefaultValueString())
            {
                defaultValueString = s_DefaultValueString;
            }

            // Group index of 0 indicates there are no default parameters
            if (defaultValueString == null)
            {
                return false;
            }
            StringDataParser dataParser = new StringDataParser(defaultValueString);

            // Skip to current argument
            int curArgIndex = 0;
            while (curArgIndex != argIndex)
            {
                int skip = dataParser.GetInt();
                dataParser.Skip(skip);
                curArgIndex++;
            }

            // Discard size of current argument
            int sizeOfCurrentArg = dataParser.GetInt();

            int defaultValueType = dataParser.GetInt();

            switch (defaultValueType)
            {
                case DefaultParamTypeNone:
                default:
                    return false;

                case DefaultParamTypeString:
                    defaultValue = dataParser.GetString();
                    return true;

                case DefaultParamTypeDefault:
                    if (thType.ToEETypePtr().IsValueType)
                    {
                        if (thType.ToEETypePtr().IsNullable)
                        {
                            defaultValue = null;
                            return true;
                        }
                        else
                        {
                            defaultValue = RuntimeImports.RhNewObject(thType.ToEETypePtr());
                            return true;
                        }
                    }
                    else
                    {
                        defaultValue = null;
                        return true;
                    }

                case DefaultParamTypeBool:
                    defaultValue = (dataParser.GetInt() == 1);
                    return true;
                case DefaultParamTypeChar:
                    defaultValue = (char)dataParser.GetInt();
                    return true;
                case DefaultParamTypeI1:
                    defaultValue = (sbyte)dataParser.GetInt();
                    return true;
                case DefaultParamTypeUI1:
                    defaultValue = (byte)dataParser.GetInt();
                    return true;
                case DefaultParamTypeI2:
                    defaultValue = (short)dataParser.GetInt();
                    return true;
                case DefaultParamTypeUI2:
                    defaultValue = (ushort)dataParser.GetInt();
                    return true;
                case DefaultParamTypeI4:
                    defaultValue = dataParser.GetInt();
                    return true;
                case DefaultParamTypeUI4:
                    defaultValue = checked((uint)dataParser.GetLong());
                    return true;
                case DefaultParamTypeI8:
                    defaultValue = dataParser.GetLong();
                    return true;
                case DefaultParamTypeUI8:
//.........这里部分代码省略.........
开发者ID:tijoytom,项目名称:corert,代码行数:101,代码来源:Delegate.DefaultParameters.cs


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