예제 #1
0
파일: EEType.cs 프로젝트: nattress/corert
        public UInt32 GetFieldOffset(EETypeField eField)
        {
            // First part of EEType consists of the fixed portion followed by the vtable.
            UInt32 cbOffset = (UInt32)(sizeof(EEType) + (IntPtr.Size * _usNumVtableSlots));

            // Then we have the interface map.
            if (eField == EETypeField.ETF_InterfaceMap)
            {
                Debug.Assert(NumInterfaces > 0);
                return cbOffset;
            }
            cbOffset += (UInt32)(sizeof(EEInterfaceInfo) * NumInterfaces);

            // Followed by the pointer to the finalizer method.
            if (eField == EETypeField.ETF_Finalizer)
            {
                Debug.Assert(IsFinalizable);
                return cbOffset;
            }
            if (IsFinalizable)
                cbOffset += (UInt32)IntPtr.Size;

            // Followed by the pointer to the optional fields.
            if (eField == EETypeField.ETF_OptionalFieldsPtr)
            {
                Debug.Assert(HasOptionalFields);
                return cbOffset;
            }
            if (HasOptionalFields)
                cbOffset += (UInt32)IntPtr.Size;

            // Followed by the pointer to the type target of a Nullable<T>.
            if (eField == EETypeField.ETF_NullableType)
            {
                Debug.Assert(IsNullable);
                return cbOffset;
            }

            // OR, followed by the pointer to the sealed virtual slots
            if (eField == EETypeField.ETF_SealedVirtualSlots)
                return cbOffset;

            if (IsNullable || (RareFlags & EETypeRareFlags.IsDynamicTypeWithSealedVTableEntriesFlag) != 0)
                cbOffset += (UInt32)IntPtr.Size;

            // in the case of sealed vtable entries on static types, we have a UInt sized relative pointer
            if ((RareFlags & EETypeRareFlags.HasSealedVTableEntriesFlag) != 0)
                cbOffset += 4;

            if (eField == EETypeField.ETF_DynamicDispatchMap)
            {
                Debug.Assert(IsDynamicType);
                return cbOffset;
            }
            if ((RareFlags & EETypeRareFlags.HasDynamicallyAllocatedDispatchMapFlag) != 0)
                cbOffset += (UInt32)IntPtr.Size;

            if (eField == EETypeField.ETF_GenericDefinition)
            {
                Debug.Assert(IsGeneric);
                return cbOffset;
            }
            if (IsGeneric)
                cbOffset += (UInt32)IntPtr.Size;

            if (eField == EETypeField.ETF_GenericComposition)
            {
                Debug.Assert(IsGeneric);
                return cbOffset;
            }
            if (IsGeneric)
                cbOffset += (UInt32)IntPtr.Size;

            if (eField == EETypeField.ETF_DynamicModule)
            {
                return cbOffset;
            }

            if ((RareFlags & EETypeRareFlags.HasDynamicModuleFlag) != 0)
                cbOffset += (UInt32)IntPtr.Size;

            if (eField == EETypeField.ETF_DynamicTemplateType)
            {
                Debug.Assert(IsDynamicType);
                return cbOffset;
            }

            // after this we have statics information for dynamic types

            Debug.Assert(false, "Unknown EEType field type");
            return 0;
        }
