Browse Source

NumericCompoundAssign: implement ILiftableInstruction

pull/1129/head
Daniel Grunwald 8 years ago
parent
commit
f021ec4383
  1. 7
      ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs
  2. 6
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

7
ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs

@ -56,7 +56,7 @@ namespace ICSharpCode.Decompiler.IL @@ -56,7 +56,7 @@ namespace ICSharpCode.Decompiler.IL
}
}
public partial class NumericCompoundAssign : CompoundAssignmentInstruction
public partial class NumericCompoundAssign : CompoundAssignmentInstruction, ILiftableInstruction
{
/// <summary>
/// Gets whether the instruction checks for overflow.
@ -195,13 +195,12 @@ namespace ICSharpCode.Decompiler.IL @@ -195,13 +195,12 @@ namespace ICSharpCode.Decompiler.IL
public partial class UserDefinedCompoundAssign : CompoundAssignmentInstruction
{
public readonly IMethod Method;
public readonly bool IsLifted;
public bool IsLifted => false; // TODO: implement ILi
public UserDefinedCompoundAssign(IMethod method, CompoundAssignmentType compoundAssignmentType, ILInstruction target, ILInstruction value, bool isLifted)
public UserDefinedCompoundAssign(IMethod method, CompoundAssignmentType compoundAssignmentType, ILInstruction target, ILInstruction value)
: base(OpCode.UserDefinedCompoundAssign, compoundAssignmentType, target, value)
{
this.Method = method;
this.IsLifted = isLifted;
Debug.Assert(Method.IsOperator);
Debug.Assert(compoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue || (Method.Name == "op_Increment" || Method.Name == "op_Decrement"));
Debug.Assert(IsValidCompoundAssignmentTarget(Target));

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

@ -292,7 +292,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -292,7 +292,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false; // TODO: add tests and think about whether nullables need special considerations
context.Step($"Compound assignment (user-defined binary)", compoundStore);
newInst = new UserDefinedCompoundAssign(operatorCall.Method, CompoundAssignmentType.EvaluatesToNewValue,
operatorCall.Arguments[0], rhs, operatorCall.IsLifted);
operatorCall.Arguments[0], rhs);
} else {
return false;
}
@ -539,7 +539,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -539,7 +539,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} else {
Call operatorCall = (Call)value;
block.Instructions[pos] = new StLoc(stloc.Variable, new UserDefinedCompoundAssign(
operatorCall.Method, CompoundAssignmentType.EvaluatesToOldValue, stloc.Value, new LdcI4(1), operatorCall.IsLifted));
operatorCall.Method, CompoundAssignmentType.EvaluatesToOldValue, stloc.Value, new LdcI4(1)));
}
return true;
}
@ -587,7 +587,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -587,7 +587,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false; // TODO: add tests and think about whether nullables need special considerations
context.Step("TransformPostIncDecOperator (user-defined)", inst);
inst.Value = new UserDefinedCompoundAssign(operatorCall.Method,
CompoundAssignmentType.EvaluatesToOldValue, inst.Value, new LdcI4(1), operatorCall.IsLifted);
CompoundAssignmentType.EvaluatesToOldValue, inst.Value, new LdcI4(1));
} else {
return false;
}

Loading…
Cancel
Save