private int DefineSequencePoints()
        {
            // Sequence Points Blob
            var bb = new ByteBuffer(ilOffsets.Length * 10);

            // header
            bb.WriteCompressedUInt(localVarSigToken);   // LocalSignature
            // we don't support multiple documents per method, so we don't need to write InitialDocument

            // sequence-point-record
            bb.WriteCompressedUInt(ilOffsets[0]);
            WriteDeltas(bb, endLines[0] - startLines[0], endColumns[0] - startColumns[0]);
            bb.WriteCompressedUInt(startLines[0]);
            bb.WriteCompressedUInt(startColumns[0]);
            for (var i = 1; i < ilOffsets.Length; i++)
            {
                // make sure we don't accidentally encode a document-record
                Debug.Assert(ilOffsets[i] > ilOffsets[i - 1]);
                // make sure we don't accidentally encode a hidden-sequence-point-record
                Debug.Assert(startLines[i] != endLines[i] || startColumns[i] != endColumns[i]);
                // sequence-point-record
                bb.WriteCompressedUInt(ilOffsets[i] - ilOffsets[i - 1]);
                WriteDeltas(bb, endLines[i] - startLines[i], endColumns[i] - startColumns[i]);
                bb.WriteCompressedInt(startLines[i] - startLines[i - 1]);
                bb.WriteCompressedInt(startColumns[i] - startColumns[i - 1]);
            }
            return(Blobs.Add(bb));
        }
Exemplo n.º 2
0
        uint WriteUTF8(string s)
        {
            if (s is null)
            {
                helper.Error("String is null");
                s = string.Empty;
            }
            var bytes = Encoding.UTF8.GetBytes(s);

            return(blobHeap.Add(bytes));
        }