public ImmutableSortedSet <int> GetInScopeHoistedLocalIndices(int ilOffset, ref ILSpan methodContextReuseSpan) { if (HoistedLocalScopeRecords.IsDefaultOrEmpty) { return(ImmutableSortedSet <int> .Empty); } methodContextReuseSpan = MethodContextReuseConstraints.CalculateReuseSpan( ilOffset, methodContextReuseSpan, HoistedLocalScopeRecords.Select(record => new ILSpan((uint)record.StartOffset, (uint)(record.StartOffset + record.Length)))); var scopesBuilder = ArrayBuilder <int> .GetInstance(); int i = 0; foreach (var record in HoistedLocalScopeRecords) { var delta = ilOffset - record.StartOffset; if (0 <= delta && delta < record.Length) { scopesBuilder.Add(i); } i++; } var result = scopesBuilder.ToImmutableSortedSet(); scopesBuilder.Free(); return(result); }
private static ILSpan GetReuseSpan(ArrayBuilder <ISymUnmanagedScope> scopes, int ilOffset, bool isEndInclusive) { return(MethodContextReuseConstraints.CalculateReuseSpan( ilOffset, ILSpan.MaxValue, scopes.Select(scope => new ILSpan((uint)scope.GetStartOffset(), (uint)(scope.GetEndOffset() + (isEndInclusive ? 1 : 0)))))); }