Browse Source

Add ExceptionSpecifierILRange to TryCatchHandler

pull/1920/head
Siegfried Pammer 5 years ago
parent
commit
c293613a56
  1. 25
      ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs
  2. 12
      ICSharpCode.Decompiler/IL/Instructions/TryInstruction.cs

25
ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

@ -214,24 +214,29 @@ namespace ICSharpCode.Decompiler.IL @@ -214,24 +214,29 @@ namespace ICSharpCode.Decompiler.IL
public void AddILRange(Interval newRange)
{
if (this.ILRange.IsEmpty) {
this.ILRange = newRange;
return;
this.ILRange = CombineILRange(this.ILRange, newRange);
}
protected static Interval CombineILRange(Interval oldRange, Interval newRange)
{
if (oldRange.IsEmpty) {
return newRange;
}
if (newRange.IsEmpty) {
return;
return oldRange;
}
if (newRange.Start <= this.StartILOffset) {
if (newRange.End < this.StartILOffset) {
this.ILRange = newRange; // use the earlier range
if (newRange.Start <= oldRange.Start) {
if (newRange.End < oldRange.Start) {
return newRange; // use the earlier range
} else {
// join overlapping ranges
this.ILRange = new Interval(newRange.Start, Math.Max(newRange.End, this.ILRange.End));
return new Interval(newRange.Start, Math.Max(newRange.End, oldRange.End));
}
} else if (newRange.Start <= this.ILRange.End) {
} else if (newRange.Start <= oldRange.End) {
// join overlapping ranges
this.ILRange = new Interval(this.StartILOffset, Math.Max(newRange.End, this.ILRange.End));
return new Interval(oldRange.Start, Math.Max(newRange.End, oldRange.End));
}
return oldRange;
}
public void AddILRange(ILInstruction sourceInstruction)

12
ICSharpCode.Decompiler/IL/Instructions/TryInstruction.cs

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.IL
{
@ -175,6 +176,17 @@ namespace ICSharpCode.Decompiler.IL @@ -175,6 +176,17 @@ namespace ICSharpCode.Decompiler.IL
output.Write(' ');
body.WriteTo(output, options);
}
/// <summary>
/// Gets the ILRange of the instructions at the start of the catch-block,
/// that take the exception object and store it in the exception variable slot.
/// </summary>
public Interval ExceptionSpecifierILRange { get; private set; }
public void AddExceptionSpecifierILRange(Interval newRange)
{
ExceptionSpecifierILRange = CombineILRange(ExceptionSpecifierILRange, newRange);
}
}
partial class TryFinally

Loading…
Cancel
Save