Example #1
0
        private void EmitDataMember(ref FieldListInProgress fieldListInProgress, uint type, int offset, Utf8String name)
        {
            Debug.Assert((_blob.Size() % 4) == 0);

            bool isStaticField = (uint)offset == 0xFFFFFFFF;

            bool mustSkipEmission;
            uint recordSize = 8 + (isStaticField ? 0 : TypeRecordsBlob.NumericLeafSize(offset)) + DebugInfoBlob.StringLengthEncoded(name);

            ExtendFieldList(ref fieldListInProgress, recordSize, out mustSkipEmission);
            if (mustSkipEmission)
            {
                return;
            }

            _blob.WriteLeafKind(isStaticField ? LeafKind.LF_STATICMEMBER : LeafKind.LF_MEMBER);
            _blob.WriteCV_Visibility(CV_Visibility.Public);
            _blob.WriteDWORD(type);

            if (!isStaticField)
            {
                _blob.WriteNumericLeaf(offset);
            }

            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
        }
Example #2
0
        public uint GetClassTypeIndex(ClassTypeDescriptor classTypeDescriptor)
        {
            FieldListInProgress fieldList = default(FieldListInProgress);

            if (classTypeDescriptor.BaseClassId != 0)
            {
                fieldList = StartFieldList();
                EmitBaseClass(ref fieldList, classTypeDescriptor.BaseClassId);
                FinalizeFieldList(fieldList);
            }

            uint       classTypeIndex = _blob.GetNextTypeIndex();
            Utf8String name           = new Utf8String(classTypeDescriptor.Name);
            uint       recordSize     = 20 + DebugInfoBlob.StringLengthEncoded(name) + TypeRecordsBlob.NumericLeafSize(0) /*size of length */;

            _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
            _blob.WriteLeafKind(classTypeDescriptor.IsStruct != 0 ? LeafKind.LF_STRUCTURE : LeafKind.LF_CLASS);
            _blob.WriteWORD(fieldList.FieldsCount);
            _blob.WriteLF_CLASS_Properties(LF_CLASS_Properties.ForwardReference);
            _blob.WriteDWORD(fieldList.TypeIndexOfFieldList);
            _blob.WriteDWORD(0); // Derivation list is not filled in here
            _blob.WriteDWORD(0); // No vtable shape
            _blob.WriteNumericLeaf(0);
            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();

            return(classTypeIndex);
        }
Example #3
0
        private void ExtendFieldList(ref FieldListInProgress fieldListInProgress, uint newDataLength, out bool mustSkipEmission)
        {
            checked
            {
                if (fieldListInProgress.FieldsCount == 0xFFFF)
                {
                    mustSkipEmission = true;
                    return;
                }

                mustSkipEmission = false;

                fieldListInProgress.FieldsCount++;
                if ((_blob.Size() + newDataLength + 11 /* size of LF_INDEX + maximum possible padding*/ - fieldListInProgress.BlobOffsetCurrentFieldListChunk) > 0xFF00)
                {
                    Debug.Assert((_blob.Size() % 4) == 0);

                    // Add LF_INDEX record to push forward
                    _blob.WriteLeafKind(LeafKind.LF_INDEX);
                    _blob.WriteWORD(0); // pad0
                    uint newFieldListTypeIndex = _blob.GetNextTypeIndex();
                    _blob.WriteDWORD(newFieldListTypeIndex);
                    FinalizeFieldList(fieldListInProgress);

                    Debug.Assert((_blob.Size() % 4) == 0);
                    fieldListInProgress.BlobOffsetCurrentFieldListChunk = _blob.Size();
                    _blob.WriteWORD(0);
                    _blob.WriteLeafKind(LeafKind.LF_FIELDLIST);
                }
            }
        }
Example #4
0
        private FieldListInProgress StartFieldList()
        {
            Debug.Assert((_blob.Size() % 4) == 0);
            FieldListInProgress fieldListInProgress = new FieldListInProgress();

            fieldListInProgress.BlobOffsetCurrentFieldListChunk = _blob.Size();
            fieldListInProgress.TypeIndexOfFieldList            = _blob.GetNextTypeIndex();
            fieldListInProgress.FieldsCount = 0;
            _blob.WriteWORD(0);
            _blob.WriteLeafKind(LeafKind.LF_FIELDLIST);

            return(fieldListInProgress);
        }
