From 2d1692c72f040bfd5c3fcbc8b843d113ff020954 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 16 Sep 2017 20:32:30 +0200 Subject: [PATCH] Add value parameter to Leave ctor. --- ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs | 3 +-- ICSharpCode.Decompiler/IL/ILReader.cs | 4 ++-- ICSharpCode.Decompiler/IL/Instructions/Leave.cs | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs index 020d53fcc..385468c82 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs @@ -447,8 +447,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow moveNextFunction.ReleaseRef(); foreach (var branch in function.Descendants.OfType()) { if (branch.TargetBlock == setResultAndExitBlock) { - branch.ReplaceWith(new Leave((BlockContainer)function.Body) { - Value = resultVar == null ? (ILInstruction)new Nop() : new LdLoc(resultVar), + branch.ReplaceWith(new Leave((BlockContainer)function.Body, resultVar == null ? null : new LdLoc(resultVar)) { ILRange = branch.ILRange }); } diff --git a/ICSharpCode.Decompiler/IL/ILReader.cs b/ICSharpCode.Decompiler/IL/ILReader.cs index f3d3ed42a..95430694b 100644 --- a/ICSharpCode.Decompiler/IL/ILReader.cs +++ b/ICSharpCode.Decompiler/IL/ILReader.cs @@ -526,7 +526,7 @@ namespace ICSharpCode.Decompiler.IL case Cil.Code.Dup: return Push(Peek()); case Cil.Code.Endfilter: - return new Leave(null) { Value = Pop() }; + return new Leave(null, Pop()); case Cil.Code.Endfinally: return new Leave(null); case Cil.Code.Initblk: @@ -943,7 +943,7 @@ namespace ICSharpCode.Decompiler.IL if (methodReturnStackType == StackType.Void) return new IL.Leave(mainContainer); else - return new IL.Leave(mainContainer) { Value = Pop(methodReturnStackType) }; + return new IL.Leave(mainContainer, Pop(methodReturnStackType)); } private ILInstruction DecodeLdstr() diff --git a/ICSharpCode.Decompiler/IL/Instructions/Leave.cs b/ICSharpCode.Decompiler/IL/Instructions/Leave.cs index c865ce0d8..136ef66aa 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/Leave.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/Leave.cs @@ -34,12 +34,12 @@ namespace ICSharpCode.Decompiler.IL { BlockContainer targetContainer; - public Leave(BlockContainer targetContainer) : base(OpCode.Leave) + public Leave(BlockContainer targetContainer, ILInstruction value = null) : base(OpCode.Leave) { // Note: ILReader will create Leave instructions with targetContainer==null to represent 'endfinally', // the targetContainer will then be filled in by BlockBuilder this.targetContainer = targetContainer; - this.Value = new Nop(); + this.Value = value ?? new Nop(); } protected override InstructionFlags ComputeFlags()