Browse Source

Compound assignment doesn't support lifting yet.

pull/870/head
Daniel Grunwald 8 years ago
parent
commit
735f8e070d
  1. 1
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
  2. 10
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

1
ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

@ -274,6 +274,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -274,6 +274,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
if (inst.Value is BinaryNumericInstruction binary
&& !binary.IsLifted
&& binary.Left.MatchLdObj(out ILInstruction target, out IType t)
&& inst.Target.Match(target).Success)
{

10
ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

@ -151,6 +151,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -151,6 +151,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
var usages = next.Descendants.Where(d => d.MatchLdLoc(localVariable)).ToArray();
if (usages.Length != 1)
return false;
if (binary.IsLifted)
return false;
context.Step($"Compound assignment to '{owner.Name}'", setterCall);
block.Instructions.RemoveAt(i + 1);
block.Instructions.RemoveAt(i);
@ -230,6 +232,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -230,6 +232,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
var binary = nextInst.Value as BinaryNumericInstruction;
if (inst.Variable.Kind != VariableKind.StackSlot || nextInst.Variable.Kind == VariableKind.StackSlot || binary == null)
return false;
if (binary.IsLifted)
return false;
if ((binary.Operator != BinaryNumericOperator.Add && binary.Operator != BinaryNumericOperator.Sub) || !binary.Left.MatchLdLoc(inst.Variable) || !binary.Right.MatchLdcI4(1))
return false;
context.Step($"TransformPostIncDecOperator", inst);
@ -269,6 +273,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -269,6 +273,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (binary == null || !binary.Left.MatchLdLoc(nextInst.Variable) || !binary.Right.MatchLdcI4(1)
|| (binary.Operator != BinaryNumericOperator.Add && binary.Operator != BinaryNumericOperator.Sub))
return false;
if (binary.IsLifted)
return false;
context.Step($"TransformPostIncDecOperator", inst);
var assignment = new CompoundAssignmentInstruction(binary.Operator, new LdObj(inst.Value, targetType), binary.Right, targetType, binary.CheckForOverflow, binary.Sign, CompoundAssignmentType.EvaluatesToOldValue);
stobj.ReplaceWith(new StLoc(nextInst.Variable, assignment));
@ -319,6 +325,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -319,6 +325,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (binary == null || !binary.Left.MatchLdLoc(fieldValue.Variable) || !binary.Right.MatchLdcI4(1)
|| (binary.Operator != BinaryNumericOperator.Add && binary.Operator != BinaryNumericOperator.Sub))
return false;
if (binary.IsLifted)
return false;
context.Step($"TransformCSharp4PostIncDecOperatorOnAddress", baseFieldAddress);
var assignment = new CompoundAssignmentInstruction(binary.Operator, new LdObj(baseAddress, t), binary.Right, t, binary.CheckForOverflow, binary.Sign, CompoundAssignmentType.EvaluatesToOldValue);
stobj.ReplaceWith(new StLoc(fieldValueCopyToLocal.Variable, assignment));
@ -349,6 +357,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -349,6 +357,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
var binary = stobj.Value as BinaryNumericInstruction;
if (binary == null || !binary.Left.MatchLdLoc(inst.Variable) || !binary.Right.MatchLdcI4(1))
return false;
if (binary.IsLifted)
return false;
context.Step($"TransformPostIncDecOnStaticField", inst);
var assignment = new CompoundAssignmentInstruction(binary.Operator, inst.Value, binary.Right, type, binary.CheckForOverflow, binary.Sign, CompoundAssignmentType.EvaluatesToOldValue);
stobj.ReplaceWith(new StLoc(inst.Variable, assignment));

Loading…
Cancel
Save