Browse Source

Add support for compound assignment of short integers.

pull/960/head
Daniel Grunwald 9 years ago
parent
commit
40a4f08a8d
  1. 21
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs
  2. 105
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  3. 405
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.il
  4. 342
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.il
  5. 336
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.roslyn.il
  6. 399
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.roslyn.il
  7. 4
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  8. 8
      ICSharpCode.Decompiler/IL/Instructions.cs
  9. 4
      ICSharpCode.Decompiler/IL/Instructions.tt
  10. 12
      ICSharpCode.Decompiler/IL/Instructions/CompoundAssignmentInstruction.cs
  11. 27
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
  12. 81
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

21
ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs

@ -30,6 +30,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
CallTwice(); CallTwice();
UnsignedShiftRightInstanceField(); UnsignedShiftRightInstanceField();
UnsignedShiftRightStaticProperty(); UnsignedShiftRightStaticProperty();
DivideByBigValue();
} }
static void Test(int a, int b) static void Test(int a, int b)
@ -76,6 +77,19 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
} }
} }
static ushort shortField;
public static ushort ShortProperty {
get {
Console.WriteLine("In get_ShortProperty");
return shortField;
}
set {
Console.WriteLine("In set_ShortProperty, value={0}", value);
shortField = value;
}
}
public static Dictionary<string, int> GetDict() public static Dictionary<string, int> GetDict()
{ {
Console.WriteLine("In GetDict()"); Console.WriteLine("In GetDict()");
@ -133,5 +147,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
StaticProperty = -15; StaticProperty = -15;
Test(X(), StaticProperty = (int)((uint)StaticProperty >> 2)); Test(X(), StaticProperty = (int)((uint)StaticProperty >> 2));
} }
static void DivideByBigValue()
{
ShortProperty = 5;
// can't use "ShortProperty /= (ushort)(ushort.MaxValue + 3)" because that would be division by 2.
ShortProperty = (ushort)(ShortProperty / (ushort.MaxValue + 3));
}
} }
} }

105
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs

@ -78,6 +78,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private int[] array1; private int[] array1;
private StructContainer field1; private StructContainer field1;
private MyEnum enumField; private MyEnum enumField;
private ShortEnum shortEnumField;
public static int StaticField; public static int StaticField;
public static short StaticShortField; public static short StaticShortField;
@ -228,8 +229,18 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
this.enumField |= MyEnum.Two; this.enumField |= MyEnum.Two;
this.enumField &= ~MyEnum.Four; this.enumField &= ~MyEnum.Four;
this.enumField += 2;
this.enumField -= 3;
} }
public void ShortEnumTest()
{
this.shortEnumField |= ShortEnum.Two;
this.shortEnumField &= ~ShortEnum.Four;
this.shortEnumField += 2;
this.shortEnumField -= 3;
}
public int PreIncrementInAddition(int i, int j) public int PreIncrementInAddition(int i, int j)
{ {
return i + ++j; return i + ++j;
@ -250,21 +261,41 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
array[pos]++; array[pos]++;
} }
public int PreIncrementShortArrayElement(short[] array, int pos) public void DoubleArrayElement(int[] array, int pos)
{
array[pos] *= 2;
}
public int DoubleArrayElementAndReturn(int[] array, int pos)
{
return array[pos] *= 2;
}
public int PreIncrementArrayElementShort(short[] array, int pos)
{ {
return --array[pos]; return --array[pos];
} }
public int PostIncrementShortArrayElement(short[] array, int pos) public int PostIncrementArrayElementShort(short[] array, int pos)
{ {
return array[pos]++; return array[pos]++;
} }
public void IncrementShortArrayElement(short[] array, int pos) public void IncrementArrayElementShort(short[] array, int pos)
{ {
array[pos]++; array[pos]++;
} }
public void DoubleArrayElementShort(short[] array, int pos)
{
array[pos] *= 2;
}
public short DoubleArrayElementShortAndReturn(short[] array, int pos)
{
return array[pos] *= 2;
}
public int PreIncrementInstanceField() public int PreIncrementInstanceField()
{ {
return ++this.M().Field; return ++this.M().Field;
@ -280,6 +311,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
this.M().Field++; this.M().Field++;
} }
public void DoubleInstanceField()
{
this.M().Field *= 2;
}
public int DoubleInstanceFieldAndReturn()
{
return this.M().Field *= 2;
}
public int PreIncrementInstanceField2(MutableClass m) public int PreIncrementInstanceField2(MutableClass m)
{ {
return ++m.Field; return ++m.Field;
@ -325,6 +366,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
this.M().Property++; this.M().Property++;
} }
public void DoubleInstanceProperty()
{
this.M().Property *= 2;
}
public int DoubleInstancePropertyAndReturn()
{
return this.M().Property *= 2;
}
public int PreIncrementInstancePropertyByte() public int PreIncrementInstancePropertyByte()
{ {
return ++this.M().ByteProperty; return ++this.M().ByteProperty;
@ -340,6 +391,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
this.M().ByteProperty++; this.M().ByteProperty++;
} }
public void DoubleInstancePropertyByte()
{
this.M().ByteProperty *= 2;
}
public int DoubleInstancePropertyByteAndReturn()
{
return this.M().ByteProperty *= 2;
}
public int PreIncrementStaticField() public int PreIncrementStaticField()
{ {
return ++CompoundAssignmentTest.StaticField; return ++CompoundAssignmentTest.StaticField;
@ -355,6 +416,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
CompoundAssignmentTest.StaticField++; CompoundAssignmentTest.StaticField++;
} }
public void DoubleStaticField()
{
CompoundAssignmentTest.StaticField *= 2;
}
public int DoubleStaticFieldAndReturn()
{
return CompoundAssignmentTest.StaticField *= 2;
}
public int PreIncrementStaticFieldShort() public int PreIncrementStaticFieldShort()
{ {
return ++CompoundAssignmentTest.StaticShortField; return ++CompoundAssignmentTest.StaticShortField;
@ -370,6 +441,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
CompoundAssignmentTest.StaticShortField++; CompoundAssignmentTest.StaticShortField++;
} }
public void DoubleStaticFieldShort()
{
CompoundAssignmentTest.StaticShortField *= 2;
}
public short DoubleStaticFieldAndReturnShort()
{
return CompoundAssignmentTest.StaticShortField *= 2;
}
public int PreIncrementStaticProperty() public int PreIncrementStaticProperty()
{ {
return ++CompoundAssignmentTest.StaticProperty; return ++CompoundAssignmentTest.StaticProperty;
@ -385,6 +466,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
CompoundAssignmentTest.StaticProperty++; CompoundAssignmentTest.StaticProperty++;
} }
public void DoubleStaticProperty()
{
CompoundAssignmentTest.StaticProperty *= 2;
}
public int DoubleStaticPropertyAndReturn()
{
return CompoundAssignmentTest.StaticProperty *= 2;
}
public ShortEnum PreIncrementStaticPropertyShort() public ShortEnum PreIncrementStaticPropertyShort()
{ {
return ++CompoundAssignmentTest.StaticShortProperty; return ++CompoundAssignmentTest.StaticShortProperty;
@ -399,7 +490,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
CompoundAssignmentTest.StaticShortProperty++; CompoundAssignmentTest.StaticShortProperty++;
} }
private static Item GetItem(object obj) private static Item GetItem(object obj)
{ {
return null; return null;
@ -411,10 +502,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
item.Self = item; item.Self = item;
} }
void Issue954(ref MyEnum a, MyEnum b) private void Issue954(ref MyEnum a, MyEnum b)
{ {
// cannot decompile to: "a %= b;", because the % operator does not apply to enums // cannot decompile to: "a %= b;", because the % operator does not apply to enums
a = (MyEnum)((int)a % (int)b); a = (MyEnum)((int)a % (int)b);
// same with enum field:
this.enumField = (MyEnum)((int)this.enumField % (int)b);
} }
} }
} }

405
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.il