Example #5
0
        public uint GetArrayTypeIndex(ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriptor, int targetPointerSize)
        {
            uint simpleArrayDebugType = GetSimpleArrayTypeIndex(arrayTypeDescriptor.ElementType, arrayTypeDescriptor.Size);

            FieldListInProgress fieldList = default(FieldListInProgress);

            fieldList = StartFieldList();
            EmitBaseClass(ref fieldList, classDescriptor.BaseClassId);
            EmitDataMember(ref fieldList, (uint)PrimitiveTypeDescriptor.TYPE_ENUM.T_INT4, targetPointerSize, new Utf8String("count"));
            int nextOffset = targetPointerSize * 2;

            if (arrayTypeDescriptor.IsMultiDimensional != 0)
            {
                for (uint i = 0; i < arrayTypeDescriptor.Rank; i++)
                {
                    EmitDataMember(ref fieldList, (uint)PrimitiveTypeDescriptor.TYPE_ENUM.T_INT4, nextOffset, new Utf8String("length" + i.ToStringInvariant()));
                    nextOffset += 4;
                }
                for (uint i = 0; i < arrayTypeDescriptor.Rank; i++)
                {
                    EmitDataMember(ref fieldList, (uint)PrimitiveTypeDescriptor.TYPE_ENUM.T_INT4, nextOffset, new Utf8String("bounds" + i.ToStringInvariant()));
                    nextOffset += 4;
                }
            }

            EmitDataMember(ref fieldList, simpleArrayDebugType, nextOffset, new Utf8String("values"));

            FinalizeFieldList(fieldList);

            uint       classTypeIndex = _blob.GetNextTypeIndex();
            Utf8String name           = new Utf8String(classDescriptor.Name);
            uint       recordSize     = 20 + DebugInfoBlob.StringLengthEncoded(name) + TypeRecordsBlob.NumericLeafSize(targetPointerSize) /*size of length */;

            _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
            _blob.WriteLeafKind(classDescriptor.IsStruct != 0 ? LeafKind.LF_STRUCTURE : LeafKind.LF_CLASS);
            _blob.WriteWORD(fieldList.FieldsCount);
            _blob.WriteLF_CLASS_Properties(LF_CLASS_Properties.None);
            _blob.WriteDWORD(fieldList.TypeIndexOfFieldList);
            _blob.WriteDWORD(0);                 // Derivation list is not filled in here
            _blob.WriteDWORD(_tiVTShapePointer); // No vtable shape
            _blob.WriteNumericLeaf(targetPointerSize);
            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
            return(classTypeIndex);
        }
Example #6
0
        private void EmitVFuncTab(ref FieldListInProgress fieldListInProgress)
        {
            Debug.Assert((_blob.Size() % 4) == 0);
            bool mustSkipEmission;
            uint recordSize = 8;

            ExtendFieldList(ref fieldListInProgress, recordSize, out mustSkipEmission);
            if (mustSkipEmission)
            {
                return;
            }

            _blob.WriteLeafKind(LeafKind.LF_VFUNCTAB);
            _blob.WriteWORD(0);
            _blob.WriteDWORD(_tiVTShapePointer);
            VerifyBlobEligibleToBeBetweenRecords();
        }
Example #7
0
        public uint GetCompleteClassTypeIndex(ClassTypeDescriptor classTypeDescriptor, ClassFieldsTypeDescriptor classFieldsTypeDescriptior,
                                              DataFieldDescriptor[] fields, StaticDataFieldDescriptor[] statics)
        {
            FieldListInProgress fieldList = default(FieldListInProgress);

            if ((classTypeDescriptor.BaseClassId != 0) || (fields != null && fields.Length > 0) || (classTypeDescriptor.IsStruct == 0))
            {
                fieldList = StartFieldList();
                if (classTypeDescriptor.BaseClassId != 0)
                {
                    EmitBaseClass(ref fieldList, classTypeDescriptor.BaseClassId);
                }

                if (classTypeDescriptor.IsStruct == 0)
                {
                    EmitVFuncTab(ref fieldList);
                }

                if (fields != null)
                {
                    foreach (DataFieldDescriptor field in fields)
                    {
                        EmitDataMember(ref fieldList, field.FieldTypeIndex, (int)field.Offset, new Utf8String(field.Name));
                    }
                }
                FinalizeFieldList(fieldList);
            }

            uint       classTypeIndex = _blob.GetNextTypeIndex();
            Utf8String name           = new Utf8String(classTypeDescriptor.Name);
            uint       recordSize     = 20 + DebugInfoBlob.StringLengthEncoded(name) + TypeRecordsBlob.NumericLeafSize(classFieldsTypeDescriptior.Size) /*size of length */;

            _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
            _blob.WriteLeafKind(classTypeDescriptor.IsStruct != 0 ? LeafKind.LF_STRUCTURE : LeafKind.LF_CLASS);
            _blob.WriteWORD(fieldList.FieldsCount);
            _blob.WriteLF_CLASS_Properties(LF_CLASS_Properties.None);
            _blob.WriteDWORD(fieldList.TypeIndexOfFieldList);
            _blob.WriteDWORD(0);                 // Derivation list is not filled in here
            _blob.WriteDWORD(_tiVTShapePointer); // No vtable shape
            _blob.WriteNumericLeaf(classFieldsTypeDescriptior.Size);
            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
            return(classTypeIndex);
        }
