Example #1
0
        public uint GetSimpleArrayTypeIndex(uint elementType, uint elementSize)
        {
            uint simpleArrayTypeIndex = _blob.GetNextTypeIndex();

            TypeRecordsBlob simpleArrayDataBlob = new TypeRecordsBlob();

            simpleArrayDataBlob.WriteLeafKind(LeafKind.LF_ARRAY);
            simpleArrayDataBlob.WriteDWORD(elementType);
            simpleArrayDataBlob.WriteDWORD((uint)PrimitiveTypeDescriptor.TYPE_ENUM.T_INT4);
            simpleArrayDataBlob.WriteNumericLeaf(elementSize);
            simpleArrayDataBlob.WriteString("");

            uint recordSize = simpleArrayDataBlob.Size() + 2;

            _blob.WriteWORD(checked ((ushort)(_blob.DWORDAlignedSize(recordSize) - 2))); // don't include size of 'length' in 'length'
            _blob.WriteBuffer(simpleArrayDataBlob);
            _blob.AlignToDWORD();
            VerifyBlobEligibleToBeBetweenRecords();
            return(simpleArrayTypeIndex);
        }
Example #2
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);
                }
            }
        }