Пример #1
0
        public ImmutableSortedSet<int> GetInScopeHoistedLocalIndices(int ilOffset, ref MethodContextReuseConstraints methodContextReuseConstraints)
        {
            if (this.HoistedLocalScopeRecords.IsDefault)
            {
                return ImmutableSortedSet<int>.Empty;
            }

            var constraintsBuilder = 
                new MethodContextReuseConstraints.Builder(methodContextReuseConstraints, ilOffset, areRangesEndInclusive: false);

            var scopesBuilder = ArrayBuilder<int>.GetInstance();
            int i = 0;
            foreach (var record in this.HoistedLocalScopeRecords)
            {
                constraintsBuilder.AddRange(record.StartOffset, record.StartOffset + record.Length);

                var delta = ilOffset - record.StartOffset;
                if (0 <= delta && delta < record.Length)
                {
                    scopesBuilder.Add(i);
                }

                i++;
            }

            methodContextReuseConstraints = constraintsBuilder.Build();

            var result = scopesBuilder.ToImmutableSortedSet();
            scopesBuilder.Free();
            return result;
        }
Пример #2
0
        public ImmutableSortedSet <int> GetInScopeHoistedLocalIndices(int ilOffset, ref MethodContextReuseConstraints methodContextReuseConstraints)
        {
            if (this.HoistedLocalScopeRecords.IsDefault)
            {
                return(ImmutableSortedSet <int> .Empty);
            }

            var constraintsBuilder =
                new MethodContextReuseConstraints.Builder(methodContextReuseConstraints, ilOffset, areRangesEndInclusive: false);

            var scopesBuilder = ArrayBuilder <int> .GetInstance();

            int i = 0;

            foreach (var record in this.HoistedLocalScopeRecords)
            {
                constraintsBuilder.AddRange(record.StartOffset, record.StartOffset + record.Length);

                var delta = ilOffset - record.StartOffset;
                if (0 <= delta && delta < record.Length)
                {
                    scopesBuilder.Add(i);
                }

                i++;
            }

            methodContextReuseConstraints = constraintsBuilder.Build();

            var result = scopesBuilder.ToImmutableSortedSet();

            scopesBuilder.Free();
            return(result);
        }
Пример #3
0
        internal static MethodContextReuseConstraints GetReuseConstraints(this ArrayBuilder <ISymUnmanagedScope> scopes, Guid moduleVersionId, int methodToken, int methodVersion, int ilOffset, bool isEndInclusive)
        {
            var builder = new MethodContextReuseConstraints.Builder(moduleVersionId, methodToken, methodVersion, ilOffset, isEndInclusive);

            foreach (ISymUnmanagedScope scope in scopes)
            {
                builder.AddRange((uint)scope.GetStartOffset(), (uint)scope.GetEndOffset());
            }
            return(builder.Build());
        }
        public void EndExclusive()
        {
            var moduleVersionId = Guid.NewGuid();
            const int methodToken = 0x06000001;
            const int methodVersion = 1;

            var builder = new MethodContextReuseConstraints.Builder(moduleVersionId, methodToken, methodVersion, ilOffset: 5, areRangesEndInclusive: false);
            Assert.True(builder.Build().HasExpectedSpan(0u, uint.MaxValue));

            builder.AddRange(1, 9);
            Assert.True(builder.Build().HasExpectedSpan(1, 9));

            builder.AddRange(2, 8);
            Assert.True(builder.Build().HasExpectedSpan(2, 8));

            builder.AddRange(1, 3);
            Assert.True(builder.Build().HasExpectedSpan(3, 8));

            builder.AddRange(7, 9);
            Assert.True(builder.Build().HasExpectedSpan(3, 7));
        }