Example #8
0
        private void EmitBaseClass(ref FieldListInProgress fieldListInProgress, uint baseClassIndex)
        {
            Debug.Assert((_blob.Size() % 4) == 0);
            bool mustSkipEmission;

            ExtendFieldList(ref fieldListInProgress, 8 + TypeRecordsBlob.NumericLeafSize(0), out mustSkipEmission);
            if (mustSkipEmission)
            {
                return;
            }

            _blob.WriteLeafKind(LeafKind.LF_BCLASS);
            _blob.WriteCV_Visibility(CV_Visibility.Public);
            _blob.WriteDWORD(baseClassIndex);
            _blob.WriteNumericLeaf(0);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
        }
Example #9
0
        private void EmitEnumerate(ref FieldListInProgress fieldListInProgress, ulong value, Utf8String name)
        {
            Debug.Assert((_blob.Size() % 4) == 0);
            bool mustSkipEmission;
            uint recordSize = 4 + TypeRecordsBlob.NumericLeafSize(value) + DebugInfoBlob.StringLengthEncoded(name);

            ExtendFieldList(ref fieldListInProgress, recordSize, out mustSkipEmission);
            if (mustSkipEmission)
            {
                return;
            }

            _blob.WriteLeafKind(LeafKind.LF_ENUMERATE);
            _blob.WriteCV_Visibility(CV_Visibility.Public);
            _blob.WriteNumericLeaf(value);
            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
        }
Example #10
0
        public uint GetEnumTypeIndex(EnumTypeDescriptor enumTypeDescriptor, EnumRecordTypeDescriptor[] enumerates)
        {
            checked
            {
                FieldListInProgress fieldList = default(FieldListInProgress);
                if ((enumerates != null && enumerates.Length > 0))
                {
                    fieldList = StartFieldList();
                    foreach (EnumRecordTypeDescriptor enumerate in enumerates)
                    {
                        EmitEnumerate(ref fieldList, enumerate.Value, new Utf8String(enumerate.Name));
                    }
                    FinalizeFieldList(fieldList);
                }

                if (enumerates != null)
                {
                    Debug.Assert(checked ((int)enumTypeDescriptor.ElementCount == enumerates.Length));
                }
                if (enumerates == null)
                {
                    Debug.Assert(enumTypeDescriptor.ElementCount == 0);
                }

                uint       enumTypeIndex = _blob.GetNextTypeIndex();
                Utf8String name          = new Utf8String(enumTypeDescriptor.Name);
                uint       recordSize    = 16 + DebugInfoBlob.StringLengthEncoded(name);
                _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
                _blob.WriteLeafKind(LeafKind.LF_ENUM);
                _blob.WriteWORD(fieldList.FieldsCount);
                _blob.WriteWORD(0);
                _blob.WriteDWORD((uint)enumTypeDescriptor.ElementType);
                _blob.WriteDWORD(fieldList.TypeIndexOfFieldList);
                _blob.WriteString(name);
                _blob.AlignToDWORD();
                VerifyBlobEligibleToBeBetweenRecords();
                return(enumTypeIndex);
            }
        }
Example #11
0
        private void FinalizeFieldList(FieldListInProgress fieldListInProgress)
        {
            ushort length = checked ((ushort)(_blob.Size() - fieldListInProgress.BlobOffsetCurrentFieldListChunk - 2));

            _blob.SetWORDAtBlobIndex(fieldListInProgress.BlobOffsetCurrentFieldListChunk, length);
        }