Browse Source

Fix #1252: Incorrect comparison type for lifted comparisons in expression trees.

pull/1317/head
Daniel Grunwald 7 years ago
parent
commit
0a9df3d373
  1. 12
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs
  2. 233
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.il
  3. 247
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.il
  4. 677
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.roslyn.il
  5. 678
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.roslyn.il
  6. 2
      ICSharpCode.Decompiler/IL/Instructions/Comp.cs
  7. 4
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

12
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs

@ -844,7 +844,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -844,7 +844,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
ToCode(null, (object a) => a ?? new MyClass());
}
public static void BinaryLogicalOperators()
public static void ComparisonOperators()
{
ToCode(null, (int a, int b) => a == b);
ToCode(null, (int a, int b) => a != b);
@ -865,6 +865,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -865,6 +865,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
ToCode(null, (int a, int b) => a == 1 || b == 2);
}
public static void LiftedComparisonOperators()
{
ToCode(X(), (int? a, int? b) => a == b);
ToCode(X(), (int? a, int? b) => a != b);
ToCode(X(), (int? a, int? b) => a < b);
ToCode(X(), (int? a, int? b) => a <= b);
ToCode(X(), (int? a, int? b) => a > b);
ToCode(X(), (int? a, int? b) => a >= b);
}
public static void UnaryArithmeticOperators()
{
Test<Func<int, int>>((int a) => a, (int a) => a);

233
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.il

@ -8876,7 +8876,7 @@ @@ -8876,7 +8876,7 @@
IL_00ac: ret
} // end of method ExpressionTrees::ConditionalOperator
.method public hidebysig static void BinaryLogicalOperators() cil managed
.method public hidebysig static void ComparisonOperators() cil managed
{
// Code size 1639 (0x667)
.maxstack 5
@ -9559,7 +9559,222 @@ @@ -9559,7 +9559,222 @@
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0665: pop
IL_0666: ret
} // end of method ExpressionTrees::BinaryLogicalOperators
} // end of method ExpressionTrees::ComparisonOperators
.method public hidebysig static void LiftedComparisonOperators() cil managed
{
// Code size 488 (0x1e8)
.maxstack 5
.locals init (class [System.Core]System.Linq.Expressions.ParameterExpression V_0,
class [System.Core]System.Linq.Expressions.ParameterExpression V_1,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_2)
IL_0000: nop
IL_0001: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_0006: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_000b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0010: ldstr "a"
IL_0015: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_001a: stloc.0
IL_001b: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0020: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0025: ldstr "b"
IL_002a: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_002f: stloc.1
IL_0030: ldloc.0
IL_0031: ldloc.1
IL_0032: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::Equal(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_0037: ldc.i4.2
IL_0038: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_003d: stloc.2
IL_003e: ldloc.2
IL_003f: ldc.i4.0
IL_0040: ldloc.0
IL_0041: stelem.ref
IL_0042: ldloc.2
IL_0043: ldc.i4.1
IL_0044: ldloc.1
IL_0045: stelem.ref
IL_0046: ldloc.2
IL_0047: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_004c: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0051: pop
IL_0052: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_0057: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_005c: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0061: ldstr "a"
IL_0066: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_006b: stloc.0
IL_006c: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0071: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0076: ldstr "b"
IL_007b: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_0080: stloc.1
IL_0081: ldloc.0
IL_0082: ldloc.1
IL_0083: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::NotEqual(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_0088: ldc.i4.2
IL_0089: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_008e: stloc.2
IL_008f: ldloc.2
IL_0090: ldc.i4.0
IL_0091: ldloc.0
IL_0092: stelem.ref
IL_0093: ldloc.2
IL_0094: ldc.i4.1
IL_0095: ldloc.1
IL_0096: stelem.ref
IL_0097: ldloc.2
IL_0098: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_009d: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_00a2: pop
IL_00a3: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_00a8: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_00ad: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_00b2: ldstr "a"
IL_00b7: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_00bc: stloc.0
IL_00bd: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_00c2: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_00c7: ldstr "b"
IL_00cc: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_00d1: stloc.1
IL_00d2: ldloc.0
IL_00d3: ldloc.1
IL_00d4: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::LessThan(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_00d9: ldc.i4.2
IL_00da: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_00df: stloc.2
IL_00e0: ldloc.2
IL_00e1: ldc.i4.0
IL_00e2: ldloc.0
IL_00e3: stelem.ref
IL_00e4: ldloc.2
IL_00e5: ldc.i4.1
IL_00e6: ldloc.1
IL_00e7: stelem.ref
IL_00e8: ldloc.2
IL_00e9: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_00ee: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_00f3: pop
IL_00f4: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_00f9: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_00fe: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0103: ldstr "a"
IL_0108: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_010d: stloc.0
IL_010e: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0113: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0118: ldstr "b"
IL_011d: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_0122: stloc.1
IL_0123: ldloc.0
IL_0124: ldloc.1
IL_0125: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::LessThanOrEqual(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_012a: ldc.i4.2
IL_012b: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_0130: stloc.2
IL_0131: ldloc.2
IL_0132: ldc.i4.0
IL_0133: ldloc.0
IL_0134: stelem.ref
IL_0135: ldloc.2
IL_0136: ldc.i4.1
IL_0137: ldloc.1
IL_0138: stelem.ref
IL_0139: ldloc.2
IL_013a: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_013f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0144: pop
IL_0145: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_014a: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_014f: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0154: ldstr "a"
IL_0159: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_015e: stloc.0
IL_015f: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0164: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0169: ldstr "b"
IL_016e: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_0173: stloc.1
IL_0174: ldloc.0
IL_0175: ldloc.1
IL_0176: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::GreaterThan(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_017b: ldc.i4.2
IL_017c: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_0181: stloc.2
IL_0182: ldloc.2
IL_0183: ldc.i4.0
IL_0184: ldloc.0
IL_0185: stelem.ref
IL_0186: ldloc.2
IL_0187: ldc.i4.1
IL_0188: ldloc.1
IL_0189: stelem.ref
IL_018a: ldloc.2
IL_018b: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_0190: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0195: pop
IL_0196: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_019b: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_01a0: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_01a5: ldstr "a"
IL_01aa: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_01af: stloc.0
IL_01b0: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_01b5: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_01ba: ldstr "b"
IL_01bf: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_01c4: stloc.1
IL_01c5: ldloc.0
IL_01c6: ldloc.1
IL_01c7: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::GreaterThanOrEqual(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_01cc: ldc.i4.2
IL_01cd: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_01d2: stloc.2
IL_01d3: ldloc.2
IL_01d4: ldc.i4.0
IL_01d5: ldloc.0
IL_01d6: stelem.ref
IL_01d7: ldloc.2
IL_01d8: ldc.i4.1
IL_01d9: ldloc.1
IL_01da: stelem.ref
IL_01db: ldloc.2
IL_01dc: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_01e1: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_01e6: pop
IL_01e7: ret
} // end of method ExpressionTrees::LiftedComparisonOperators
.method public hidebysig static void UnaryArithmeticOperators() cil managed
{
@ -12718,7 +12933,7 @@ @@ -12718,7 +12933,7 @@
IL_0000: ldc.i4.3
IL_0001: newarr [mscorlib]System.Int32
IL_0006: dup
IL_0007: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x600010d-1'
IL_0007: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x600010e-1'
IL_000c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
valuetype [mscorlib]System.RuntimeFieldHandle)
IL_0011: stloc.0
@ -12794,7 +13009,7 @@ @@ -12794,7 +13009,7 @@
IL_0009: ldc.i4.3
IL_000a: newarr [mscorlib]System.Int32
IL_000f: dup
IL_0010: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x6000111-1'
IL_0010: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x6000112-1'
IL_0015: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
valuetype [mscorlib]System.RuntimeFieldHandle)
IL_001a: stelem.ref
@ -14617,8 +14832,8 @@ @@ -14617,8 +14832,8 @@
.size 12
} // end of class '__StaticArrayInitTypeSize=12'
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x600010d-1' at I_00009008
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x6000111-1' at I_00009080
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x600010e-1' at I_00009200
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x6000112-1' at I_00009278
} // end of class '<PrivateImplementationDetails>'
.class private auto ansi sealed beforefieldinit '<>f__AnonymousType3`2'<'<A>j__TPar','<B>j__TPar'>
@ -14810,9 +15025,9 @@ @@ -14810,9 +15025,9 @@
// =============================================================
.data cil I_00009008 = bytearray (
.data cil I_00009200 = bytearray (
01 00 00 00 02 00 00 00 03 00 00 00)
.data cil I_00009014 = int8[108]
.data cil I_00009080 = bytearray (
.data cil I_0000920C = int8[4]
.data cil I_00009278 = bytearray (
01 00 00 00 02 00 00 00 03 00 00 00)
// *********** DISASSEMBLY COMPLETE ***********************

247
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.il

@ -8565,7 +8565,7 @@ @@ -8565,7 +8565,7 @@
IL_00ab: ret
} // end of method ExpressionTrees::ConditionalOperator
.method public hidebysig static void BinaryLogicalOperators() cil managed
.method public hidebysig static void ComparisonOperators() cil managed
{
// Code size 1795 (0x703)
.maxstack 5
@ -9295,7 +9295,236 @@ @@ -9295,7 +9295,236 @@
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0701: pop
IL_0702: ret
} // end of method ExpressionTrees::BinaryLogicalOperators
} // end of method ExpressionTrees::ComparisonOperators
.method public hidebysig static void LiftedComparisonOperators() cil managed
{
// Code size 534 (0x216)
.maxstack 5
.locals init (class [System.Core]System.Linq.Expressions.ParameterExpression V_0,
class [System.Core]System.Linq.Expressions.ParameterExpression V_1,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_2,
class [System.Core]System.Linq.Expressions.ParameterExpression V_3,
class [System.Core]System.Linq.Expressions.ParameterExpression V_4,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_5,
class [System.Core]System.Linq.Expressions.ParameterExpression V_6,
class [System.Core]System.Linq.Expressions.ParameterExpression V_7,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_8,
class [System.Core]System.Linq.Expressions.ParameterExpression V_9,
class [System.Core]System.Linq.Expressions.ParameterExpression V_10,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_11,
class [System.Core]System.Linq.Expressions.ParameterExpression V_12,
class [System.Core]System.Linq.Expressions.ParameterExpression V_13,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_14,
class [System.Core]System.Linq.Expressions.ParameterExpression V_15,
class [System.Core]System.Linq.Expressions.ParameterExpression V_16,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_17)
IL_0000: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_0005: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_000a: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_000f: ldstr "a"
IL_0014: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_0019: stloc.0
IL_001a: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_001f: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0024: ldstr "b"
IL_0029: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_002e: stloc.1
IL_002f: ldloc.0
IL_0030: ldloc.1
IL_0031: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::Equal(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_0036: ldc.i4.2
IL_0037: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_003c: stloc.2
IL_003d: ldloc.2
IL_003e: ldc.i4.0
IL_003f: ldloc.0
IL_0040: stelem.ref
IL_0041: ldloc.2
IL_0042: ldc.i4.1
IL_0043: ldloc.1
IL_0044: stelem.ref
IL_0045: ldloc.2
IL_0046: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_004b: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0050: pop
IL_0051: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_0056: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_005b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0060: ldstr "a"
IL_0065: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_006a: stloc.3
IL_006b: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0070: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0075: ldstr "b"
IL_007a: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_007f: stloc.s V_4
IL_0081: ldloc.3
IL_0082: ldloc.s V_4
IL_0084: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::NotEqual(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_0089: ldc.i4.2
IL_008a: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_008f: stloc.s V_5
IL_0091: ldloc.s V_5
IL_0093: ldc.i4.0
IL_0094: ldloc.3
IL_0095: stelem.ref
IL_0096: ldloc.s V_5
IL_0098: ldc.i4.1
IL_0099: ldloc.s V_4
IL_009b: stelem.ref
IL_009c: ldloc.s V_5
IL_009e: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_00a3: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_00a8: pop
IL_00a9: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_00ae: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_00b3: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_00b8: ldstr "a"
IL_00bd: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_00c2: stloc.s V_6
IL_00c4: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_00c9: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_00ce: ldstr "b"
IL_00d3: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_00d8: stloc.s V_7
IL_00da: ldloc.s V_6
IL_00dc: ldloc.s V_7
IL_00de: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::LessThan(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_00e3: ldc.i4.2
IL_00e4: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_00e9: stloc.s V_8
IL_00eb: ldloc.s V_8
IL_00ed: ldc.i4.0
IL_00ee: ldloc.s V_6
IL_00f0: stelem.ref
IL_00f1: ldloc.s V_8
IL_00f3: ldc.i4.1
IL_00f4: ldloc.s V_7
IL_00f6: stelem.ref
IL_00f7: ldloc.s V_8
IL_00f9: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_00fe: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0103: pop
IL_0104: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_0109: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_010e: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0113: ldstr "a"
IL_0118: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_011d: stloc.s V_9
IL_011f: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0124: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0129: ldstr "b"
IL_012e: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_0133: stloc.s V_10
IL_0135: ldloc.s V_9
IL_0137: ldloc.s V_10
IL_0139: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::LessThanOrEqual(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_013e: ldc.i4.2
IL_013f: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_0144: stloc.s V_11
IL_0146: ldloc.s V_11
IL_0148: ldc.i4.0
IL_0149: ldloc.s V_9
IL_014b: stelem.ref
IL_014c: ldloc.s V_11
IL_014e: ldc.i4.1
IL_014f: ldloc.s V_10
IL_0151: stelem.ref
IL_0152: ldloc.s V_11
IL_0154: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_0159: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_015e: pop
IL_015f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_0164: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_0169: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_016e: ldstr "a"
IL_0173: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_0178: stloc.s V_12
IL_017a: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_017f: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0184: ldstr "b"
IL_0189: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_018e: stloc.s V_13
IL_0190: ldloc.s V_12
IL_0192: ldloc.s V_13
IL_0194: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::GreaterThan(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_0199: ldc.i4.2
IL_019a: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_019f: stloc.s V_14
IL_01a1: ldloc.s V_14
IL_01a3: ldc.i4.0
IL_01a4: ldloc.s V_12
IL_01a6: stelem.ref
IL_01a7: ldloc.s V_14
IL_01a9: ldc.i4.1
IL_01aa: ldloc.s V_13
IL_01ac: stelem.ref
IL_01ad: ldloc.s V_14
IL_01af: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_01b4: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_01b9: pop
IL_01ba: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::X()
IL_01bf: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_01c4: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_01c9: ldstr "a"
IL_01ce: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_01d3: stloc.s V_15
IL_01d5: ldtoken valuetype [mscorlib]System.Nullable`1<int32>
IL_01da: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_01df: ldstr "b"
IL_01e4: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type,
string)
IL_01e9: stloc.s V_16
IL_01eb: ldloc.s V_15
IL_01ed: ldloc.s V_16
IL_01ef: call class [System.Core]System.Linq.Expressions.BinaryExpression [System.Core]System.Linq.Expressions.Expression::GreaterThanOrEqual(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.Expression)
IL_01f4: ldc.i4.2
IL_01f5: newarr [System.Core]System.Linq.Expressions.ParameterExpression
IL_01fa: stloc.s V_17
IL_01fc: ldloc.s V_17
IL_01fe: ldc.i4.0
IL_01ff: ldloc.s V_15
IL_0201: stelem.ref
IL_0202: ldloc.s V_17
IL_0204: ldc.i4.1
IL_0205: ldloc.s V_16
IL_0207: stelem.ref
IL_0208: ldloc.s V_17
IL_020a: call class [System.Core]System.Linq.Expressions.Expression`1<!!0> [System.Core]System.Linq.Expressions.Expression::Lambda<class [mscorlib]System.Func`3<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>>(class [System.Core]System.Linq.Expressions.Expression,
class [System.Core]System.Linq.Expressions.ParameterExpression[])
IL_020f: call object ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExpressionTrees::ToCode<valuetype [mscorlib]System.Nullable`1<int32>,valuetype [mscorlib]System.Nullable`1<int32>,bool>(object,
class [System.Core]System.Linq.Expressions.Expression`1<class [mscorlib]System.Func`3<!!0,!!1,!!2>>)
IL_0214: pop
IL_0215: ret
} // end of method ExpressionTrees::LiftedComparisonOperators
.method public hidebysig static void UnaryArithmeticOperators() cil managed
{
@ -12111,7 +12340,7 @@ @@ -12111,7 +12340,7 @@
IL_0000: ldc.i4.3
IL_0001: newarr [mscorlib]System.Int32
IL_0006: dup
IL_0007: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x600010d-1'
IL_0007: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x600010e-1'
IL_000c: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
valuetype [mscorlib]System.RuntimeFieldHandle)
IL_0011: ret
@ -12167,7 +12396,7 @@ @@ -12167,7 +12396,7 @@
IL_0009: ldc.i4.3
IL_000a: newarr [mscorlib]System.Int32
IL_000f: dup
IL_0010: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x6000111-1'
IL_0010: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '<PrivateImplementationDetails>'::'$$method0x6000112-1'
IL_0015: call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array,
valuetype [mscorlib]System.RuntimeFieldHandle)
IL_001a: stelem.ref
@ -13856,8 +14085,8 @@ @@ -13856,8 +14085,8 @@
.size 12
} // end of class '__StaticArrayInitTypeSize=12'
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x600010d-1' at I_00008B38
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x6000111-1' at I_00008B70
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x600010e-1' at I_00008D60
.field static assembly valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=12' '$$method0x6000112-1' at I_00008D98
} // end of class '<PrivateImplementationDetails>'
.class private auto ansi sealed beforefieldinit '<>f__AnonymousType3`2'<'<A>j__TPar','<B>j__TPar'>
@ -14023,9 +14252,9 @@ @@ -14023,9 +14252,9 @@
// =============================================================
.data cil I_00008B38 = bytearray (
.data cil I_00008D60 = bytearray (
01 00 00 00 02 00 00 00 03 00 00 00)
.data cil I_00008B44 = int8[12]
.data cil I_00008B70 = bytearray (
.data cil I_00008D6C = int8[4]
.data cil I_00008D98 = bytearray (
01 00 00 00 02 00 00 00 03 00 00 00)
// *********** DISASSEMBLY COMPLETE ***********************

677
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.opt.roslyn.il

File diff suppressed because it is too large Load Diff

678
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.roslyn.il

File diff suppressed because it is too large Load Diff

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

@ -183,6 +183,8 @@ namespace ICSharpCode.Decompiler.IL @@ -183,6 +183,8 @@ namespace ICSharpCode.Decompiler.IL
return;
}
output.Write(OpCode);
output.Write('.');
output.Write(InputType.ToString().ToLower());
switch (Sign) {
case Sign.Signed:
output.Write(".signed");

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

@ -611,7 +611,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -611,7 +611,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (new Call(operatorMethod) { Arguments = { left, right } }, operatorMethod.ReturnType);
}
var resultType = context.TypeSystem.FindType(KnownTypeCode.Boolean);
return (new Comp(kind, NullableType.IsNullable(leftType) ? ComparisonLiftingKind.CSharp : ComparisonLiftingKind.None, leftType.GetStackType(), leftType.GetSign(), left, right), resultType);
var lifting = NullableType.IsNullable(leftType) ? ComparisonLiftingKind.CSharp : ComparisonLiftingKind.None;
var utype = NullableType.GetUnderlyingType(leftType);
return (new Comp(kind, lifting, utype.GetStackType(), utype.GetSign(), left, right), resultType);
}
(ILInstruction, IType) ConvertCondition(CallInstruction invocation)

Loading…
Cancel
Save