Browse Source

Minor clean-ups.

pull/191/merge
Eusebiu Marcu 14 years ago
parent
commit
6bae4e5180
  1. 2
      Debugger/ILSpy.Debugger/Bookmarks/BookmarkManager.cs
  2. 13
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  3. 12
      ICSharpCode.Decompiler/CodeMappings.cs
  4. 9
      ICSharpCode.Decompiler/PlainTextOutput.cs

2
Debugger/ILSpy.Debugger/Bookmarks/BookmarkManager.cs

@ -166,7 +166,7 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks @@ -166,7 +166,7 @@ namespace ICSharpCode.ILSpy.Debugger.Bookmarks
MemberReference memberReference;
int newline;
if (newMappings[markerType.MetadataToken.ToInt32()].GetSourceCodeFromMetadataTokenAndOffset(token, instruction.ILInstructionOffset.From, out memberReference, out newline)) {
if (newMappings[markerType.MetadataToken.ToInt32()].GetInstructionByTokenAndOffset(token, instruction.ILInstructionOffset.From, out memberReference, out newline)) {
// 4. create breakpoint for new languages
CurrentLineBookmark.SetPosition(memberReference, newline, 0, newline, 0);
}

13
Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs

@ -808,14 +808,10 @@ namespace ICSharpCode.ILSpy.Debugger.Services @@ -808,14 +808,10 @@ namespace ICSharpCode.ILSpy.Debugger.Services
int line;
MemberReference memberReference;
if (DebugData.CodeMappings.ContainsKey(token)) {
if (DebugData.CodeMappings[token].GetSourceCodeFromMetadataTokenAndOffset(token, ilOffset, out memberReference, out line)) {
if (DebugData.CodeMappings.ContainsKey(token) &&
DebugData.CodeMappings[token].GetInstructionByTokenAndOffset(token, ilOffset, out memberReference, out line)) {
DebuggerService.RemoveCurrentLineMarker();
DebuggerService.JumpToCurrentLine(memberReference, line, 0, line, 0);
} else {
// is possible that the type is not decompiled yet, so we must do a decompilation on demand
DecompileOnDemand(frame);
}
}
else {
// is possible that the type is not decompiled yet, so we must do a decompilation on demand
@ -888,7 +884,8 @@ namespace ICSharpCode.ILSpy.Debugger.Services @@ -888,7 +884,8 @@ namespace ICSharpCode.ILSpy.Debugger.Services
else if (memberReference is EventDefinition)
builder.AddEvent(memberReference as EventDefinition);
builder.GenerateCode(new PlainTextOutput());
var output = new PlainTextOutput();
builder.GenerateCode(output);
DebugData.CodeMappings = codeMappings = builder.CodeMappings;
DebugData.DecompiledMemberReferences = members = builder.DecompiledMemberReferences;
}
@ -897,7 +894,7 @@ namespace ICSharpCode.ILSpy.Debugger.Services @@ -897,7 +894,7 @@ namespace ICSharpCode.ILSpy.Debugger.Services
// try jump
int line;
codeMappings = codeMappings ?? DebugData.CodeMappings;
if (codeMappings[token].GetSourceCodeFromMetadataTokenAndOffset(token, ilOffset, out memberReference, out line)) {
if (codeMappings[token].GetInstructionByTokenAndOffset(token, ilOffset, out memberReference, out line)) {
DebuggerService.RemoveCurrentLineMarker();
DebuggerService.JumpToCurrentLine(memberReference, line, 0, line, 0);
} else {

12
ICSharpCode.Decompiler/CodeMappings.cs

@ -105,9 +105,9 @@ namespace ICSharpCode.Decompiler @@ -105,9 +105,9 @@ namespace ICSharpCode.Decompiler
currentList.AddRange(MemberMapping.InvertedList);
} else {
// if the current list contains the last mapping, add also the last gap
// var lastInverted = MemberMapping.InvertedList.LastOrDefault();
// if (lastInverted != null && lastInverted.From == currentList[currentList.Count - 1].To)
// currentList.Add(lastInverted);
var lastInverted = MemberMapping.InvertedList.LastOrDefault();
if (lastInverted != null && lastInverted.From == currentList[currentList.Count - 1].To)
currentList.Add(lastInverted);
}
// set the output
@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler @@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler
if (map == null) {
// get the immediate next one
map = maping.MemberCodeMappings.Find(m => m.ILInstructionOffset.From >= ilOffset);
map = maping.MemberCodeMappings.Find(m => m.ILInstructionOffset.From > ilOffset);
isMatch = false;
if (map == null)
map = maping.MemberCodeMappings.LastOrDefault(); // get the last
@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler @@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler
/// <param name="typeName">Type definition.</param>
/// <param name="line">Line number.</param>
/// <remarks>It is possible to exist to different types from different assemblies with the same metadata token.</remarks>
public static bool GetSourceCodeFromMetadataTokenAndOffset(
public static bool GetInstructionByTokenAndOffset(
this List<MemberMapping> codeMappings,
int token,
int ilOffset,
@ -303,7 +303,7 @@ namespace ICSharpCode.Decompiler @@ -303,7 +303,7 @@ namespace ICSharpCode.Decompiler
var codeMapping = mapping.MemberCodeMappings.Find(
cm => cm.ILInstructionOffset.From <= ilOffset && ilOffset <= cm.ILInstructionOffset.To - 1);
if (codeMapping == null) {
codeMapping = mapping.MemberCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset));
codeMapping = mapping.MemberCodeMappings.Find(cm => cm.ILInstructionOffset.From > ilOffset);
if (codeMapping == null) {
codeMapping = mapping.MemberCodeMappings.LastOrDefault();
if (codeMapping == null)

9
ICSharpCode.Decompiler/PlainTextOutput.cs

@ -26,22 +26,23 @@ namespace ICSharpCode.Decompiler @@ -26,22 +26,23 @@ namespace ICSharpCode.Decompiler
readonly TextWriter writer;
int indent;
bool needsIndent;
int lineNumber = 1;
public PlainTextOutput(TextWriter writer)
{
if (writer == null)
throw new ArgumentNullException("writer");
this.writer = writer;
CurrentLine = 1;
}
public PlainTextOutput()
{
this.writer = new StringWriter();
CurrentLine = 1;
}
public int CurrentLine { get; set; }
public int CurrentLine {
get { return lineNumber; }
}
public override string ToString()
{
@ -82,9 +83,9 @@ namespace ICSharpCode.Decompiler @@ -82,9 +83,9 @@ namespace ICSharpCode.Decompiler
public void WriteLine()
{
lineNumber++;
writer.WriteLine();
needsIndent = true;
++CurrentLine;
}
public void WriteDefinition(string text, object definition)

Loading…
Cancel
Save