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
public void AddILRange(Interval newRange) public void AddILRange(Interval newRange)
{ {
if (this.ILRange.IsEmpty) { this.ILRange = CombineILRange(this.ILRange, newRange);
this.ILRange = newRange; }
return;
protected static Interval CombineILRange(Interval oldRange, Interval newRange)
{
if (oldRange.IsEmpty) {
return newRange;
} }
if (newRange.IsEmpty) { if (newRange.IsEmpty) {
return; return oldRange;
} }
if (newRange.Start <= this.StartILOffset) { if (newRange.Start <= oldRange.Start) {
if (newRange.End < this.StartILOffset) { if (newRange.End < oldRange.Start) {
this.ILRange = newRange; // use the earlier range return newRange; // use the earlier range
} else { } else {
// join overlapping ranges // 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 // 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) public void AddILRange(ILInstruction sourceInstruction)

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

@ -19,6 +19,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.IL namespace ICSharpCode.Decompiler.IL
{ {
@ -175,6 +176,17 @@ namespace ICSharpCode.Decompiler.IL
output.Write(' '); output.Write(' ');
body.WriteTo(output, options); 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 partial class TryFinally

Loading…
Cancel
Save