Browse Source

Fix use of Clone in NullCoalescingTransform

pull/734/merge
Siegfried Pammer 8 years ago
parent
commit
bcaf6db313
  1. 2
      ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs
  2. 4
      ICSharpCode.Decompiler/IL/Transforms/NullCoalescingTransform.cs

2
ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs

@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.IL
public override void WriteTo(ITextOutput output) public override void WriteTo(ITextOutput output)
{ {
output.Write(OpCode); output.Write(OpCode);
output.Write(" ("); output.Write("(");
valueInst.WriteTo(output); valueInst.WriteTo(output);
output.Write(", "); output.Write(", ");
fallbackInst.WriteTo(output); fallbackInst.WriteTo(output);

4
ICSharpCode.Decompiler/IL/Transforms/NullCoalescingTransform.cs

@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// stloc s(fallbackInst) /// stloc s(fallbackInst)
/// } /// }
/// => /// =>
/// stloc s(if.notnull(valueInst, fallbackInst) /// stloc s(if.notnull(valueInst, fallbackInst))
/// </summary> /// </summary>
bool TransformNullCoalescing(Block block, int i) bool TransformNullCoalescing(Block block, int i)
{ {
@ -57,7 +57,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!ifInstruction.FalseInst.MatchNop() || !(ifInstruction.TrueInst is Block b) || b.Instructions.Count != 1 || !(b.Instructions[0] is StLoc fallbackStore) || fallbackStore.Variable != stloc.Variable) if (!ifInstruction.FalseInst.MatchNop() || !(ifInstruction.TrueInst is Block b) || b.Instructions.Count != 1 || !(b.Instructions[0] is StLoc fallbackStore) || fallbackStore.Variable != stloc.Variable)
return false; return false;
context.Step("TransformNullCoalescing", stloc); context.Step("TransformNullCoalescing", stloc);
stloc.Value.ReplaceWith(new NullCoalescingInstruction(stloc.Value.Clone(), fallbackStore.Value.Clone())); stloc.Value = new NullCoalescingInstruction(stloc.Value, fallbackStore.Value);
return true; return true;
} }
} }

Loading…
Cancel
Save