diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
index fd7bd3f75..b14953951 100644
--- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
+++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
@@ -95,7 +95,7 @@
-
+
diff --git a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs
index ff8264f94..464df9521 100644
--- a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs
+++ b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs
@@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.ILAst
TransformDecimalCtorToConstant,
SimplifyLdObjAndStObj,
SimplifyCustomShortCircuit,
- SimplifyNullableOperators,
+ SimplifyLiftedOperators,
TransformArrayInitializers,
TransformMultidimensionalArrayInitializers,
TransformObjectInitializers,
@@ -152,8 +152,8 @@ namespace ICSharpCode.Decompiler.ILAst
if (abortBeforeStep == ILAstOptimizationStep.SimplifyCustomShortCircuit) return;
modified |= block.RunOptimization(new SimpleControlFlow(context, method).SimplifyCustomShortCircuit);
- if (abortBeforeStep == ILAstOptimizationStep.SimplifyNullableOperators) return;
- modified |= block.RunOptimization(SimplifyNullableOperators);
+ if (abortBeforeStep == ILAstOptimizationStep.SimplifyLiftedOperators) return;
+ modified |= block.RunOptimization(SimplifyLiftedOperators);
if (abortBeforeStep == ILAstOptimizationStep.TransformArrayInitializers) return;
modified |= block.RunOptimization(TransformArrayInitializers);
diff --git a/ICSharpCode.Decompiler/ILAst/ILCodes.cs b/ICSharpCode.Decompiler/ILAst/ILCodes.cs
index 1ae93244d..475420e46 100644
--- a/ICSharpCode.Decompiler/ILAst/ILCodes.cs
+++ b/ICSharpCode.Decompiler/ILAst/ILCodes.cs
@@ -317,12 +317,12 @@ namespace ICSharpCode.Decompiler.ILAst
/// Also used when inlining a method call on a value type: "stloc(v, ...); call(M, ldloca(v));" becomes "call(M, AddressOf(...))"
///
AddressOf,
- /// Simulates getting the value of the nullable argument in comparisons involving nullable values
+ /// Simulates getting the value of a lifted operator's nullable argument
///
/// For example "stloc(v1, ...); stloc(v2, ...); logicand(ceq(call(Nullable`1::GetValueOrDefault, ldloca(v1)), ldloc(v2)), callgetter(Nullable`1::get_HasValue, ldloca(v1)))" becomes "wrap(ceq(ValueOf(...), ...))"
///
ValueOf,
- /// Simulates creating a new nullable value from a valuetype argument
+ /// Simulates creating a new nullable value from a value type argument
///
/// For example "stloc(v1, ...); stloc(v2, ...); ternaryop(callgetter(Nullable`1::get_HasValue, ldloca(v1)), newobj(Nullable`1::.ctor, add(call(Nullable`1::GetValueOrDefault, ldloca(v1)), ldloc(v2))), defaultvalue(Nullable`1))"
/// becomes "NullableOf(add(valueof(...), ...))"
diff --git a/ICSharpCode.Decompiler/ILAst/NullableOperators.cs b/ICSharpCode.Decompiler/ILAst/LiftedOperators.cs
similarity index 98%
rename from ICSharpCode.Decompiler/ILAst/NullableOperators.cs
rename to ICSharpCode.Decompiler/ILAst/LiftedOperators.cs
index 5ce80323c..7bef7befe 100644
--- a/ICSharpCode.Decompiler/ILAst/NullableOperators.cs
+++ b/ICSharpCode.Decompiler/ILAst/LiftedOperators.cs
@@ -26,9 +26,9 @@ namespace ICSharpCode.Decompiler.ILAst
{
partial class ILAstOptimizer
{
- bool SimplifyNullableOperators(List body, ILExpression expr, int pos)
+ bool SimplifyLiftedOperators(List body, ILExpression expr, int pos)
{
- if (!new PatternMatcher(typeSystem).SimplifyNullableOperators(expr)) return false;
+ if (!new PatternMatcher(typeSystem).SimplifyLiftedOperators(expr)) return false;
var inlining = new ILInlining(method);
while (--pos >= 0 && inlining.InlineIfPossible(body, ref pos)) ;
@@ -44,13 +44,13 @@ namespace ICSharpCode.Decompiler.ILAst
this.typeSystem = typeSystem;
}
- public bool SimplifyNullableOperators(ILExpression expr)
+ public bool SimplifyLiftedOperators(ILExpression expr)
{
if (Simplify(expr)) return true;
bool modified = false;
foreach (var a in expr.Arguments)
- modified |= SimplifyNullableOperators(a);
+ modified |= SimplifyLiftedOperators(a);
return modified;
}
diff --git a/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs b/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs
index 938063378..d32a4926c 100644
--- a/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs
+++ b/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs
@@ -397,17 +397,17 @@ namespace ICSharpCode.Decompiler.ILAst
return false;
ILExpression op = expr.Arguments.Last();
- // in case of compound assignments with nullable values the result is inside NullableOf and the operand is inside ValueOf
- bool nullable = false;
+ // in case of compound assignments with a lifted operator the result is inside NullableOf and the operand is inside ValueOf
+ bool liftedOperator = false;
if (op.Code == ILCode.NullableOf) {
op = op.Arguments[0];
- nullable = true;
+ liftedOperator = true;
}
if (!CanBeRepresentedAsCompoundAssignment(op))
return false;
ILExpression ldelem = op.Arguments[0];
- if (nullable) {
+ if (liftedOperator) {
if (ldelem.Code != ILCode.ValueOf)
return false;
ldelem = ldelem.Arguments[0];
diff --git a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
index dc2be5fcd..362f6620e 100644
--- a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -64,7 +64,7 @@
-
+
diff --git a/ICSharpCode.Decompiler/Tests/NullableOperators.cs b/ICSharpCode.Decompiler/Tests/LiftedOperators.cs
similarity index 97%
rename from ICSharpCode.Decompiler/Tests/NullableOperators.cs
rename to ICSharpCode.Decompiler/Tests/LiftedOperators.cs
index bd7e978e8..426276ab0 100644
--- a/ICSharpCode.Decompiler/Tests/NullableOperators.cs
+++ b/ICSharpCode.Decompiler/Tests/LiftedOperators.cs
@@ -19,9 +19,9 @@
using System;
using System.Runtime.InteropServices;
-public static class NullableOperators
+public static class LiftedOperators
{
- // C# uses 4 different patterns of IL for operators involving nullable values: bool, other primitive types, decimal, other structs.
+ // C# uses 4 different patterns of IL for lifted operators: bool, other primitive types, decimal, other structs.
// Different patterns are used depending on whether both of the operands are nullable or only the left/right operand is nullable.
// Negation must not be pushed through such comparisons because it would change the semantics.
// A comparison used in a condition differs somewhat from a comparison used as a simple value.
@@ -131,7 +131,7 @@ public static class NullableOperators
a ^= b;
}
- public static void BoolValueComplex(bool? a, Func x, bool?[] list)
+ public static void BoolValueComplex(bool? a, Func x)
{
Console.WriteLine(a == x());
Console.WriteLine(a != x());
@@ -151,7 +151,7 @@ public static class NullableOperators
a ^= x();
Console.WriteLine(x() ^ a);
- list[0] ^= x();
+ (new bool?[0])[0] ^= x();
}
public static void BoolValueConst(bool? a)
@@ -316,7 +316,7 @@ public static class NullableOperators
a >>= b;
}
- public static void IntValueComplex(int? a, Func x, int?[] list)
+ public static void IntValueComplex(int? a, Func x)
{
Console.WriteLine(a == x());
Console.WriteLine(a != x());
@@ -349,7 +349,7 @@ public static class NullableOperators
a >>= x();
Console.WriteLine(x() + a);
- list[0] += x();
+ (new int?[0])[0] += x();
}
public static void IntValueConst(int? a)
@@ -515,7 +515,7 @@ public static class NullableOperators
a %= b;
}
- public static void NumberValueComplex(decimal? a, Func x, decimal?[] list)
+ public static void NumberValueComplex(decimal? a, Func x)
{
Console.WriteLine(a == x());
Console.WriteLine(a != x());
@@ -538,7 +538,7 @@ public static class NullableOperators
a %= x();
Console.WriteLine(x() + a);
- list[0] += x();
+ (new decimal?[0])[0] += x();
}
public static void NumberValueConst(decimal? a)
@@ -679,7 +679,7 @@ public static class NullableOperators
a >>= i;
}
- public static void StructValueComplex(TS? a, Func x, Func i, TS?[] list)
+ public static void StructValueComplex(TS? a, Func x, Func i)
{
Console.WriteLine(a == x());
Console.WriteLine(a != x());
@@ -712,7 +712,7 @@ public static class NullableOperators
a >>= i();
Console.WriteLine(x() + a);
- list[0] += x();
+ (new TS?[0])[0] += x();
}
}
diff --git a/ICSharpCode.Decompiler/Tests/TestRunner.cs b/ICSharpCode.Decompiler/Tests/TestRunner.cs
index a45a874d7..69617ba82 100644
--- a/ICSharpCode.Decompiler/Tests/TestRunner.cs
+++ b/ICSharpCode.Decompiler/Tests/TestRunner.cs
@@ -80,6 +80,12 @@ namespace ICSharpCode.Decompiler.Tests
public void InitializerTests()
{
TestFile(@"..\..\Tests\InitializerTests.cs");
+ }
+
+ [Test]
+ public void LiftedOperators()
+ {
+ TestFile(@"..\..\Tests\LiftedOperators.cs");
}
[Test]
@@ -93,12 +99,6 @@ namespace ICSharpCode.Decompiler.Tests
{
TestFile(@"..\..\Tests\MultidimensionalArray.cs");
}
-
- [Test]
- public void NullableOperators()
- {
- TestFile(@"..\..\Tests\NullableOperators.cs");
- }
[Test]
public void PInvoke()