コード例 #1
0
        private static ImmutableArray <bool> GetFlags(DynamicLocalBucket bucket)
        {
            int   flagCount = bucket.FlagCount;
            ulong flags     = bucket.Flags;
            var   builder   = ArrayBuilder <bool> .GetInstance(flagCount);

            for (int i = 0; i < flagCount; i++)
            {
                builder.Add((flags & (1u << i)) != 0);
            }
            return(builder.ToImmutableAndFree());
        }
コード例 #2
0
        /// <summary>
        /// Does for locals what <see cref="System.Runtime.CompilerServices.DynamicAttribute"/> does for parameters, return types, and fields.
        /// In particular, indicates which occurrences of <see cref="object"/> in the signature are really dynamic.
        /// </summary>
        /// <remarks>
        /// Appears when there are dynamic locals.
        /// Exposed for <see cref="T:Roslyn.Test.PdbUtilities.PdbToXmlConverter"/>.
        /// </remarks>
        /// <exception cref="InvalidOperationException">Bad data.</exception>
        public static ImmutableArray <DynamicLocalBucket> DecodeDynamicLocalsRecord(ImmutableArray <byte> bytes)
        {
            int offset      = 0;
            int bucketCount = ReadInt32(bytes, ref offset);

            var builder = ArrayBuilder <DynamicLocalBucket> .GetInstance(bucketCount);

            for (int i = 0; i < bucketCount; i++)
            {
                const int FlagBytesCount = 64;

                ulong flags = 0UL;
                for (int j = 0; j < FlagBytesCount; j++)
                {
                    var flag = ReadByte(bytes, ref offset) != 0;
                    if (flag)
                    {
                        flags |= 1UL << j;
                    }
                }

                int flagCount = ReadInt32(bytes, ref offset);
                int slotId    = ReadInt32(bytes, ref offset);

                const int NameBytesCount = 128;
                var       pooled         = PooledStringBuilder.GetInstance();
                var       nameBuilder    = pooled.Builder;

                int nameEnd = offset + NameBytesCount;
                while (offset < nameEnd)
                {
                    char ch = (char)ReadInt16(bytes, ref offset);
                    if (ch == 0)
                    {
                        // The Identifier name takes 64 WCHAR no matter how big its actual length is.
                        offset = nameEnd;
                        break;
                    }

                    nameBuilder.Append(ch);
                }

                var name = pooled.ToStringAndFree();

                var bucket = new DynamicLocalBucket(flagCount, flags, slotId, name);
                builder.Add(bucket);
            }

            return(builder.ToImmutableAndFree());
        }
コード例 #3
0
 private static ImmutableArray<bool> GetFlags(DynamicLocalBucket bucket)
 {
     int flagCount = bucket.FlagCount;
     ulong flags = bucket.Flags;
     var builder = ArrayBuilder<bool>.GetInstance(flagCount);
     for (int i = 0; i < flagCount; i++)
     {
         builder.Add((flags & (1u << i)) != 0);
     }
     return builder.ToImmutableAndFree();
 }
コード例 #4
0
        /// <summary>
        /// Does for locals what <see cref="System.Runtime.CompilerServices.DynamicAttribute"/> does for parameters, return types, and fields.
        /// In particular, indicates which occurrences of <see cref="object"/> in the signature are really dynamic.
        /// </summary>
        /// <remarks>
        /// Appears when there are dynamic locals.
        /// Exposed for <see cref="T:Roslyn.Test.PdbUtilities.PdbToXmlConverter"/>.
        /// </remarks>
        /// <exception cref="InvalidOperationException">Bad data.</exception>
        public static ImmutableArray<DynamicLocalBucket> DecodeDynamicLocalsRecord(ImmutableArray<byte> bytes)
        {
            int offset = 0;
            int bucketCount = ReadInt32(bytes, ref offset);

            var builder = ArrayBuilder<DynamicLocalBucket>.GetInstance(bucketCount);
            for (int i = 0; i < bucketCount; i++)
            {
                const int FlagBytesCount = 64;

                ulong flags = 0UL;
                for (int j = 0; j < FlagBytesCount; j++)
                {
                    var flag = ReadByte(bytes, ref offset) != 0;
                    if (flag)
                    {
                        flags |= 1UL << j;
                    }
                }

                int flagCount = ReadInt32(bytes, ref offset);
                int slotId = ReadInt32(bytes, ref offset);

                const int NameBytesCount = 128;
                var pooled = PooledStringBuilder.GetInstance();
                var nameBuilder = pooled.Builder;

                int nameEnd = offset + NameBytesCount;
                while (offset < nameEnd)
                {
                    char ch = (char)ReadInt16(bytes, ref offset);
                    if (ch == 0)
                    {
                        // The Identifier name takes 64 WCHAR no matter how big its actual length is.
                        offset = nameEnd;
                        break;
                    }

                    nameBuilder.Append(ch);
                }

                var name = pooled.ToStringAndFree();

                var bucket = new DynamicLocalBucket(flagCount, flags, slotId, name);
                builder.Add(bucket);
            }

            return builder.ToImmutableAndFree();
        }