@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly gvvksqgl .assembly oguadjyn
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
@ -20,15 +20,15 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module gvvksqgl.dll .module oguadjyn.dll
// MVID: {50934C05-8B92-4905-A41A-146C5F2392BA} // MVID: {7DE8C1A3-5051-43F6-ACDA-EFB9A52251C4}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x00410000 // Image base: 0x019F0000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -203,6 +203,7 @@
.field private int32[] array1 .field private int32[] array1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1 .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum shortEnumField
.field public static int32 StaticField .field public static int32 StaticField
.field public static int16 StaticShortField .field public static int16 StaticShortField
.field private static int32 '<StaticProperty>k__BackingField' .field private static int32 '<StaticProperty>k__BackingField'
@ -771,7 +772,7 @@
.method public hidebysig instance void .method public hidebysig instance void
Enum() cil managed Enum() cil managed
{ {
// Code size 31 (0x1f) // Code size 59 (0x3b)
.maxstack 8 .maxstack 8
IL_0000: nop IL_0000: nop
IL_0001: ldarg.0 IL_0001: ldarg.0
@ -786,9 +787,58 @@
IL_0016: ldc.i4.s -5 IL_0016: ldc.i4.s -5
IL_0018: and IL_0018: and
IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_001e: ret IL_001e: ldarg.0
IL_001f: dup
IL_0020: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0025: ldc.i4.2
IL_0026: add
IL_0027: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_002c: ldarg.0
IL_002d: dup
IL_002e: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0033: ldc.i4.3
IL_0034: sub
IL_0035: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_003a: ret
} // end of method CompoundAssignmentTest::Enum } // end of method CompoundAssignmentTest::Enum
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 63 (0x3f)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: dup
IL_0003: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0008: ldc.i4.2
IL_0009: or
IL_000a: conv.i2
IL_000b: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0010: ldarg.0
IL_0011: dup
IL_0012: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0017: ldc.i4.s -5
IL_0019: and
IL_001a: conv.i2
IL_001b: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0020: ldarg.0
IL_0021: dup
IL_0022: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0027: ldc.i4.2
IL_0028: add
IL_0029: conv.i2
IL_002a: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_002f: ldarg.0
IL_0030: dup
IL_0031: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0036: ldc.i4.3
IL_0037: sub
IL_0038: conv.i2
IL_0039: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_003e: ret
} // end of method CompoundAssignmentTest::ShortEnumTest
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInAddition(int32 i, PreIncrementInAddition(int32 i,
int32 j) cil managed int32 j) cil managed
@ -883,8 +933,53 @@
IL_0015: ret IL_0015: ret
} // end of method CompoundAssignmentTest::IncrementArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElement
.method public hidebysig instance void
DoubleArrayElement(int32[] 'array',
int32 pos) cil managed
{
// Code size 22 (0x16)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int32
IL_0008: dup
IL_0009: ldobj [mscorlib]System.Int32
IL_000e: ldc.i4.2
IL_000f: mul
IL_0010: stobj [mscorlib]System.Int32
IL_0015: ret
} // end of method CompoundAssignmentTest::DoubleArrayElement
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementShortArrayElement(int16[] 'array', DoubleArrayElementAndReturn(int32[] 'array',
int32 pos) cil managed
{
// Code size 29 (0x1d)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int32
IL_0008: dup
IL_0009: ldobj [mscorlib]System.Int32
IL_000e: ldc.i4.2
IL_000f: mul
IL_0010: dup
IL_0011: stloc.1
IL_0012: stobj [mscorlib]System.Int32
IL_0017: ldloc.1
IL_0018: stloc.0
IL_0019: br.s IL_001b
IL_001b: ldloc.0
IL_001c: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementAndReturn
.method public hidebysig instance int32
PreIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 30 (0x1e) // Code size 30 (0x1e)
@ -909,10 +1004,10 @@
IL_001c: ldloc.0 IL_001c: ldloc.0
IL_001d: ret IL_001d: ret
} // end of method CompoundAssignmentTest::PreIncrementShortArrayElement } // end of method CompoundAssignmentTest::PreIncrementArrayElementShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PostIncrementShortArrayElement(int16[] 'array', PostIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 30 (0x1e) // Code size 30 (0x1e)
@ -937,10 +1032,10 @@
IL_001c: ldloc.0 IL_001c: ldloc.0
IL_001d: ret IL_001d: ret
} // end of method CompoundAssignmentTest::PostIncrementShortArrayElement } // end of method CompoundAssignmentTest::PostIncrementArrayElementShort
.method public hidebysig instance void .method public hidebysig instance void
IncrementShortArrayElement(int16[] 'array', IncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 23 (0x17) // Code size 23 (0x17)
@ -956,7 +1051,54 @@
IL_0010: conv.i2 IL_0010: conv.i2
IL_0011: stobj [mscorlib]System.Int16 IL_0011: stobj [mscorlib]System.Int16
IL_0016: ret IL_0016: ret
} // end of method CompoundAssignmentTest::IncrementShortArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElementShort
.method public hidebysig instance void
DoubleArrayElementShort(int16[] 'array',
int32 pos) cil managed
{
// Code size 23 (0x17)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int16
IL_0008: dup
IL_0009: ldobj [mscorlib]System.Int16
IL_000e: ldc.i4.2
IL_000f: mul
IL_0010: conv.i2
IL_0011: stobj [mscorlib]System.Int16
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShort
.method public hidebysig instance int16
DoubleArrayElementShortAndReturn(int16[] 'array',
int32 pos) cil managed
{
// Code size 30 (0x1e)
.maxstack 3
.locals init (int16 V_0,
int16 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int16
IL_0008: dup
IL_0009: ldobj [mscorlib]System.Int16
IL_000e: ldc.i4.2
IL_000f: mul
IL_0010: conv.i2
IL_0011: dup
IL_0012: stloc.1
IL_0013: stobj [mscorlib]System.Int16
IL_0018: ldloc.1
IL_0019: stloc.0
IL_001a: br.s IL_001c
IL_001c: ldloc.0
IL_001d: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShortAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField() cil managed PreIncrementInstanceField() cil managed
@ -1024,6 +1166,47 @@
IL_0014: ret IL_0014: ret
} // end of method CompoundAssignmentTest::IncrementInstanceField } // end of method CompoundAssignmentTest::IncrementInstanceField
.method public hidebysig instance void
DoubleInstanceField() cil managed
{
// Code size 21 (0x15)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0014: ret
} // end of method CompoundAssignmentTest::DoubleInstanceField
.method public hidebysig instance int32
DoubleInstanceFieldAndReturn() cil managed
{
// Code size 28 (0x1c)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: dup
IL_0010: stloc.1
IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0016: ldloc.1
IL_0017: stloc.0
IL_0018: br.s IL_001a
IL_001a: ldloc.0
IL_001b: ret
} // end of method CompoundAssignmentTest::DoubleInstanceFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed
{ {
@ -1225,6 +1408,49 @@
IL_0015: ret IL_0015: ret
} // end of method CompoundAssignmentTest::IncrementInstanceProperty } // end of method CompoundAssignmentTest::IncrementInstanceProperty
.method public hidebysig instance void
DoubleInstanceProperty() cil managed
{
// Code size 22 (0x16)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0014: nop
IL_0015: ret
} // end of method CompoundAssignmentTest::DoubleInstanceProperty
.method public hidebysig instance int32
DoubleInstancePropertyAndReturn() cil managed
{
// Code size 29 (0x1d)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: dup
IL_0010: stloc.1
IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0016: nop
IL_0017: ldloc.1
IL_0018: stloc.0
IL_0019: br.s IL_001b
IL_001b: ldloc.0
IL_001c: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstancePropertyByte() cil managed PreIncrementInstancePropertyByte() cil managed
{ {
@ -1297,6 +1523,51 @@
IL_0016: ret IL_0016: ret
} // end of method CompoundAssignmentTest::IncrementInstancePropertyByte } // end of method CompoundAssignmentTest::IncrementInstancePropertyByte
.method public hidebysig instance void
DoubleInstancePropertyByte() cil managed
{
// Code size 23 (0x17)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: conv.u1
IL_0010: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0015: nop
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByte
.method public hidebysig instance int32
DoubleInstancePropertyByteAndReturn() cil managed
{
// Code size 30 (0x1e)
.maxstack 3
.locals init (int32 V_0,
uint8 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: conv.u1
IL_0010: dup
IL_0011: stloc.1
IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0017: nop
IL_0018: ldloc.1
IL_0019: stloc.0
IL_001a: br.s IL_001c
IL_001c: ldloc.0
IL_001d: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByteAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticField() cil managed PreIncrementStaticField() cil managed
{ {
@ -1348,6 +1619,38 @@
IL_000d: ret IL_000d: ret
} // end of method CompoundAssignmentTest::IncrementStaticField } // end of method CompoundAssignmentTest::IncrementStaticField
.method public hidebysig instance void
DoubleStaticField() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: nop
IL_0001: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticField
.method public hidebysig instance int32
DoubleStaticFieldAndReturn() cil managed
{
// Code size 19 (0x13)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: dup
IL_0009: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticFieldShort() cil managed PreIncrementStaticFieldShort() cil managed
{ {
@ -1402,6 +1705,40 @@
IL_000e: ret IL_000e: ret
} // end of method CompoundAssignmentTest::IncrementStaticFieldShort } // end of method CompoundAssignmentTest::IncrementStaticFieldShort
.method public hidebysig instance void
DoubleStaticFieldShort() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: conv.i2
IL_0009: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldShort
.method public hidebysig instance int16
DoubleStaticFieldAndReturnShort() cil managed
{
// Code size 20 (0x14)
.maxstack 2
.locals init (int16 V_0)
IL_0000: nop
IL_0001: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: conv.i2
IL_0009: dup
IL_000a: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturnShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticProperty() cil managed PreIncrementStaticProperty() cil managed
{ {
@ -1456,6 +1793,40 @@
IL_000e: ret IL_000e: ret
} // end of method CompoundAssignmentTest::IncrementStaticProperty } // end of method CompoundAssignmentTest::IncrementStaticProperty
.method public hidebysig instance void
DoubleStaticProperty() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000d: nop
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleStaticProperty
.method public hidebysig instance int32
DoubleStaticPropertyAndReturn() cil managed
{
// Code size 20 (0x14)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: dup
IL_0009: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000e: nop
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleStaticPropertyAndReturn
.method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum .method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum
PreIncrementStaticPropertyShort() cil managed PreIncrementStaticPropertyShort() cil managed
{ {
@ -1547,7 +1918,7 @@
Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a, Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed
{ {
// Code size 8 (0x8) // Code size 22 (0x16)
.maxstack 8 .maxstack 8
IL_0000: nop IL_0000: nop
IL_0001: ldarg.1 IL_0001: ldarg.1
@ -1556,7 +1927,13 @@
IL_0004: ldarg.2 IL_0004: ldarg.2
IL_0005: rem IL_0005: rem
IL_0006: stind.i4 IL_0006: stind.i4
IL_0007: ret IL_0007: ldarg.0
IL_0008: ldarg.0
IL_0009: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_000e: ldarg.2
IL_000f: rem
IL_0010: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0015: ret
} // end of method CompoundAssignmentTest::Issue954 } // end of method CompoundAssignmentTest::Issue954
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname

342
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.il

@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly '20aqunvz' .assembly vm2ov5l1
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
@ -20,15 +20,15 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module '20aqunvz.dll' .module vm2ov5l1.dll
// MVID: {3A9D60C3-9668-4C33-85C8-329DB1EEECE6} // MVID: {F7BCAA28-E619-40E7-921D-149FF48046FD}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x029E0000 // Image base: 0x052F0000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -186,6 +186,7 @@
.field private int32[] array1 .field private int32[] array1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1 .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum shortEnumField
.field public static int32 StaticField .field public static int32 StaticField
.field public static int16 StaticShortField .field public static int16 StaticShortField
.field private static int32 '<StaticProperty>k__BackingField' .field private static int32 '<StaticProperty>k__BackingField'
@ -659,7 +660,7 @@
.method public hidebysig instance void .method public hidebysig instance void
Enum() cil managed Enum() cil managed
{ {
// Code size 30 (0x1e) // Code size 58 (0x3a)
.maxstack 8 .maxstack 8
IL_0000: ldarg.0 IL_0000: ldarg.0
IL_0001: dup IL_0001: dup
@ -673,9 +674,57 @@
IL_0015: ldc.i4.s -5 IL_0015: ldc.i4.s -5
IL_0017: and IL_0017: and
IL_0018: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField IL_0018: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_001d: ret IL_001d: ldarg.0
IL_001e: dup
IL_001f: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0024: ldc.i4.2
IL_0025: add
IL_0026: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_002b: ldarg.0
IL_002c: dup
IL_002d: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0032: ldc.i4.3
IL_0033: sub
IL_0034: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0039: ret
} // end of method CompoundAssignmentTest::Enum } // end of method CompoundAssignmentTest::Enum
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 62 (0x3e)
.maxstack 8
IL_0000: ldarg.0
IL_0001: dup
IL_0002: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0007: ldc.i4.2
IL_0008: or
IL_0009: conv.i2
IL_000a: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_000f: ldarg.0
IL_0010: dup
IL_0011: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0016: ldc.i4.s -5
IL_0018: and
IL_0019: conv.i2
IL_001a: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_001f: ldarg.0
IL_0020: dup
IL_0021: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0026: ldc.i4.2
IL_0027: add
IL_0028: conv.i2
IL_0029: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_002e: ldarg.0
IL_002f: dup
IL_0030: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0035: ldc.i4.3
IL_0036: sub
IL_0037: conv.i2
IL_0038: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_003d: ret
} // end of method CompoundAssignmentTest::ShortEnumTest
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInAddition(int32 i, PreIncrementInAddition(int32 i,
int32 j) cil managed int32 j) cil managed
@ -751,8 +800,46 @@
IL_0014: ret IL_0014: ret
} // end of method CompoundAssignmentTest::IncrementArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElement
.method public hidebysig instance void
DoubleArrayElement(int32[] 'array',
int32 pos) cil managed
{
// Code size 21 (0x15)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int32
IL_0007: dup
IL_0008: ldobj [mscorlib]System.Int32
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: stobj [mscorlib]System.Int32
IL_0014: ret
} // end of method CompoundAssignmentTest::DoubleArrayElement
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementShortArrayElement(int16[] 'array', DoubleArrayElementAndReturn(int32[] 'array',
int32 pos) cil managed
{
// Code size 24 (0x18)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int32
IL_0007: dup
IL_0008: ldobj [mscorlib]System.Int32
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: dup
IL_0010: stloc.0
IL_0011: stobj [mscorlib]System.Int32
IL_0016: ldloc.0
IL_0017: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementAndReturn
.method public hidebysig instance int32
PreIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 25 (0x19) // Code size 25 (0x19)
@ -771,10 +858,10 @@
IL_0012: stobj [mscorlib]System.Int16 IL_0012: stobj [mscorlib]System.Int16
IL_0017: ldloc.0 IL_0017: ldloc.0
IL_0018: ret IL_0018: ret
} // end of method CompoundAssignmentTest::PreIncrementShortArrayElement } // end of method CompoundAssignmentTest::PreIncrementArrayElementShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PostIncrementShortArrayElement(int16[] 'array', PostIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 25 (0x19) // Code size 25 (0x19)
@ -793,10 +880,10 @@
IL_0012: stobj [mscorlib]System.Int16 IL_0012: stobj [mscorlib]System.Int16
IL_0017: ldloc.0 IL_0017: ldloc.0
IL_0018: ret IL_0018: ret
} // end of method CompoundAssignmentTest::PostIncrementShortArrayElement } // end of method CompoundAssignmentTest::PostIncrementArrayElementShort
.method public hidebysig instance void .method public hidebysig instance void
IncrementShortArrayElement(int16[] 'array', IncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 22 (0x16) // Code size 22 (0x16)
@ -811,7 +898,47 @@
IL_000f: conv.i2 IL_000f: conv.i2
IL_0010: stobj [mscorlib]System.Int16 IL_0010: stobj [mscorlib]System.Int16
IL_0015: ret IL_0015: ret
} // end of method CompoundAssignmentTest::IncrementShortArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElementShort
.method public hidebysig instance void
DoubleArrayElementShort(int16[] 'array',
int32 pos) cil managed
{
// Code size 22 (0x16)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int16
IL_0007: dup
IL_0008: ldobj [mscorlib]System.Int16
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: conv.i2
IL_0010: stobj [mscorlib]System.Int16
IL_0015: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShort
.method public hidebysig instance int16
DoubleArrayElementShortAndReturn(int16[] 'array',
int32 pos) cil managed
{
// Code size 25 (0x19)
.maxstack 3
.locals init (int16 V_0)
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int16
IL_0007: dup
IL_0008: ldobj [mscorlib]System.Int16
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: conv.i2
IL_0010: dup
IL_0011: stloc.0
IL_0012: stobj [mscorlib]System.Int16
IL_0017: ldloc.0
IL_0018: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShortAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField() cil managed PreIncrementInstanceField() cil managed
@ -866,6 +993,40 @@
IL_0013: ret IL_0013: ret
} // end of method CompoundAssignmentTest::IncrementInstanceField } // end of method CompoundAssignmentTest::IncrementInstanceField
.method public hidebysig instance void
DoubleInstanceField() cil managed
{
// Code size 20 (0x14)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleInstanceField
.method public hidebysig instance int32
DoubleInstanceFieldAndReturn() cil managed
{
// Code size 23 (0x17)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: dup
IL_000f: stloc.0
IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0015: ldloc.0
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleInstanceFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed
{ {
@ -1025,6 +1186,40 @@
IL_0013: ret IL_0013: ret
} // end of method CompoundAssignmentTest::IncrementInstanceProperty } // end of method CompoundAssignmentTest::IncrementInstanceProperty
.method public hidebysig instance void
DoubleInstanceProperty() cil managed
{
// Code size 20 (0x14)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleInstanceProperty
.method public hidebysig instance int32
DoubleInstancePropertyAndReturn() cil managed
{
// Code size 23 (0x17)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: dup
IL_000f: stloc.0
IL_0010: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0015: ldloc.0
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstancePropertyByte() cil managed PreIncrementInstancePropertyByte() cil managed
{ {
@ -1081,6 +1276,42 @@
IL_0014: ret IL_0014: ret
} // end of method CompoundAssignmentTest::IncrementInstancePropertyByte } // end of method CompoundAssignmentTest::IncrementInstancePropertyByte
.method public hidebysig instance void
DoubleInstancePropertyByte() cil managed
{
// Code size 21 (0x15)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: conv.u1
IL_000f: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0014: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByte
.method public hidebysig instance int32
DoubleInstancePropertyByteAndReturn() cil managed
{
// Code size 24 (0x18)
.maxstack 3
.locals init (uint8 V_0)
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: conv.u1
IL_000f: dup
IL_0010: stloc.0
IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0016: ldloc.0
IL_0017: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByteAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticField() cil managed PreIncrementStaticField() cil managed
{ {
@ -1119,6 +1350,31 @@
IL_000c: ret IL_000c: ret
} // end of method CompoundAssignmentTest::IncrementStaticField } // end of method CompoundAssignmentTest::IncrementStaticField
.method public hidebysig instance void
DoubleStaticField() cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000c: ret
} // end of method CompoundAssignmentTest::DoubleStaticField
.method public hidebysig instance int32
DoubleStaticFieldAndReturn() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: dup
IL_0008: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticFieldShort() cil managed PreIncrementStaticFieldShort() cil managed
{ {
@ -1160,6 +1416,33 @@
IL_000d: ret IL_000d: ret
} // end of method CompoundAssignmentTest::IncrementStaticFieldShort } // end of method CompoundAssignmentTest::IncrementStaticFieldShort
.method public hidebysig instance void
DoubleStaticFieldShort() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: conv.i2
IL_0008: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldShort
.method public hidebysig instance int16
DoubleStaticFieldAndReturnShort() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: conv.i2
IL_0008: dup
IL_0009: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturnShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticProperty() cil managed PreIncrementStaticProperty() cil managed
{ {
@ -1198,6 +1481,31 @@
IL_000c: ret IL_000c: ret
} // end of method CompoundAssignmentTest::IncrementStaticProperty } // end of method CompoundAssignmentTest::IncrementStaticProperty
.method public hidebysig instance void
DoubleStaticProperty() cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000c: ret
} // end of method CompoundAssignmentTest::DoubleStaticProperty
.method public hidebysig instance int32
DoubleStaticPropertyAndReturn() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: dup
IL_0008: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticPropertyAndReturn
.method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum .method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum
PreIncrementStaticPropertyShort() cil managed PreIncrementStaticPropertyShort() cil managed
{ {
@ -1266,7 +1574,7 @@
Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a, Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed
{ {
// Code size 7 (0x7) // Code size 21 (0x15)
.maxstack 8 .maxstack 8
IL_0000: ldarg.1 IL_0000: ldarg.1
IL_0001: ldarg.1 IL_0001: ldarg.1
@ -1274,7 +1582,13 @@
IL_0003: ldarg.2 IL_0003: ldarg.2
IL_0004: rem IL_0004: rem
IL_0005: stind.i4 IL_0005: stind.i4
IL_0006: ret IL_0006: ldarg.0
IL_0007: ldarg.0
IL_0008: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_000d: ldarg.2
IL_000e: rem
IL_000f: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0014: ret
} // end of method CompoundAssignmentTest::Issue954 } // end of method CompoundAssignmentTest::Issue954
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname

336
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.roslyn.il

@ -25,14 +25,14 @@
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module CompoundAssignmentTest.dll .module CompoundAssignmentTest.dll
// MVID: {8664D95A-CCCF-4302-9678-AEB0491B7A00} // MVID: {9C969BC5-E3E2-4944-BB85-4B7EAAE52E4D}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x02D20000 // Image base: 0x00480000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -190,6 +190,7 @@
.field private int32[] array1 .field private int32[] array1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1 .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum shortEnumField
.field public static int32 StaticField .field public static int32 StaticField
.field public static int16 StaticShortField .field public static int16 StaticShortField
.field private static int32 '<StaticProperty>k__BackingField' .field private static int32 '<StaticProperty>k__BackingField'
@ -662,7 +663,7 @@
.method public hidebysig instance void .method public hidebysig instance void
Enum() cil managed Enum() cil managed
{ {
// Code size 30 (0x1e) // Code size 58 (0x3a)
.maxstack 8 .maxstack 8
IL_0000: ldarg.0 IL_0000: ldarg.0
IL_0001: ldarg.0 IL_0001: ldarg.0
@ -676,9 +677,55 @@
IL_0015: ldc.i4.s -5 IL_0015: ldc.i4.s -5
IL_0017: and IL_0017: and
IL_0018: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField IL_0018: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_001d: ret IL_001d: ldarg.0
IL_001e: ldarg.0
IL_001f: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0024: ldc.i4.2
IL_0025: add
IL_0026: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_002b: ldarg.0
IL_002c: ldarg.0
IL_002d: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0032: ldc.i4.3
IL_0033: sub
IL_0034: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0039: ret
} // end of method CompoundAssignmentTest::Enum } // end of method CompoundAssignmentTest::Enum
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 60 (0x3c)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.0
IL_0002: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0007: ldc.i4.2
IL_0008: or
IL_0009: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_000e: ldarg.0
IL_000f: ldarg.0
IL_0010: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0015: ldc.i4.s -5
IL_0017: and
IL_0018: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_001d: ldarg.0
IL_001e: ldarg.0
IL_001f: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0024: ldc.i4.2
IL_0025: add
IL_0026: conv.i2
IL_0027: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_002c: ldarg.0
IL_002d: ldarg.0
IL_002e: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0033: ldc.i4.3
IL_0034: sub
IL_0035: conv.i2
IL_0036: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_003b: ret
} // end of method CompoundAssignmentTest::ShortEnumTest
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInAddition(int32 i, PreIncrementInAddition(int32 i,
int32 j) cil managed int32 j) cil managed
@ -754,8 +801,46 @@
IL_000c: ret IL_000c: ret
} // end of method CompoundAssignmentTest::IncrementArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElement
.method public hidebysig instance void
DoubleArrayElement(int32[] 'array',
int32 pos) cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int32
IL_0007: dup
IL_0008: ldind.i4
IL_0009: ldc.i4.2
IL_000a: mul
IL_000b: stind.i4
IL_000c: ret
} // end of method CompoundAssignmentTest::DoubleArrayElement
.method public hidebysig instance int32
DoubleArrayElementAndReturn(int32[] 'array',
int32 pos) cil managed
{
// Code size 16 (0x10)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int32
IL_0007: dup
IL_0008: ldind.i4
IL_0009: ldc.i4.2
IL_000a: mul
IL_000b: dup
IL_000c: stloc.0
IL_000d: stind.i4
IL_000e: ldloc.0
IL_000f: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementShortArrayElement(int16[] 'array', PreIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 17 (0x11) // Code size 17 (0x11)
@ -774,10 +859,10 @@
IL_000e: stind.i2 IL_000e: stind.i2
IL_000f: ldloc.0 IL_000f: ldloc.0
IL_0010: ret IL_0010: ret
} // end of method CompoundAssignmentTest::PreIncrementShortArrayElement } // end of method CompoundAssignmentTest::PreIncrementArrayElementShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PostIncrementShortArrayElement(int16[] 'array', PostIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 17 (0x11) // Code size 17 (0x11)
@ -796,10 +881,10 @@
IL_000e: stind.i2 IL_000e: stind.i2
IL_000f: ldloc.0 IL_000f: ldloc.0
IL_0010: ret IL_0010: ret
} // end of method CompoundAssignmentTest::PostIncrementShortArrayElement } // end of method CompoundAssignmentTest::PostIncrementArrayElementShort
.method public hidebysig instance void .method public hidebysig instance void
IncrementShortArrayElement(int16[] 'array', IncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 14 (0xe) // Code size 14 (0xe)
@ -814,7 +899,47 @@
IL_000b: conv.i2 IL_000b: conv.i2
IL_000c: stind.i2 IL_000c: stind.i2
IL_000d: ret IL_000d: ret
} // end of method CompoundAssignmentTest::IncrementShortArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElementShort
.method public hidebysig instance void
DoubleArrayElementShort(int16[] 'array',
int32 pos) cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int16
IL_0007: dup
IL_0008: ldind.i2
IL_0009: ldc.i4.2
IL_000a: mul
IL_000b: conv.i2
IL_000c: stind.i2
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShort
.method public hidebysig instance int16
DoubleArrayElementShortAndReturn(int16[] 'array',
int32 pos) cil managed
{
// Code size 17 (0x11)
.maxstack 3
.locals init (int16 V_0)
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldelema [mscorlib]System.Int16
IL_0007: dup
IL_0008: ldind.i2
IL_0009: ldc.i4.2
IL_000a: mul
IL_000b: conv.i2
IL_000c: dup
IL_000d: stloc.0
IL_000e: stind.i2
IL_000f: ldloc.0
IL_0010: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShortAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField() cil managed PreIncrementInstanceField() cil managed
@ -869,6 +994,40 @@
IL_0013: ret IL_0013: ret
} // end of method CompoundAssignmentTest::IncrementInstanceField } // end of method CompoundAssignmentTest::IncrementInstanceField
.method public hidebysig instance void
DoubleInstanceField() cil managed
{
// Code size 20 (0x14)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleInstanceField
.method public hidebysig instance int32
DoubleInstanceFieldAndReturn() cil managed
{
// Code size 23 (0x17)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: dup
IL_000f: stloc.0
IL_0010: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0015: ldloc.0
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleInstanceFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed
{ {
@ -1031,6 +1190,40 @@
IL_0015: ret IL_0015: ret
} // end of method CompoundAssignmentTest::IncrementInstanceProperty } // end of method CompoundAssignmentTest::IncrementInstanceProperty
.method public hidebysig instance void
DoubleInstanceProperty() cil managed
{
// Code size 20 (0x14)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleInstanceProperty
.method public hidebysig instance int32
DoubleInstancePropertyAndReturn() cil managed
{
// Code size 23 (0x17)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: dup
IL_000f: stloc.0
IL_0010: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0015: ldloc.0
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstancePropertyByte() cil managed PreIncrementInstancePropertyByte() cil managed
{ {
@ -1090,6 +1283,42 @@
IL_0016: ret IL_0016: ret
} // end of method CompoundAssignmentTest::IncrementInstancePropertyByte } // end of method CompoundAssignmentTest::IncrementInstancePropertyByte
.method public hidebysig instance void
DoubleInstancePropertyByte() cil managed
{
// Code size 21 (0x15)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: conv.u1
IL_000f: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0014: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByte
.method public hidebysig instance int32
DoubleInstancePropertyByteAndReturn() cil managed
{
// Code size 24 (0x18)
.maxstack 3
.locals init (uint8 V_0)
IL_0000: ldarg.0
IL_0001: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0006: dup
IL_0007: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000c: ldc.i4.2
IL_000d: mul
IL_000e: conv.u1
IL_000f: dup
IL_0010: stloc.0
IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0016: ldloc.0
IL_0017: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByteAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticField() cil managed PreIncrementStaticField() cil managed
{ {
@ -1128,6 +1357,31 @@
IL_000c: ret IL_000c: ret
} // end of method CompoundAssignmentTest::IncrementStaticField } // end of method CompoundAssignmentTest::IncrementStaticField
.method public hidebysig instance void
DoubleStaticField() cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000c: ret
} // end of method CompoundAssignmentTest::DoubleStaticField
.method public hidebysig instance int32
DoubleStaticFieldAndReturn() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: dup
IL_0008: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticFieldShort() cil managed PreIncrementStaticFieldShort() cil managed
{ {
@ -1169,6 +1423,33 @@
IL_000d: ret IL_000d: ret
} // end of method CompoundAssignmentTest::IncrementStaticFieldShort } // end of method CompoundAssignmentTest::IncrementStaticFieldShort
.method public hidebysig instance void
DoubleStaticFieldShort() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: conv.i2
IL_0008: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldShort
.method public hidebysig instance int16
DoubleStaticFieldAndReturnShort() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: conv.i2
IL_0008: dup
IL_0009: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturnShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticProperty() cil managed PreIncrementStaticProperty() cil managed
{ {
@ -1207,6 +1488,31 @@
IL_000c: ret IL_000c: ret
} // end of method CompoundAssignmentTest::IncrementStaticProperty } // end of method CompoundAssignmentTest::IncrementStaticProperty
.method public hidebysig instance void
DoubleStaticProperty() cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000c: ret
} // end of method CompoundAssignmentTest::DoubleStaticProperty
.method public hidebysig instance int32
DoubleStaticPropertyAndReturn() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0005: ldc.i4.2
IL_0006: mul
IL_0007: dup
IL_0008: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticPropertyAndReturn
.method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum .method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum
PreIncrementStaticPropertyShort() cil managed PreIncrementStaticPropertyShort() cil managed
{ {
@ -1272,7 +1578,7 @@
Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a, Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed
{ {
// Code size 7 (0x7) // Code size 21 (0x15)
.maxstack 8 .maxstack 8
IL_0000: ldarg.1 IL_0000: ldarg.1
IL_0001: ldarg.1 IL_0001: ldarg.1
@ -1280,7 +1586,13 @@
IL_0003: ldarg.2 IL_0003: ldarg.2
IL_0004: rem IL_0004: rem
IL_0005: stind.i4 IL_0005: stind.i4
IL_0006: ret IL_0006: ldarg.0
IL_0007: ldarg.0
IL_0008: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_000d: ldarg.2
IL_000e: rem
IL_000f: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0014: ret
} // end of method CompoundAssignmentTest::Issue954 } // end of method CompoundAssignmentTest::Issue954
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname

399
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.roslyn.il

@ -25,14 +25,14 @@
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module CompoundAssignmentTest.dll .module CompoundAssignmentTest.dll
// MVID: {9D118C00-E9E9-446E-9B2F-0C32732A9171} // MVID: {AB7EC3EB-B732-497E-809B-7D4DBB442E2C}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x02BF0000 // Image base: 0x019F0000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -201,6 +201,7 @@
.field private int32[] array1 .field private int32[] array1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1 .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField .field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum shortEnumField
.field public static int32 StaticField .field public static int32 StaticField
.field public static int16 StaticShortField .field public static int16 StaticShortField
.field private static int32 '<StaticProperty>k__BackingField' .field private static int32 '<StaticProperty>k__BackingField'
@ -760,7 +761,7 @@
.method public hidebysig instance void .method public hidebysig instance void
Enum() cil managed Enum() cil managed
{ {
// Code size 31 (0x1f) // Code size 59 (0x3b)
.maxstack 8 .maxstack 8
IL_0000: nop IL_0000: nop
IL_0001: ldarg.0 IL_0001: ldarg.0
@ -775,9 +776,56 @@
IL_0016: ldc.i4.s -5 IL_0016: ldc.i4.s -5
IL_0018: and IL_0018: and
IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_001e: ret IL_001e: ldarg.0
IL_001f: ldarg.0
IL_0020: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0025: ldc.i4.2
IL_0026: add
IL_0027: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_002c: ldarg.0
IL_002d: ldarg.0
IL_002e: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0033: ldc.i4.3
IL_0034: sub
IL_0035: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_003a: ret
} // end of method CompoundAssignmentTest::Enum } // end of method CompoundAssignmentTest::Enum
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 61 (0x3d)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.0
IL_0003: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0008: ldc.i4.2
IL_0009: or
IL_000a: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_000f: ldarg.0
IL_0010: ldarg.0
IL_0011: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0016: ldc.i4.s -5
IL_0018: and
IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_001e: ldarg.0
IL_001f: ldarg.0
IL_0020: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0025: ldc.i4.2
IL_0026: add
IL_0027: conv.i2
IL_0028: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_002d: ldarg.0
IL_002e: ldarg.0
IL_002f: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0034: ldc.i4.3
IL_0035: sub
IL_0036: conv.i2
IL_0037: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_003c: ret
} // end of method CompoundAssignmentTest::ShortEnumTest
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInAddition(int32 i, PreIncrementInAddition(int32 i,
int32 j) cil managed int32 j) cil managed
@ -872,8 +920,53 @@
IL_000d: ret IL_000d: ret
} // end of method CompoundAssignmentTest::IncrementArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElement
.method public hidebysig instance void
DoubleArrayElement(int32[] 'array',
int32 pos) cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int32
IL_0008: dup
IL_0009: ldind.i4
IL_000a: ldc.i4.2
IL_000b: mul
IL_000c: stind.i4
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleArrayElement
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementShortArrayElement(int16[] 'array', DoubleArrayElementAndReturn(int32[] 'array',
int32 pos) cil managed
{
// Code size 21 (0x15)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int32
IL_0008: dup
IL_0009: ldind.i4
IL_000a: ldc.i4.2
IL_000b: mul
IL_000c: dup
IL_000d: stloc.0
IL_000e: stind.i4
IL_000f: ldloc.0
IL_0010: stloc.1
IL_0011: br.s IL_0013
IL_0013: ldloc.1
IL_0014: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementAndReturn
.method public hidebysig instance int32
PreIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 22 (0x16) // Code size 22 (0x16)
@ -898,10 +991,10 @@
IL_0014: ldloc.1 IL_0014: ldloc.1
IL_0015: ret IL_0015: ret
} // end of method CompoundAssignmentTest::PreIncrementShortArrayElement } // end of method CompoundAssignmentTest::PreIncrementArrayElementShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PostIncrementShortArrayElement(int16[] 'array', PostIncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 22 (0x16) // Code size 22 (0x16)
@ -926,10 +1019,10 @@
IL_0014: ldloc.1 IL_0014: ldloc.1
IL_0015: ret IL_0015: ret
} // end of method CompoundAssignmentTest::PostIncrementShortArrayElement } // end of method CompoundAssignmentTest::PostIncrementArrayElementShort
.method public hidebysig instance void .method public hidebysig instance void
IncrementShortArrayElement(int16[] 'array', IncrementArrayElementShort(int16[] 'array',
int32 pos) cil managed int32 pos) cil managed
{ {
// Code size 15 (0xf) // Code size 15 (0xf)
@ -945,7 +1038,54 @@
IL_000c: conv.i2 IL_000c: conv.i2
IL_000d: stind.i2 IL_000d: stind.i2
IL_000e: ret IL_000e: ret
} // end of method CompoundAssignmentTest::IncrementShortArrayElement } // end of method CompoundAssignmentTest::IncrementArrayElementShort
.method public hidebysig instance void
DoubleArrayElementShort(int16[] 'array',
int32 pos) cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int16
IL_0008: dup
IL_0009: ldind.i2
IL_000a: ldc.i4.2
IL_000b: mul
IL_000c: conv.i2
IL_000d: stind.i2
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShort
.method public hidebysig instance int16
DoubleArrayElementShortAndReturn(int16[] 'array',
int32 pos) cil managed
{
// Code size 22 (0x16)
.maxstack 3
.locals init (int16 V_0,
int16 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldelema [mscorlib]System.Int16
IL_0008: dup
IL_0009: ldind.i2
IL_000a: ldc.i4.2
IL_000b: mul
IL_000c: conv.i2
IL_000d: dup
IL_000e: stloc.0
IL_000f: stind.i2
IL_0010: ldloc.0
IL_0011: stloc.1
IL_0012: br.s IL_0014
IL_0014: ldloc.1
IL_0015: ret
} // end of method CompoundAssignmentTest::DoubleArrayElementShortAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField() cil managed PreIncrementInstanceField() cil managed
@ -1013,6 +1153,47 @@
IL_0014: ret IL_0014: ret
} // end of method CompoundAssignmentTest::IncrementInstanceField } // end of method CompoundAssignmentTest::IncrementInstanceField
.method public hidebysig instance void
DoubleInstanceField() cil managed
{
// Code size 21 (0x15)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0014: ret
} // end of method CompoundAssignmentTest::DoubleInstanceField
.method public hidebysig instance int32
DoubleInstanceFieldAndReturn() cil managed
{
// Code size 28 (0x1c)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: dup
IL_0010: stloc.0
IL_0011: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0016: ldloc.0
IL_0017: stloc.1
IL_0018: br.s IL_001a
IL_001a: ldloc.1
IL_001b: ret
} // end of method CompoundAssignmentTest::DoubleInstanceFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed
{ {
@ -1217,6 +1398,49 @@
IL_0017: ret IL_0017: ret
} // end of method CompoundAssignmentTest::IncrementInstanceProperty } // end of method CompoundAssignmentTest::IncrementInstanceProperty
.method public hidebysig instance void
DoubleInstanceProperty() cil managed
{
// Code size 22 (0x16)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0014: nop
IL_0015: ret
} // end of method CompoundAssignmentTest::DoubleInstanceProperty
.method public hidebysig instance int32
DoubleInstancePropertyAndReturn() cil managed
{
// Code size 29 (0x1d)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: dup
IL_0010: stloc.0
IL_0011: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
IL_0016: nop
IL_0017: ldloc.0
IL_0018: stloc.1
IL_0019: br.s IL_001b
IL_001b: ldloc.1
IL_001c: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementInstancePropertyByte() cil managed PreIncrementInstancePropertyByte() cil managed
{ {
@ -1292,6 +1516,51 @@
IL_0018: ret IL_0018: ret
} // end of method CompoundAssignmentTest::IncrementInstancePropertyByte } // end of method CompoundAssignmentTest::IncrementInstancePropertyByte
.method public hidebysig instance void
DoubleInstancePropertyByte() cil managed
{
// Code size 23 (0x17)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: conv.u1
IL_0010: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0015: nop
IL_0016: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByte
.method public hidebysig instance int32
DoubleInstancePropertyByteAndReturn() cil managed
{
// Code size 30 (0x1e)
.maxstack 3
.locals init (uint8 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::M()
IL_0007: dup
IL_0008: callvirt instance uint8 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_ByteProperty()
IL_000d: ldc.i4.2
IL_000e: mul
IL_000f: conv.u1
IL_0010: dup
IL_0011: stloc.0
IL_0012: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_ByteProperty(uint8)
IL_0017: nop
IL_0018: ldloc.0
IL_0019: stloc.1
IL_001a: br.s IL_001c
IL_001c: ldloc.1
IL_001d: ret
} // end of method CompoundAssignmentTest::DoubleInstancePropertyByteAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticField() cil managed PreIncrementStaticField() cil managed
{ {
@ -1343,6 +1612,38 @@
IL_000d: ret IL_000d: ret
} // end of method CompoundAssignmentTest::IncrementStaticField } // end of method CompoundAssignmentTest::IncrementStaticField
.method public hidebysig instance void
DoubleStaticField() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: nop
IL_0001: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000d: ret
} // end of method CompoundAssignmentTest::DoubleStaticField
.method public hidebysig instance int32
DoubleStaticFieldAndReturn() cil managed
{
// Code size 19 (0x13)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: dup
IL_0009: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticField
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturn
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticFieldShort() cil managed PreIncrementStaticFieldShort() cil managed
{ {
@ -1397,6 +1698,40 @@
IL_000e: ret IL_000e: ret
} // end of method CompoundAssignmentTest::IncrementStaticFieldShort } // end of method CompoundAssignmentTest::IncrementStaticFieldShort
.method public hidebysig instance void
DoubleStaticFieldShort() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: conv.i2
IL_0009: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldShort
.method public hidebysig instance int16
DoubleStaticFieldAndReturnShort() cil managed
{
// Code size 20 (0x14)
.maxstack 2
.locals init (int16 V_0)
IL_0000: nop
IL_0001: ldsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: conv.i2
IL_0009: dup
IL_000a: stsfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::StaticShortField
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleStaticFieldAndReturnShort
.method public hidebysig instance int32 .method public hidebysig instance int32
PreIncrementStaticProperty() cil managed PreIncrementStaticProperty() cil managed
{ {
@ -1451,6 +1786,40 @@
IL_000e: ret IL_000e: ret
} // end of method CompoundAssignmentTest::IncrementStaticProperty } // end of method CompoundAssignmentTest::IncrementStaticProperty
.method public hidebysig instance void
DoubleStaticProperty() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000d: nop
IL_000e: ret
} // end of method CompoundAssignmentTest::DoubleStaticProperty
.method public hidebysig instance int32
DoubleStaticPropertyAndReturn() cil managed
{
// Code size 20 (0x14)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: call int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
IL_0006: ldc.i4.2
IL_0007: mul
IL_0008: dup
IL_0009: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
IL_000e: nop
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method CompoundAssignmentTest::DoubleStaticPropertyAndReturn
.method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum .method public hidebysig instance valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum
PreIncrementStaticPropertyShort() cil managed PreIncrementStaticPropertyShort() cil managed
{ {
@ -1542,7 +1911,7 @@
Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a, Issue954(valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum& a,
valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum b) cil managed
{ {
// Code size 8 (0x8) // Code size 22 (0x16)
.maxstack 8 .maxstack 8
IL_0000: nop IL_0000: nop
IL_0001: ldarg.1 IL_0001: ldarg.1
@ -1551,7 +1920,13 @@
IL_0004: ldarg.2 IL_0004: ldarg.2
IL_0005: rem IL_0005: rem
IL_0006: stind.i4 IL_0006: stind.i4
IL_0007: ret IL_0007: ldarg.0
IL_0008: ldarg.0
IL_0009: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_000e: ldarg.2
IL_000f: rem
IL_0010: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0015: ret
} // end of method CompoundAssignmentTest::Issue954 } // end of method CompoundAssignmentTest::Issue954
.method public hidebysig specialname rtspecialname .method public hidebysig specialname rtspecialname

4
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -1078,7 +1078,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (NullableType.IsNullable(value.Type)) { if (NullableType.IsNullable(value.Type)) {
targetType = NullableType.Create(compilation, targetType); targetType = NullableType.Create(compilation, targetType);
} }
value = value.ConvertTo(targetType, this, inst.CheckForOverflow); value = value.ConvertTo(targetType, this, inst.CheckForOverflow, allowImplicitConversion: true);
break; break;
} }
case AssignmentOperatorType.Multiply: case AssignmentOperatorType.Multiply:
@ -1091,7 +1091,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (NullableType.IsNullable(value.Type)) { if (NullableType.IsNullable(value.Type)) {
targetType = NullableType.Create(compilation, targetType); targetType = NullableType.Create(compilation, targetType);
} }
value = value.ConvertTo(targetType, this, inst.CheckForOverflow); value = value.ConvertTo(targetType, this, inst.CheckForOverflow, allowImplicitConversion: true);
break; break;
} }
} }

8
ICSharpCode.Decompiler/IL/Instructions.cs

@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.IL
/// <summary>Loads the address of a local variable. (ldarga/ldloca)</summary> /// <summary>Loads the address of a local variable. (ldarga/ldloca)</summary>
LdLoca, LdLoca,
/// <summary>Stores a value into a local variable. (IL: starg/stloc) /// <summary>Stores a value into a local variable. (IL: starg/stloc)
/// Evaluates to the value that was stored (for byte/short variables: evaluates to the truncated value)</summary> /// Evaluates to the value that was stored (for byte/short variables: evaluates to the truncated value, sign/zero extended back to I4 based on variable.Type.GetSign())</summary>
StLoc, StLoc,
/// <summary>Stores the value into an anonymous temporary variable, and returns the address of that variable.</summary> /// <summary>Stores the value into an anonymous temporary variable, and returns the address of that variable.</summary>
AddressOf, AddressOf,
@ -139,7 +139,7 @@ namespace ICSharpCode.Decompiler.IL
/// <summary>Indirect load (ref/pointer dereference).</summary> /// <summary>Indirect load (ref/pointer dereference).</summary>
LdObj, LdObj,
/// <summary>Indirect store (store to ref/pointer). /// <summary>Indirect store (store to ref/pointer).
/// Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value)</summary> /// Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value, sign/zero extended back to I4 based on type.GetSign())</summary>
StObj, StObj,
/// <summary>Boxes a value.</summary> /// <summary>Boxes a value.</summary>
Box, Box,
@ -2223,7 +2223,7 @@ namespace ICSharpCode.Decompiler.IL
namespace ICSharpCode.Decompiler.IL namespace ICSharpCode.Decompiler.IL
{ {
/// <summary>Stores a value into a local variable. (IL: starg/stloc) /// <summary>Stores a value into a local variable. (IL: starg/stloc)
/// Evaluates to the value that was stored (for byte/short variables: evaluates to the truncated value)</summary> /// Evaluates to the value that was stored (for byte/short variables: evaluates to the truncated value, sign/zero extended back to I4 based on variable.Type.GetSign())</summary>
public sealed partial class StLoc : ILInstruction, IStoreInstruction public sealed partial class StLoc : ILInstruction, IStoreInstruction
{ {
public StLoc(ILVariable variable, ILInstruction value) : base(OpCode.StLoc) public StLoc(ILVariable variable, ILInstruction value) : base(OpCode.StLoc)
@ -3559,7 +3559,7 @@ namespace ICSharpCode.Decompiler.IL
namespace ICSharpCode.Decompiler.IL namespace ICSharpCode.Decompiler.IL
{ {
/// <summary>Indirect store (store to ref/pointer). /// <summary>Indirect store (store to ref/pointer).
/// Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value)</summary> /// Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value, sign/zero extended back to I4 based on type.GetSign())</summary>
public sealed partial class StObj : ILInstruction, ISupportsVolatilePrefix, ISupportsUnalignedPrefix public sealed partial class StObj : ILInstruction, ISupportsVolatilePrefix, ISupportsUnalignedPrefix
{ {
public StObj(ILInstruction target, ILInstruction value, IType type) : base(OpCode.StObj) public StObj(ILInstruction target, ILInstruction value, IType type) : base(OpCode.StObj)

4
ICSharpCode.Decompiler/IL/Instructions.tt

@ -151,7 +151,7 @@
new OpCode("ldloca", "Loads the address of a local variable. (ldarga/ldloca)", new OpCode("ldloca", "Loads the address of a local variable. (ldarga/ldloca)",
CustomClassName("LdLoca"), NoArguments, ResultType("Ref"), HasVariableOperand("Address")), CustomClassName("LdLoca"), NoArguments, ResultType("Ref"), HasVariableOperand("Address")),
new OpCode("stloc", "Stores a value into a local variable. (IL: starg/stloc)" + Environment.NewLine new OpCode("stloc", "Stores a value into a local variable. (IL: starg/stloc)" + Environment.NewLine
+ "Evaluates to the value that was stored (for byte/short variables: evaluates to the truncated value)", + "Evaluates to the value that was stored (for byte/short variables: evaluates to the truncated value, sign/zero extended back to I4 based on variable.Type.GetSign())",
CustomClassName("StLoc"), HasVariableOperand("Store"), CustomArguments("value"), CustomClassName("StLoc"), HasVariableOperand("Store"), CustomArguments("value"),
ResultType("variable.StackType")), ResultType("variable.StackType")),
new OpCode("addressof", "Stores the value into an anonymous temporary variable, and returns the address of that variable.", new OpCode("addressof", "Stores the value into an anonymous temporary variable, and returns the address of that variable.",
@ -206,7 +206,7 @@
CustomClassName("LdObj"), CustomArguments("target"), HasTypeOperand, MemoryAccess, CustomWriteToButKeepOriginal, CustomClassName("LdObj"), CustomArguments("target"), HasTypeOperand, MemoryAccess, CustomWriteToButKeepOriginal,
SupportsVolatilePrefix, SupportsUnalignedPrefix, MayThrow, ResultType("type.GetStackType()")), SupportsVolatilePrefix, SupportsUnalignedPrefix, MayThrow, ResultType("type.GetStackType()")),
new OpCode("stobj", "Indirect store (store to ref/pointer)." + Environment.NewLine new OpCode("stobj", "Indirect store (store to ref/pointer)." + Environment.NewLine
+ "Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value)", + "Evaluates to the value that was stored (when using type byte/short: evaluates to the truncated value, sign/zero extended back to I4 based on type.GetSign())",
CustomClassName("StObj"), CustomArguments("target", "value"), HasTypeOperand, MemoryAccess, CustomWriteToButKeepOriginal, CustomClassName("StObj"), CustomArguments("target", "value"), HasTypeOperand, MemoryAccess, CustomWriteToButKeepOriginal,
SupportsVolatilePrefix, SupportsUnalignedPrefix, MayThrow, ResultType("type.GetStackType()")), SupportsVolatilePrefix, SupportsUnalignedPrefix, MayThrow, ResultType("type.GetStackType()")),

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

@ -86,8 +86,16 @@ namespace ICSharpCode.Decompiler.IL
type = NullableType.GetUnderlyingType(type); type = NullableType.GetUnderlyingType(type);
} }
if (type.Kind == TypeKind.Enum) { if (type.Kind == TypeKind.Enum) {
if (binary.Operator != BinaryNumericOperator.Add && binary.Operator != BinaryNumericOperator.Sub) switch (binary.Operator) {
return false; case BinaryNumericOperator.Add:
case BinaryNumericOperator.Sub:
case BinaryNumericOperator.BitAnd:
case BinaryNumericOperator.BitOr:
case BinaryNumericOperator.BitXor:
break; // OK
default:
return false; // operator not supported on enum types
}
} }
if (binary.Sign != Sign.None) { if (binary.Sign != Sign.None) {
if (type.GetSign() != binary.Sign) if (type.GetSign() != binary.Sign)

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

@ -279,32 +279,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
context.RequestRerun(); context.RequestRerun();
return; return;
} }
TransformAssignment.HandleStObjCompoundAssign(inst, context);
if (inst.Value is BinaryNumericInstruction binary
&& binary.Left is LdObj ldobj
&& inst.Target.Match(ldobj.Target).Success
&& SemanticHelper.IsPure(ldobj.Target.Flags))
{
// ldobj.Type may just be 'int' (due to ldind.i4) when we're actually operating on a 'ref MyEnum'.
// Try to determine the real type of the object we're modifying:
IType targetType = ldobj.Target.InferType();
if (targetType.Kind == TypeKind.Pointer || targetType.Kind == TypeKind.ByReference) {
targetType = ((TypeWithElementType)targetType).ElementType;
if (targetType.Kind == TypeKind.Unknown || targetType.GetSize() != ldobj.Type.GetSize()) {
targetType = ldobj.Type;
}
} else {
targetType = ldobj.Type;
}
if (CompoundAssignmentInstruction.IsBinaryCompatibleWithType(binary, targetType)) {
context.Step("compound assignment", inst);
// stobj(target, binary.op(ldobj(target), ...))
// => compound.op(target, ...)
inst.ReplaceWith(new CompoundAssignmentInstruction(
binary, binary.Left, binary.Right,
targetType, CompoundAssignmentType.EvaluatesToNewValue));
}
}
} }
protected internal override void VisitIfInstruction(IfInstruction inst) protected internal override void VisitIfInstruction(IfInstruction inst)

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

@ -20,6 +20,7 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
namespace ICSharpCode.Decompiler.IL.Transforms namespace ICSharpCode.Decompiler.IL.Transforms
{ {
@ -124,7 +125,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// in some cases it can be a compiler-generated local // in some cases it can be a compiler-generated local
if (mainStLoc == null || (mainStLoc.Variable.Kind != VariableKind.StackSlot && mainStLoc.Variable.Kind != VariableKind.Local)) if (mainStLoc == null || (mainStLoc.Variable.Kind != VariableKind.StackSlot && mainStLoc.Variable.Kind != VariableKind.Local))
return false; return false;
BinaryNumericInstruction binary = mainStLoc.Value as BinaryNumericInstruction; ILInstruction value = mainStLoc.Value;
if (value is Conv conv && conv.Kind == ConversionKind.Truncate && conv.TargetType.IsSmallIntegerType()) {
// for compound assignments to small integers, the compiler emits a "conv" instruction
value = conv.Argument;
} else {
conv = null;
}
BinaryNumericInstruction binary = value as BinaryNumericInstruction;
ILVariable localVariable = mainStLoc.Variable; ILVariable localVariable = mainStLoc.Variable;
if (!localVariable.IsSingleDefinition) if (!localVariable.IsSingleDefinition)
return false; return false;
@ -142,13 +150,16 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false; return false;
if (next.Descendants.Where(d => d.MatchLdLoc(localVariable)).Count() != 1) if (next.Descendants.Where(d => d.MatchLdLoc(localVariable)).Count() != 1)
return false; return false;
if (!CompoundAssignmentInstruction.IsBinaryCompatibleWithType(binary, getterCall.Method.ReturnType)) IType targetType = getterCall.Method.ReturnType;
if (!CompoundAssignmentInstruction.IsBinaryCompatibleWithType(binary, targetType))
return false; return false;
if (conv != null && !(conv.TargetType == targetType.ToPrimitiveType() && conv.CheckForOverflow == binary.CheckForOverflow))
return false; // conv does not match binary operation
context.Step($"Inline compound assignment to '{getterCall.Method.AccessorOwner.Name}'", setterCall); context.Step($"Inline compound assignment to '{getterCall.Method.AccessorOwner.Name}'", setterCall);
block.Instructions.RemoveAt(i + 1); // remove setter call block.Instructions.RemoveAt(i + 1); // remove setter call
binary.ReplaceWith(new CompoundAssignmentInstruction( mainStLoc.Value = new CompoundAssignmentInstruction(
binary, getterCall, binary.Right, binary, getterCall, binary.Right,
getterCall.Method.ReturnType, CompoundAssignmentType.EvaluatesToNewValue)); targetType, CompoundAssignmentType.EvaluatesToNewValue);
return true; return true;
} }
@ -218,13 +229,22 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// ==> stloc v(compound.op.new(callvirt(callvirt get_Property(ldloc S_1)), value)) // ==> stloc v(compound.op.new(callvirt(callvirt get_Property(ldloc S_1)), value))
setterValue = storeInSetter.Value; setterValue = storeInSetter.Value;
} }
if (setterValue is Conv conv && conv.Kind == ConversionKind.Truncate && conv.TargetType.IsSmallIntegerType()) {
// for compound assignments to small integers, the compiler emits a "conv" instruction
setterValue = conv.Argument;
} else {
conv = null;
}
if (!(setterValue is BinaryNumericInstruction binary)) if (!(setterValue is BinaryNumericInstruction binary))
return false; return false;
var getterCall = binary.Left as CallInstruction; var getterCall = binary.Left as CallInstruction;
if (!MatchingGetterAndSetterCalls(getterCall, setterCall)) if (!MatchingGetterAndSetterCalls(getterCall, setterCall))
return false; return false;
if (!CompoundAssignmentInstruction.IsBinaryCompatibleWithType(binary, getterCall.Method.ReturnType)) IType targetType = getterCall.Method.ReturnType;
if (!CompoundAssignmentInstruction.IsBinaryCompatibleWithType(binary, targetType))
return false; return false;
if (conv != null && !(conv.TargetType == targetType.ToPrimitiveType() && conv.CheckForOverflow == binary.CheckForOverflow))
return false; // conv does not match binary operation
context.Step($"Compound assignment to '{getterCall.Method.AccessorOwner.Name}'", setterCall); context.Step($"Compound assignment to '{getterCall.Method.AccessorOwner.Name}'", setterCall);
ILInstruction newInst = new CompoundAssignmentInstruction( ILInstruction newInst = new CompoundAssignmentInstruction(
binary, getterCall, binary.Right, binary, getterCall, binary.Right,
@ -238,6 +258,52 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return true; return true;
} }
/// <summary>
/// stobj(target, binary.op(ldobj(target), ...))
/// => compound.op(target, ...)
/// </summary>
/// <remarks>
/// Called by ExpressionTransforms.
/// </remarks>
internal static bool HandleStObjCompoundAssign(StObj inst, ILTransformContext context)
{
ILInstruction value = inst.Value;
if (value is Conv conv && conv.Kind == ConversionKind.Truncate && conv.TargetType.IsSmallIntegerType()) {
// for compound assignments to small integers, the compiler emits a "conv" instruction
value = conv.Argument;
} else {
conv = null;
}
if (!(value is BinaryNumericInstruction binary))
return false;
if (!(binary.Left is LdObj ldobj))
return false;
if (!inst.Target.Match(ldobj.Target).Success)
return false;
if (!SemanticHelper.IsPure(ldobj.Target.Flags))
return false;
// ldobj.Type may just be 'int' (due to ldind.i4) when we're actually operating on a 'ref MyEnum'.
// Try to determine the real type of the object we're modifying:
IType targetType = ldobj.Target.InferType();
if (targetType.Kind == TypeKind.Pointer || targetType.Kind == TypeKind.ByReference) {
targetType = ((TypeWithElementType)targetType).ElementType;
if (targetType.Kind == TypeKind.Unknown || targetType.GetSize() != ldobj.Type.GetSize()) {
targetType = ldobj.Type;
}
} else {
targetType = ldobj.Type;
}
if (!CompoundAssignmentInstruction.IsBinaryCompatibleWithType(binary, targetType))
return false;
if (conv != null && !(conv.TargetType == targetType.ToPrimitiveType() && conv.CheckForOverflow == binary.CheckForOverflow))
return false; // conv does not match binary operation
context.Step("compound assignment", inst);
inst.ReplaceWith(new CompoundAssignmentInstruction(
binary, binary.Left, binary.Right,
targetType, CompoundAssignmentType.EvaluatesToNewValue));
return true;
}
/// <code> /// <code>
/// stloc s(value) /// stloc s(value)
/// stloc l(ldloc s) /// stloc l(ldloc s)
@ -280,8 +346,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// conv instructions. // conv instructions.
return false; return false;
} }
// With small integer types, test whether the value being stored // With small integer types, test whether the value might be changed by
// is being truncated: // truncation (based on type.GetSize()) followed by sign/zero extension (based on type.GetSign()).
// (it's OK to have false-positives here if we're unsure)
if (value.MatchLdcI4(out int val)) { if (value.MatchLdcI4(out int val)) {
switch (type.GetEnumUnderlyingType().GetDefinition()?.KnownTypeCode) { switch (type.GetEnumUnderlyingType().GetDefinition()?.KnownTypeCode) {
case KnownTypeCode.Boolean: case KnownTypeCode.Boolean:

Loading…
Cancel
Save