예제 #2
0
        public UInt32 GetFieldOffset(EETypeField eField)
        {
            // First part of EEType consists of the fixed portion followed by the vtable.
            UInt32 cbOffset = (UInt32)(sizeof(EEType) + (IntPtr.Size * _usNumVtableSlots));

            // Then we have the interface map.
            if (eField == EETypeField.ETF_InterfaceMap)
            {
                Debug.Assert(NumInterfaces > 0);
                return(cbOffset);
            }
            cbOffset += (UInt32)(sizeof(EEInterfaceInfo) * NumInterfaces);

            // Followed by the pointer to the finalizer method.
            if (eField == EETypeField.ETF_Finalizer)
            {
                Debug.Assert(IsFinalizable);
                return(cbOffset);
            }
            if (IsFinalizable)
            {
                cbOffset += (UInt32)IntPtr.Size;
            }

            // Followed by the pointer to the optional fields.
            if (eField == EETypeField.ETF_OptionalFieldsPtr)
            {
                Debug.Assert(HasOptionalFields);
                return(cbOffset);
            }
            if (HasOptionalFields)
            {
                cbOffset += (UInt32)IntPtr.Size;
            }

            // Followed by the pointer to the type target of a Nullable<T>.
            if (eField == EETypeField.ETF_NullableType)
            {
                Debug.Assert(IsNullable);
                return(cbOffset);
            }

            // OR, followed by the pointer to the sealed virtual slots
            if (eField == EETypeField.ETF_SealedVirtualSlots)
            {
                return(cbOffset);
            }

            if (IsNullable || (RareFlags & EETypeRareFlags.IsDynamicTypeWithSealedVTableEntriesFlag) != 0)
            {
                cbOffset += (UInt32)IntPtr.Size;
            }

            // in the case of sealed vtable entries on static types, we have a UInt sized relative pointer
            if ((RareFlags & EETypeRareFlags.HasSealedVTableEntriesFlag) != 0)
            {
                cbOffset += 4;
            }

            if (eField == EETypeField.ETF_DynamicDispatchMap)
            {
                Debug.Assert(IsDynamicType);
                return(cbOffset);
            }
            if ((RareFlags & EETypeRareFlags.HasDynamicallyAllocatedDispatchMapFlag) != 0)
            {
                cbOffset += (UInt32)IntPtr.Size;
            }

            if (eField == EETypeField.ETF_GenericDefinition)
            {
                Debug.Assert(IsGeneric);
                return(cbOffset);
            }
            if (IsGeneric)
            {
                cbOffset += (UInt32)IntPtr.Size;
            }

            if (eField == EETypeField.ETF_GenericComposition)
            {
                Debug.Assert(IsGeneric);
                return(cbOffset);
            }
            if (IsGeneric)
            {
                cbOffset += (UInt32)IntPtr.Size;
            }

            if (eField == EETypeField.ETF_DynamicTemplateType)
            {
                Debug.Assert(IsDynamicType);
                return(cbOffset);
            }

            // after this we have statics information for dynamic types

            Debug.Assert(false, "Unknown EEType field type");
            return(0);
        }
예제 #3
0
파일: EEType.cs 프로젝트: mjp41/corert
        public UInt32 GetFieldOffset(EETypeField eField)
        {
            // First part of EEType consists of the fixed portion followed by the vtable.
            UInt32 cbOffset = (UInt32)(sizeof(EEType) + (IntPtr.Size * _usNumVtableSlots));

            // Then we have the interface map.
            if (eField == EETypeField.ETF_InterfaceMap)
            {
                Debug.Assert(NumInterfaces > 0);
                return cbOffset;
            }
            cbOffset += (UInt32)(sizeof(EEInterfaceInfo) * NumInterfaces);

            // Followed by the pointer to the finalizer method.
            if (eField == EETypeField.ETF_Finalizer)
            {
                Debug.Assert(IsFinalizable);
                return cbOffset;
            }
            if (IsFinalizable)
                cbOffset += (UInt32)IntPtr.Size;

            // Followed by the pointer to the optional fields.
            if (eField == EETypeField.ETF_OptionalFieldsPtr)
            {
                Debug.Assert(HasOptionalFields);
                return cbOffset;
            }
            if (HasOptionalFields)
                cbOffset += (UInt32)IntPtr.Size;

            // Followed by the pointer to the type target of a Nullable<T>.
            if (eField == EETypeField.ETF_NullableType)
            {
                Debug.Assert(IsNullable);
                return cbOffset;
            }

            // OR, followed by the pointer to the sealed virtual slots
            if (eField == EETypeField.ETF_SealedVirtualSlots)
                return cbOffset;

            if (IsNullable || RareFlags.HasFlag(EETypeRareFlags.IsDynamicTypeWithSealedVTableEntriesFlag))
                cbOffset += (UInt32)IntPtr.Size;

            if (eField == EETypeField.ETF_DynamicDispatchMap)
            {
                Debug.Assert(IsDynamicType);
                return cbOffset;
            }
            if (RareFlags.HasFlag(EETypeRareFlags.HasDynamicallyAllocatedDispatchMapFlag))
                cbOffset += (UInt32)IntPtr.Size;

            if (eField == EETypeField.ETF_DynamicTemplateType)
            {
                Debug.Assert(IsDynamicType);
                return cbOffset;
            }

            Debug.Assert(false, "Unknown EEType field type");
            return 0;
        }