Browse Source

Use Nop instead of InvalidExpression to hold the "goto from catch-block to try-block" comment

pull/2566/head
Daniel Grunwald 4 years ago
parent
commit
77dcbbee86
  1. 2
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  2. 2
      ICSharpCode.Decompiler/IL/BlockBuilder.cs
  3. 3
      ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs
  4. 1
      ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs

2
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -4408,7 +4408,7 @@ namespace ICSharpCode.Decompiler.CSharp
protected internal override TranslatedExpression VisitInvalidExpression(InvalidExpression inst, TranslationContext context) protected internal override TranslatedExpression VisitInvalidExpression(InvalidExpression inst, TranslationContext context)
{ {
string message = inst.Severity; string message = "Error";
if (inst.StartILOffset != 0) if (inst.StartILOffset != 0)
{ {
message += $" near IL_{inst.StartILOffset:x4}"; message += $" near IL_{inst.StartILOffset:x4}";

2
ICSharpCode.Decompiler/IL/BlockBuilder.cs

@ -385,7 +385,7 @@ namespace ICSharpCode.Decompiler.IL
} }
var usedLabels = new LongSet(dispatch.TargetILOffsets.Select(offset => LongInterval.Inclusive(offset, offset))); var usedLabels = new LongSet(dispatch.TargetILOffsets.Select(offset => LongInterval.Inclusive(offset, offset)));
switchInst.Sections.Add(new SwitchSection { Labels = usedLabels.Invert(), Body = new Branch(tryBody.EntryPoint) }); switchInst.Sections.Add(new SwitchSection { Labels = usedLabels.Invert(), Body = new Branch(tryBody.EntryPoint) });
dispatchBlock.Instructions.Add(new InvalidExpression("ILSpy has introduced the following switch to emulate a goto from catch-block to try-block") { Severity = "Note" }); dispatchBlock.Instructions.Add(new Nop { Comment = "ILSpy has introduced the following switch to emulate a goto from catch-block to try-block" });
dispatchBlock.Instructions.Add(switchInst); dispatchBlock.Instructions.Add(switchInst);
tryBody.Blocks.Insert(0, dispatchBlock); tryBody.Blocks.Insert(0, dispatchBlock);

3
ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs

@ -15,7 +15,6 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -71,7 +70,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
} }
// Remove 'nop' instructions // Remove 'nop' instructions
block.Instructions.RemoveAll(inst => inst.OpCode == OpCode.Nop); block.Instructions.RemoveAll(inst => inst is Nop { Comment: null });
} }
private static void RemoveDeadStackStores(Block block, ILTransformContext context) private static void RemoveDeadStackStores(Block block, ILTransformContext context)

1
ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs

@ -89,7 +89,6 @@ namespace ICSharpCode.Decompiler.IL
partial class InvalidExpression : SimpleInstruction partial class InvalidExpression : SimpleInstruction
{ {
public string Severity = "Error";
public string? Message; public string? Message;
public StackType ExpectedResultType = StackType.Unknown; public StackType ExpectedResultType = StackType.Unknown;

Loading…
Cancel
Save