From 7a087cd45935a876a4d752c4de5399a9baf52cb2 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Sun, 13 Mar 2011 16:02:54 +0200 Subject: [PATCH] do some cleanup in code --- .../Ast/TextOutputFormatter.cs | 2 +- ICSharpCode.Decompiler/CodeMappings.cs | 39 +------------------ 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs b/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs index 8f5c8104b..dabd1c3a6 100644 --- a/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs +++ b/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs @@ -132,10 +132,10 @@ namespace ICSharpCode.Decompiler.Ast var n = node.Ancestors.FirstOrDefault(a => a.Annotation() != null); if (n != default(AstType)) { MemberMapping mapping = n.Annotation(); - var map = mapping.MemberCodeMappings.Find(s => s.SourceCodeLine == output.CurrentLine); foreach (var range in ranges) { // make sure we have one ILRange per source code line + var map = mapping.MemberCodeMappings.Find(s => s.SourceCodeLine == output.CurrentLine); if (map == null) { mapping.MemberCodeMappings.Add(new SourceCodeMapping { ILInstructionOffset = range, diff --git a/ICSharpCode.Decompiler/CodeMappings.cs b/ICSharpCode.Decompiler/CodeMappings.cs index cbe2a51e6..2e3586e6e 100644 --- a/ICSharpCode.Decompiler/CodeMappings.cs +++ b/ICSharpCode.Decompiler/CodeMappings.cs @@ -49,16 +49,13 @@ namespace ICSharpCode.Decompiler resultList.Add(ILInstructionOffset.From); resultList.Add(ILInstructionOffset.To); + // add the next gap if exists var map = MemberMapping.MemberCodeMappings.Find(m => m.ILInstructionOffset.From >= ILInstructionOffset.To); if (map != null && map.ILInstructionOffset.From != ILInstructionOffset.To) { resultList.Add(ILInstructionOffset.To); resultList.Add(map.ILInstructionOffset.From); } -// var tempList = MemberMapping.GetAllUnknownMappings(ILInstructionOffset.To); -// if (tempList.Count != 0) -// resultList.AddRange(tempList); - return resultList.ToArray(); } } @@ -82,40 +79,6 @@ namespace ICSharpCode.Decompiler /// Gets or sets the source code mappings. /// public List MemberCodeMappings { get; set; } - - /// - /// Gets the list of all unknown/gaps code mappings greater than a value.
- /// Eg.: for (0-9, 11-14, 16-27) the return list is (9,11,14,16) for start value 0 (or lower than 9). - ///
- /// Start value. - /// - public List GetAllUnknownMappings(int startValue) - { - var result = new List(); - var data = MemberCodeMappings.OrderBy(m => m.ILInstructionOffset.From); - var prevMap = data.ElementAt(0); - - for (int i = 1; i < data.Count(); ++i) { - var map = data.ElementAt(i); - // consider only the next mappings - if (map.ILInstructionOffset.To <= startValue) { - prevMap = map; - continue; - } - - // if there is not gap, move on - if (prevMap.ILInstructionOffset.To == map.ILInstructionOffset.From) { - prevMap = map; - continue; - } - - result.Add(prevMap.ILInstructionOffset.To); - result.Add(map.ILInstructionOffset.From); - prevMap = map; - } - - return result; - } } public static class CodeMappings