Exemple #1
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);
        }
Exemple #2
0
        public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor)
        {
            uint memberFunctionIdTypeIndex = _blob.GetNextTypeIndex();

            Utf8String name       = new Utf8String(memberIdDescriptor.Name);
            uint       recordSize = 12 + DebugInfoBlob.StringLengthEncoded(name);

            _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
            _blob.WriteLeafKind(LeafKind.LF_MFUNC_ID);
            _blob.WriteDWORD(memberIdDescriptor.MemberFunction);
            _blob.WriteDWORD(memberIdDescriptor.ParentClass);
            _blob.WriteString(name);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
            return(memberFunctionIdTypeIndex);
        }
Exemple #3
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);
        }
        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);
        }
Exemple #5
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();
        }
Exemple #6
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);
            }
        }
Exemple #7
0
 public void WriteBuffer(DebugInfoBlob debugInfoBlob)
 {
     _data.Append(debugInfoBlob._data);
 }
Exemple #8
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();
        }