Browse Source

Fix compound assignment and post-increment.

pull/960/head
Daniel Grunwald 8 years ago
parent
commit
7847a69d69
  1. 2
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  2. 2
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  3. 48
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.il
  4. 48
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.il
  5. 38
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.opt.roslyn.il
  6. 38
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.roslyn.il
  7. 15
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.cs
  8. 69
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.il
  9. 55
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.opt.il
  10. 431
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.opt.roslyn.il
  11. 524
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.roslyn.il
  12. 8
      ICSharpCode.Decompiler/IL/Instructions/MemoryInstructions.cs
  13. 161
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs

2
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -74,7 +74,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
public void InlineAssignmentTest([ValueSource("noRoslynOptions")] CompilerOptions cscOptions)
public void InlineAssignmentTest([ValueSource("defaultOptions")] CompilerOptions cscOptions)
{
Run(cscOptions: cscOptions);
}

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

@ -236,7 +236,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -236,7 +236,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void ShortEnumTest()
{
this.shortEnumField |= ShortEnum.Two;
this.shortEnumField &= ~ShortEnum.Four;
this.shortEnumField &= ShortEnum.Four;
this.shortEnumField += 2;
this.shortEnumField -= 3;
}

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

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly oguadjyn
.assembly njho1304
{
.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
@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module oguadjyn.dll
// MVID: {7DE8C1A3-5051-43F6-ACDA-EFB9A52251C4}
.module njho1304.dll
// MVID: {06E90287-B329-43EC-805F-F8BC42EE77DE}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x019F0000
// Image base: 0x00C00000
// =============== CLASS MEMBERS DECLARATION ===================
@ -805,7 +805,7 @@ @@ -805,7 +805,7 @@
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 63 (0x3f)
// Code size 62 (0x3e)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
@ -818,25 +818,25 @@ @@ -818,25 +818,25 @@
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
IL_0017: ldc.i4.4
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

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

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly vm2ov5l1
.assembly iwgzkcmd
{
.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
@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module vm2ov5l1.dll
// MVID: {F7BCAA28-E619-40E7-921D-149FF48046FD}
.module iwgzkcmd.dll
// MVID: {80313F66-9892-4910-999C-C098CFBAAB05}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x052F0000
// Image base: 0x02540000
// =============== CLASS MEMBERS DECLARATION ===================
@ -692,7 +692,7 @@ @@ -692,7 +692,7 @@
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 62 (0x3e)
// Code size 61 (0x3d)
.maxstack 8
IL_0000: ldarg.0
IL_0001: dup
@ -704,25 +704,25 @@ @@ -704,25 +704,25 @@
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
IL_0016: ldc.i4.4
IL_0017: and
IL_0018: conv.i2
IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_001e: ldarg.0
IL_001f: dup
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: dup
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

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

@ -25,14 +25,14 @@ @@ -25,14 +25,14 @@
.ver 0:0:0:0
}
.module CompoundAssignmentTest.dll
// MVID: {9C969BC5-E3E2-4944-BB85-4B7EAAE52E4D}
// MVID: {F06B4897-D7A1-4604-8BC9-FB97832F7C40}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00480000
// Image base: 0x02D30000
// =============== CLASS MEMBERS DECLARATION ===================
@ -695,7 +695,7 @@ @@ -695,7 +695,7 @@
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 60 (0x3c)
// Code size 59 (0x3b)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.0
@ -706,24 +706,24 @@ @@ -706,24 +706,24 @@
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_0015: ldc.i4.4
IL_0016: and
IL_0017: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_001c: ldarg.0
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_001e: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0023: ldc.i4.2
IL_0024: add
IL_0025: conv.i2
IL_0026: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_002b: ldarg.0
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
IL_002d: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_0032: ldc.i4.3
IL_0033: sub
IL_0034: conv.i2
IL_0035: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/ShortEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::shortEnumField
IL_003a: ret
} // end of method CompoundAssignmentTest::ShortEnumTest
.method public hidebysig instance int32

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

@ -25,14 +25,14 @@ @@ -25,14 +25,14 @@
.ver 0:0:0:0
}
.module CompoundAssignmentTest.dll
// MVID: {AB7EC3EB-B732-497E-809B-7D4DBB442E2C}
// MVID: {C9CD236E-5AA3-4F16-ABA1-33B72FC48FEA}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x019F0000
// Image base: 0x01530000
// =============== CLASS MEMBERS DECLARATION ===================
@ -794,7 +794,7 @@ @@ -794,7 +794,7 @@
.method public hidebysig instance void
ShortEnumTest() cil managed
{
// Code size 61 (0x3d)
// Code size 60 (0x3c)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
@ -806,24 +806,24 @@ @@ -806,24 +806,24 @@
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_0016: ldc.i4.4
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: 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_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: 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
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

15
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.cs

@ -39,12 +39,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -39,12 +39,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public void SimpleInlineWithLocals()
{
int value;
Console.WriteLine(value = 5);
int index;
Console.WriteLine(this.GetFormat(), index = this.GetIndex());
Console.WriteLine(index);
InlineAssignmentTest value;
Console.WriteLine(this.GetFormat(), value = new InlineAssignmentTest());
Console.WriteLine(value);
InlineAssignmentTest value2;
Console.WriteLine(value2 = new InlineAssignmentTest());
Console.WriteLine(value2);
}
public void SimpleInlineWithFields()
@ -112,6 +112,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -112,6 +112,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
throw new NotImplementedException();
}
public string GetFormat()
{
return "{0}";
}
public int GetValue(int value)
{
return value;

69
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.il

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly dcbsz5ie
.assembly cljdpn4p
{
.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
@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module dcbsz5ie.dll
// MVID: {CFA464E9-510B-40EC-AD90-3FB26B76D1A6}
.module cljdpn4p.dll
// MVID: {4E91830C-4968-4AA2-B516-7FDA32452515}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00690000
// Image base: 0x006A0000
// =============== CLASS MEMBERS DECLARATION ===================
@ -101,28 +101,36 @@ @@ -101,28 +101,36 @@
.method public hidebysig instance void
SimpleInlineWithLocals() cil managed
{
// Code size 38 (0x26)
.maxstack 2
// Code size 60 (0x3c)
.maxstack 3
.locals init (int32 V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest V_1)
IL_0000: nop
IL_0001: ldc.i4.5
IL_0002: dup
IL_0003: stloc.0
IL_0004: call void [mscorlib]System.Console::WriteLine(int32)
IL_0009: nop
IL_000a: ldloc.0
IL_000b: call void [mscorlib]System.Console::WriteLine(int32)
IL_0010: nop
IL_0011: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0016: dup
IL_0017: stloc.1
IL_0018: call void [mscorlib]System.Console::WriteLine(object)
IL_001d: nop
IL_001e: ldloc.1
IL_001f: call void [mscorlib]System.Console::WriteLine(object)
IL_0024: nop
IL_0025: ret
IL_0001: ldarg.0
IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0007: ldarg.0
IL_0008: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_000d: dup
IL_000e: stloc.0
IL_000f: box [mscorlib]System.Int32
IL_0014: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0019: nop
IL_001a: ldloc.0
IL_001b: call void [mscorlib]System.Console::WriteLine(int32)
IL_0020: nop
IL_0021: ldarg.0
IL_0022: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0027: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_002c: dup
IL_002d: stloc.1
IL_002e: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0033: nop
IL_0034: ldloc.1
IL_0035: call void [mscorlib]System.Console::WriteLine(object)
IL_003a: nop
IL_003b: ret
} // end of method InlineAssignmentTest::SimpleInlineWithLocals
.method public hidebysig instance void
@ -394,6 +402,21 @@ @@ -394,6 +402,21 @@
IL_0006: throw
} // end of method InlineAssignmentTest::GetArray
.method public hidebysig instance string
GetFormat() cil managed
{
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: nop
IL_0001: ldstr "{0}"
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method InlineAssignmentTest::GetFormat
.method public hidebysig instance int32
GetValue(int32 'value') cil managed
{

55
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.opt.il

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly idzuatf2
.assembly jfxjxuqt
{
.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
@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module idzuatf2.dll
// MVID: {0E6B135E-0CD7-486D-88EB-95340860F028}
.module jfxjxuqt.dll
// MVID: {862986C8-F9C1-4FF3-8646-A3CA63D29744}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x02A70000
// Image base: 0x010B0000
// =============== CLASS MEMBERS DECLARATION ===================
@ -91,23 +91,31 @@ @@ -91,23 +91,31 @@
.method public hidebysig instance void
SimpleInlineWithLocals() cil managed
{
// Code size 33 (0x21)
.maxstack 2
// Code size 55 (0x37)
.maxstack 3
.locals init (int32 V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest V_1)
IL_0000: ldc.i4.5
IL_0001: dup
IL_0002: stloc.0
IL_0003: call void [mscorlib]System.Console::WriteLine(int32)
IL_0008: ldloc.0
IL_0009: call void [mscorlib]System.Console::WriteLine(int32)
IL_000e: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0013: dup
IL_0014: stloc.1
IL_0015: call void [mscorlib]System.Console::WriteLine(object)
IL_001a: ldloc.1
IL_001b: call void [mscorlib]System.Console::WriteLine(object)
IL_0020: ret
IL_0000: ldarg.0
IL_0001: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0006: ldarg.0
IL_0007: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_000c: dup
IL_000d: stloc.0
IL_000e: box [mscorlib]System.Int32
IL_0013: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0018: ldloc.0
IL_0019: call void [mscorlib]System.Console::WriteLine(int32)
IL_001e: ldarg.0
IL_001f: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0024: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0029: dup
IL_002a: stloc.1
IL_002b: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0030: ldloc.1
IL_0031: call void [mscorlib]System.Console::WriteLine(object)
IL_0036: ret
} // end of method InlineAssignmentTest::SimpleInlineWithLocals
.method public hidebysig instance void
@ -327,6 +335,15 @@ @@ -327,6 +335,15 @@
IL_0005: throw
} // end of method InlineAssignmentTest::GetArray
.method public hidebysig instance string
GetFormat() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldstr "{0}"
IL_0005: ret
} // end of method InlineAssignmentTest::GetFormat
.method public hidebysig instance int32
GetValue(int32 'value') cil managed
{

431
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.opt.roslyn.il

@ -0,0 +1,431 @@ @@ -0,0 +1,431 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly InlineAssignmentTest
{
.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
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module InlineAssignmentTest.dll
// MVID: {2D549318-D869-4294-BA40-CB6EEA5D9CE2}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x02CB0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest
extends [mscorlib]System.Object
{
.field private int32 field1
.field private static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest field2
.field private int32[] field3
.field private int16 field4
.field private int32 '<InstanceProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field private static int32 '<StaticProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname instance int32
get_InstanceProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<InstanceProperty>k__BackingField'
IL_0006: ret
} // end of method InlineAssignmentTest::get_InstanceProperty
.method public hidebysig specialname instance void
set_InstanceProperty(int32 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<InstanceProperty>k__BackingField'
IL_0007: ret
} // end of method InlineAssignmentTest::set_InstanceProperty
.method public hidebysig specialname static
int32 get_StaticProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<StaticProperty>k__BackingField'
IL_0005: ret
} // end of method InlineAssignmentTest::get_StaticProperty
.method public hidebysig specialname static
void set_StaticProperty(int32 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<StaticProperty>k__BackingField'
IL_0006: ret
} // end of method InlineAssignmentTest::set_StaticProperty
.method public hidebysig instance void
SimpleInlineWithLocals() cil managed
{
// Code size 55 (0x37)
.maxstack 3
.locals init (int32 V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest V_1)
IL_0000: ldarg.0
IL_0001: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0006: ldarg.0
IL_0007: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_000c: dup
IL_000d: stloc.0
IL_000e: box [mscorlib]System.Int32
IL_0013: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0018: ldloc.0
IL_0019: call void [mscorlib]System.Console::WriteLine(int32)
IL_001e: ldarg.0
IL_001f: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0024: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0029: dup
IL_002a: stloc.1
IL_002b: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0030: ldloc.1
IL_0031: call void [mscorlib]System.Console::WriteLine(object)
IL_0036: ret
} // end of method InlineAssignmentTest::SimpleInlineWithLocals
.method public hidebysig instance void
SimpleInlineWithFields() cil managed
{
// Code size 32 (0x20)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: ldc.i4.5
IL_0002: dup
IL_0003: stloc.0
IL_0004: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_0009: ldloc.0
IL_000a: call void [mscorlib]System.Console::WriteLine(int32)
IL_000f: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0014: dup
IL_0015: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field2
IL_001a: call void [mscorlib]System.Console::WriteLine(object)
IL_001f: ret
} // end of method InlineAssignmentTest::SimpleInlineWithFields
.method public hidebysig instance void
SimpleInlineWithFields2() cil managed
{
// Code size 148 (0x94)
.maxstack 4
.locals init (int32 V_0,
int16 V_1)
IL_0000: ldarg.0
IL_0001: ldc.i4.5
IL_0002: dup
IL_0003: stloc.0
IL_0004: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_0009: ldloc.0
IL_000a: call void [mscorlib]System.Console::WriteLine(int32)
IL_000f: ldarg.0
IL_0010: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_0015: call void [mscorlib]System.Console::WriteLine(int32)
IL_001a: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_001f: dup
IL_0020: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field2
IL_0025: call void [mscorlib]System.Console::WriteLine(object)
IL_002a: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field2
IL_002f: call void [mscorlib]System.Console::WriteLine(object)
IL_0034: ldarg.0
IL_0035: ldarg.0
IL_0036: ldc.i4.6
IL_0037: dup
IL_0038: stloc.1
IL_0039: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_003e: ldloc.1
IL_003f: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_0044: pop
IL_0045: ldarg.0
IL_0046: ldarg.0
IL_0047: ldc.i4 0xffffd8f0
IL_004c: dup
IL_004d: stloc.1
IL_004e: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_0053: ldloc.1
IL_0054: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_0059: pop
IL_005a: ldarg.0
IL_005b: ldarg.0
IL_005c: ldarg.0
IL_005d: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_0062: conv.i2
IL_0063: dup
IL_0064: stloc.1
IL_0065: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_006a: ldloc.1
IL_006b: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_0070: pop
IL_0071: ldarg.0
IL_0072: ldarg.0
IL_0073: ldarg.0
IL_0074: ldc.i4.0
IL_0075: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_007a: dup
IL_007b: stloc.1
IL_007c: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_0081: ldloc.1
IL_0082: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_0087: pop
IL_0088: ldarg.0
IL_0089: ldfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_008e: call void [mscorlib]System.Console::WriteLine(int32)
IL_0093: ret
} // end of method InlineAssignmentTest::SimpleInlineWithFields2
.method public hidebysig instance int16
UseShort(int16 s) cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.1
IL_0001: call void [mscorlib]System.Console::WriteLine(int32)
IL_0006: ldarg.1
IL_0007: ret
} // end of method InlineAssignmentTest::UseShort
.method public hidebysig instance void
ReadLoop1(class [mscorlib]System.IO.TextReader r) cil managed
{
// Code size 19 (0x13)
.maxstack 2
.locals init (string V_0)
IL_0000: br.s IL_0008
IL_0002: ldloc.0
IL_0003: call void [mscorlib]System.Console::WriteLine(string)
IL_0008: ldarg.1
IL_0009: callvirt instance string [mscorlib]System.IO.TextReader::ReadLine()
IL_000e: dup
IL_000f: stloc.0
IL_0010: brtrue.s IL_0002
IL_0012: ret
} // end of method InlineAssignmentTest::ReadLoop1
.method public hidebysig instance void
AccessArray(int32[] a) cil managed
{
// Code size 23 (0x17)
.maxstack 4
.locals init (int32 V_0,
int32 V_1)
IL_0000: ldarg.1
IL_0001: ldc.i4.0
IL_0002: ldelem.i4
IL_0003: dup
IL_0004: stloc.0
IL_0005: call void [mscorlib]System.Console::WriteLine(int32)
IL_000a: ldarg.1
IL_000b: ldloc.0
IL_000c: ldloc.0
IL_000d: dup
IL_000e: stloc.1
IL_000f: stelem.i4
IL_0010: ldloc.1
IL_0011: call void [mscorlib]System.Console::WriteLine(int32)
IL_0016: ret
} // end of method InlineAssignmentTest::AccessArray
.method public hidebysig instance int32
Return(int32& a) cil managed
{
// Code size 7 (0x7)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.1
IL_0001: ldc.i4.3
IL_0002: dup
IL_0003: stloc.0
IL_0004: stind.i4
IL_0005: ldloc.0
IL_0006: ret
} // end of method InlineAssignmentTest::Return
.method public hidebysig instance int32
Array(int32[] a,
int32 i) cil managed
{
// Code size 8 (0x8)
.maxstack 4
.locals init (int32 V_0)
IL_0000: ldarg.1
IL_0001: ldarg.2
IL_0002: ldarg.2
IL_0003: dup
IL_0004: stloc.0
IL_0005: stelem.i4
IL_0006: ldloc.0
IL_0007: ret
} // end of method InlineAssignmentTest::Array
.method public hidebysig instance int32
Array2(int32 i) cil managed
{
// Code size 13 (0xd)
.maxstack 4
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: ldfld int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field3
IL_0006: ldarg.1
IL_0007: ldc.i4.1
IL_0008: dup
IL_0009: stloc.0
IL_000a: stelem.i4
IL_000b: ldloc.0
IL_000c: ret
} // end of method InlineAssignmentTest::Array2
.method public hidebysig instance int32
GetIndex() cil managed
{
// Code size 14 (0xe)
.maxstack 8
IL_0000: newobj instance void [mscorlib]System.Random::.ctor()
IL_0005: ldc.i4.0
IL_0006: ldc.i4.s 100
IL_0008: callvirt instance int32 [mscorlib]System.Random::Next(int32,
int32)
IL_000d: ret
} // end of method InlineAssignmentTest::GetIndex
.method public hidebysig instance int32[]
GetArray() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
IL_0005: throw
} // end of method InlineAssignmentTest::GetArray
.method public hidebysig instance string
GetFormat() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldstr "{0}"
IL_0005: ret
} // end of method InlineAssignmentTest::GetFormat
.method public hidebysig instance int32
GetValue(int32 'value') cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: ldarg.1
IL_0001: ret
} // end of method InlineAssignmentTest::GetValue
.method public hidebysig instance int32
ArrayUsageWithMethods() cil managed
{
// Code size 29 (0x1d)
.maxstack 4
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: call instance int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetArray()
IL_0006: ldarg.0
IL_0007: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_000c: ldarg.0
IL_000d: ldarg.0
IL_000e: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_0013: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetValue(int32)
IL_0018: dup
IL_0019: stloc.0
IL_001a: stelem.i4
IL_001b: ldloc.0
IL_001c: ret
} // end of method InlineAssignmentTest::ArrayUsageWithMethods
.method public hidebysig instance int32
StaticPropertyTest() cil managed
{
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_0006: dup
IL_0007: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_StaticProperty(int32)
IL_000c: ret
} // end of method InlineAssignmentTest::StaticPropertyTest
.method public hidebysig instance int32
InstancePropertyTest() cil managed
{
// Code size 16 (0x10)
.maxstack 3
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: ldarg.0
IL_0002: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_0007: dup
IL_0008: stloc.0
IL_0009: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_InstanceProperty(int32)
IL_000e: ldloc.0
IL_000f: ret
} // end of method InlineAssignmentTest::InstancePropertyTest
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method InlineAssignmentTest::.ctor
.property instance int32 InstanceProperty()
{
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::get_InstanceProperty()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_InstanceProperty(int32)
} // end of property InlineAssignmentTest::InstanceProperty
.property int32 StaticProperty()
{
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::get_StaticProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_StaticProperty(int32)
} // end of property InlineAssignmentTest::StaticProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

524
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InlineAssignmentTest.roslyn.il

@ -0,0 +1,524 @@ @@ -0,0 +1,524 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly InlineAssignmentTest
{
.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
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module InlineAssignmentTest.dll
// MVID: {370735A1-C3D5-4BD3-8F9B-CC3F81FB734E}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00BE0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest
extends [mscorlib]System.Object
{
.field private int32 field1
.field private static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest field2
.field private int32[] field3
.field private int16 field4
.field private int32 '<InstanceProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.field private static int32 '<StaticProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
.method public hidebysig specialname instance int32
get_InstanceProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<InstanceProperty>k__BackingField'
IL_0006: ret
} // end of method InlineAssignmentTest::get_InstanceProperty
.method public hidebysig specialname instance void
set_InstanceProperty(int32 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<InstanceProperty>k__BackingField'
IL_0007: ret
} // end of method InlineAssignmentTest::set_InstanceProperty
.method public hidebysig specialname static
int32 get_StaticProperty() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<StaticProperty>k__BackingField'
IL_0005: ret
} // end of method InlineAssignmentTest::get_StaticProperty
.method public hidebysig specialname static
void set_StaticProperty(int32 'value') cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: stsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::'<StaticProperty>k__BackingField'
IL_0006: ret
} // end of method InlineAssignmentTest::set_StaticProperty
.method public hidebysig instance void
SimpleInlineWithLocals() cil managed
{
// Code size 60 (0x3c)
.maxstack 3
.locals init (int32 V_0,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0007: ldarg.0
IL_0008: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_000d: dup
IL_000e: stloc.0
IL_000f: box [mscorlib]System.Int32
IL_0014: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0019: nop
IL_001a: ldloc.0
IL_001b: call void [mscorlib]System.Console::WriteLine(int32)
IL_0020: nop
IL_0021: ldarg.0
IL_0022: call instance string ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetFormat()
IL_0027: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_002c: dup
IL_002d: stloc.1
IL_002e: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0033: nop
IL_0034: ldloc.1
IL_0035: call void [mscorlib]System.Console::WriteLine(object)
IL_003a: nop
IL_003b: ret
} // end of method InlineAssignmentTest::SimpleInlineWithLocals
.method public hidebysig instance void
SimpleInlineWithFields() cil managed
{
// Code size 35 (0x23)
.maxstack 3
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.5
IL_0003: dup
IL_0004: stloc.0
IL_0005: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_000a: ldloc.0
IL_000b: call void [mscorlib]System.Console::WriteLine(int32)
IL_0010: nop
IL_0011: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0016: dup
IL_0017: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field2
IL_001c: call void [mscorlib]System.Console::WriteLine(object)
IL_0021: nop
IL_0022: ret
} // end of method InlineAssignmentTest::SimpleInlineWithFields
.method public hidebysig instance void
SimpleInlineWithFields2() cil managed
{
// Code size 154 (0x9a)
.maxstack 4
.locals init (int32 V_0,
int16 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.5
IL_0003: dup
IL_0004: stloc.0
IL_0005: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_000a: ldloc.0
IL_000b: call void [mscorlib]System.Console::WriteLine(int32)
IL_0010: nop
IL_0011: ldarg.0
IL_0012: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_0017: call void [mscorlib]System.Console::WriteLine(int32)
IL_001c: nop
IL_001d: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::.ctor()
IL_0022: dup
IL_0023: stsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field2
IL_0028: call void [mscorlib]System.Console::WriteLine(object)
IL_002d: nop
IL_002e: ldsfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field2
IL_0033: call void [mscorlib]System.Console::WriteLine(object)
IL_0038: nop
IL_0039: ldarg.0
IL_003a: ldarg.0
IL_003b: ldc.i4.6
IL_003c: dup
IL_003d: stloc.1
IL_003e: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_0043: ldloc.1
IL_0044: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_0049: pop
IL_004a: ldarg.0
IL_004b: ldarg.0
IL_004c: ldc.i4 0xffffd8f0
IL_0051: dup
IL_0052: stloc.1
IL_0053: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_0058: ldloc.1
IL_0059: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_005e: pop
IL_005f: ldarg.0
IL_0060: ldarg.0
IL_0061: ldarg.0
IL_0062: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field1
IL_0067: conv.i2
IL_0068: dup
IL_0069: stloc.1
IL_006a: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_006f: ldloc.1
IL_0070: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_0075: pop
IL_0076: ldarg.0
IL_0077: ldarg.0
IL_0078: ldarg.0
IL_0079: ldc.i4.0
IL_007a: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_007f: dup
IL_0080: stloc.1
IL_0081: stfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_0086: ldloc.1
IL_0087: call instance int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::UseShort(int16)
IL_008c: pop
IL_008d: ldarg.0
IL_008e: ldfld int16 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field4
IL_0093: call void [mscorlib]System.Console::WriteLine(int32)
IL_0098: nop
IL_0099: ret
} // end of method InlineAssignmentTest::SimpleInlineWithFields2
.method public hidebysig instance int16
UseShort(int16 s) cil managed
{
// Code size 14 (0xe)
.maxstack 1
.locals init (int16 V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: call void [mscorlib]System.Console::WriteLine(int32)
IL_0007: nop
IL_0008: ldarg.1
IL_0009: stloc.0
IL_000a: br.s IL_000c
IL_000c: ldloc.0
IL_000d: ret
} // end of method InlineAssignmentTest::UseShort
.method public hidebysig instance void
ReadLoop1(class [mscorlib]System.IO.TextReader r) cil managed
{
// Code size 28 (0x1c)
.maxstack 2
.locals init (string V_0,
bool V_1)
IL_0000: nop
IL_0001: br.s IL_000c
IL_0003: nop
IL_0004: ldloc.0
IL_0005: call void [mscorlib]System.Console::WriteLine(string)
IL_000a: nop
IL_000b: nop
IL_000c: ldarg.1
IL_000d: callvirt instance string [mscorlib]System.IO.TextReader::ReadLine()
IL_0012: dup
IL_0013: stloc.0
IL_0014: ldnull
IL_0015: cgt.un
IL_0017: stloc.1
IL_0018: ldloc.1
IL_0019: brtrue.s IL_0003
IL_001b: ret
} // end of method InlineAssignmentTest::ReadLoop1
.method public hidebysig instance void
AccessArray(int32[] a) cil managed
{
// Code size 26 (0x1a)
.maxstack 4
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.0
IL_0003: ldelem.i4
IL_0004: dup
IL_0005: stloc.0
IL_0006: call void [mscorlib]System.Console::WriteLine(int32)
IL_000b: nop
IL_000c: ldarg.1
IL_000d: ldloc.0
IL_000e: ldloc.0
IL_000f: dup
IL_0010: stloc.1
IL_0011: stelem.i4
IL_0012: ldloc.1
IL_0013: call void [mscorlib]System.Console::WriteLine(int32)
IL_0018: nop
IL_0019: ret
} // end of method InlineAssignmentTest::AccessArray
.method public hidebysig instance int32
Return(int32& a) cil managed
{
// Code size 12 (0xc)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.3
IL_0003: dup
IL_0004: stloc.0
IL_0005: stind.i4
IL_0006: ldloc.0
IL_0007: stloc.1
IL_0008: br.s IL_000a
IL_000a: ldloc.1
IL_000b: ret
} // end of method InlineAssignmentTest::Return
.method public hidebysig instance int32
Array(int32[] a,
int32 i) cil managed
{
// Code size 13 (0xd)
.maxstack 4
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldarg.2
IL_0004: dup
IL_0005: stloc.0
IL_0006: stelem.i4
IL_0007: ldloc.0
IL_0008: stloc.1
IL_0009: br.s IL_000b
IL_000b: ldloc.1
IL_000c: ret
} // end of method InlineAssignmentTest::Array
.method public hidebysig instance int32
Array2(int32 i) cil managed
{
// Code size 18 (0x12)
.maxstack 4
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldfld int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::field3
IL_0007: ldarg.1
IL_0008: ldc.i4.1
IL_0009: dup
IL_000a: stloc.0
IL_000b: stelem.i4
IL_000c: ldloc.0
IL_000d: stloc.1
IL_000e: br.s IL_0010
IL_0010: ldloc.1
IL_0011: ret
} // end of method InlineAssignmentTest::Array2
.method public hidebysig instance int32
GetIndex() cil managed
{
// Code size 19 (0x13)
.maxstack 3
.locals init (int32 V_0)
IL_0000: nop
IL_0001: newobj instance void [mscorlib]System.Random::.ctor()
IL_0006: ldc.i4.0
IL_0007: ldc.i4.s 100
IL_0009: callvirt instance int32 [mscorlib]System.Random::Next(int32,
int32)
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method InlineAssignmentTest::GetIndex
.method public hidebysig instance int32[]
GetArray() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: nop
IL_0001: newobj instance void [mscorlib]System.NotImplementedException::.ctor()
IL_0006: throw
} // end of method InlineAssignmentTest::GetArray
.method public hidebysig instance string
GetFormat() cil managed
{
// Code size 11 (0xb)
.maxstack 1
.locals init (string V_0)
IL_0000: nop
IL_0001: ldstr "{0}"
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method InlineAssignmentTest::GetFormat
.method public hidebysig instance int32
GetValue(int32 'value') cil managed
{
// Code size 7 (0x7)
.maxstack 1
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method InlineAssignmentTest::GetValue
.method public hidebysig instance int32
ArrayUsageWithMethods() cil managed
{
// Code size 34 (0x22)
.maxstack 4
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance int32[] ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetArray()
IL_0007: ldarg.0
IL_0008: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_000d: ldarg.0
IL_000e: ldarg.0
IL_000f: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_0014: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetValue(int32)
IL_0019: dup
IL_001a: stloc.0
IL_001b: stelem.i4
IL_001c: ldloc.0
IL_001d: stloc.1
IL_001e: br.s IL_0020
IL_0020: ldloc.1
IL_0021: ret
} // end of method InlineAssignmentTest::ArrayUsageWithMethods
.method public hidebysig instance int32
StaticPropertyTest() cil managed
{
// Code size 19 (0x13)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_0007: dup
IL_0008: call void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_StaticProperty(int32)
IL_000d: nop
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method InlineAssignmentTest::StaticPropertyTest
.method public hidebysig instance int32
InstancePropertyTest() cil managed
{
// Code size 22 (0x16)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldarg.0
IL_0003: call instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::GetIndex()
IL_0008: dup
IL_0009: stloc.0
IL_000a: call instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_InstanceProperty(int32)
IL_000f: nop
IL_0010: ldloc.0
IL_0011: stloc.1
IL_0012: br.s IL_0014
IL_0014: ldloc.1
IL_0015: ret
} // end of method InlineAssignmentTest::InstancePropertyTest
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method InlineAssignmentTest::.ctor
.property instance int32 InstanceProperty()
{
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::get_InstanceProperty()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_InstanceProperty(int32)
} // end of property InlineAssignmentTest::InstanceProperty
.property int32 StaticProperty()
{
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::get_StaticProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest::set_StaticProperty(int32)
} // end of property InlineAssignmentTest::StaticProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.InlineAssignmentTest
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

8
ICSharpCode.Decompiler/IL/Instructions/MemoryInstructions.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.IL @@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.IL
if (this.MatchLdFld(out var target, out var field)) {
ILRange.WriteTo(output, options);
output.Write("ldfld ");
Disassembler.DisassemblerHelpers.WriteOperand(output, field);
field.WriteTo(output);
output.Write('(');
target.WriteTo(output, options);
output.Write(')');
@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.IL @@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.IL
} else if (this.MatchLdsFld(out field)) {
ILRange.WriteTo(output, options);
output.Write("ldsfld ");
Disassembler.DisassemblerHelpers.WriteOperand(output, field);
field.WriteTo(output);
return;
}
}
@ -67,7 +67,7 @@ namespace ICSharpCode.Decompiler.IL @@ -67,7 +67,7 @@ namespace ICSharpCode.Decompiler.IL
if (this.MatchStFld(out var target, out var field, out var value)) {
ILRange.WriteTo(output, options);
output.Write("stfld ");
Disassembler.DisassemblerHelpers.WriteOperand(output, field);
field.WriteTo(output);
output.Write('(');
target.WriteTo(output, options);
output.Write(", ");
@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler.IL @@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler.IL
} else if (this.MatchStsFld(out field, out value)) {
ILRange.WriteTo(output, options);
output.Write("stsfld ");
Disassembler.DisassemblerHelpers.WriteOperand(output, field);
field.WriteTo(output);
output.Write('(');
value.WriteTo(output, options);
output.Write(')');

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

@ -35,28 +35,19 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -35,28 +35,19 @@ namespace ICSharpCode.Decompiler.IL.Transforms
void IStatementTransform.Run(Block block, int pos, StatementTransformContext context)
{
this.context = context;
/*if (TransformPostIncDecOperatorOnAddress(block, i) || TransformPostIncDecOnStaticField(block, i) || TransformCSharp4PostIncDecOperatorOnAddress(block, i)) {
block.Instructions.RemoveAt(i);
continue;
}
if (TransformPostIncDecOperator(block, i)) {
block.Instructions.RemoveAt(i);
continue;
}*/
if (TransformInlineAssignmentStObjOrCall(block, pos) || TransformInlineAssignmentLocal(block, pos)) {
// both inline assignments create a top-level stloc which might affect inlining
context.RequestRerun();
return;
}
/*
TransformInlineCompoundAssignmentCall(block, pos);
TransformRoslynCompoundAssignmentCall(block, pos);
// TODO: post-increment on local
// post-increment on address (e.g. field or array element)
TransformPostIncDecOperatorOnAddress(block, pos);
TransformRoslynPostIncDecOperatorOnAddress(block, pos);
// TODO: post-increment on call
*/
if (TransformPostIncDecOperatorWithInlineStore(block, pos)
|| TransformPostIncDecOperator(block, pos)
|| TransformPostIncDecOperatorLocal(block, pos))
{
// again, new top-level stloc might need inlining:
context.RequestRerun();
return;
}
}
/// <code>
@ -126,6 +117,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -126,6 +117,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
block.Instructions.Remove(stobj);
stobj.Value = inst.Value;
inst.ReplaceWith(new StLoc(local, stobj));
// note: our caller will trigger a re-run, which will call HandleStObjCompoundAssign if applicable
return true;
} else if (block.Instructions[nextPos] is CallInstruction call) {
// call must be a setter call:
@ -151,10 +143,19 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -151,10 +143,19 @@ namespace ICSharpCode.Decompiler.IL.Transforms
block.Instructions.Remove(call);
var newVar = context.Function.RegisterVariable(VariableKind.StackSlot, call.Method.Parameters.Last().Type);
call.Arguments[call.Arguments.Count - 1] = new StLoc(newVar, inst.Value);
inst.ReplaceWith(new StLoc(local, new Block(BlockType.CallInlineAssign) {
var inlineBlock = new Block(BlockType.CallInlineAssign) {
Instructions = { call },
FinalInstruction = new LdLoc(newVar)
}));
};
inst.ReplaceWith(new StLoc(local, inlineBlock));
// because the ExpressionTransforms don't look into inline blocks, manually trigger HandleCallCompoundAssign
if (HandleCallCompoundAssign(call, context)) {
// if we did construct a compound assignment, it should have made our inline block redundant:
if (inlineBlock.Instructions.Single().MatchStLoc(newVar, out var compoundAssign)) {
Debug.Assert(newVar.IsSingleDefinition && newVar.LoadCount == 1);
inlineBlock.ReplaceWith(compoundAssign);
}
}
return true;
} else {
return false;
@ -439,10 +440,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -439,10 +440,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// final: ldloc s2
/// })
/// </code>
bool TransformPostIncDecOperator(Block block, int i)
bool TransformPostIncDecOperatorLocal(Block block, int pos)
{
var inst = block.Instructions[i] as StLoc;
var nextInst = block.Instructions.ElementAtOrDefault(i + 1) as StLoc;
var inst = block.Instructions[pos] as StLoc;
var nextInst = block.Instructions.ElementAtOrDefault(pos + 1) as StLoc;
if (inst == null || nextInst == null || !inst.Value.MatchLdLoc(out var l) || !ILVariableEqualityComparer.Instance.Equals(l, nextInst.Variable))
return false;
var binary = nextInst.Value as BinaryNumericInstruction;
@ -452,27 +453,86 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -452,27 +453,86 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if ((binary.Operator != BinaryNumericOperator.Add && binary.Operator != BinaryNumericOperator.Sub) || !binary.Left.MatchLdLoc(inst.Variable) || !binary.Right.MatchLdcI4(1))
return false;
context.Step($"TransformPostIncDecOperator", inst);
context.Step($"TransformPostIncDecOperatorLocal", inst);
var tempStore = context.Function.RegisterVariable(VariableKind.StackSlot, inst.Variable.Type);
var assignment = new Block(BlockType.PostfixOperator);
assignment.Instructions.Add(new StLoc(tempStore, new LdLoc(nextInst.Variable)));
assignment.Instructions.Add(new StLoc(nextInst.Variable, new BinaryNumericInstruction(binary.Operator, new LdLoc(tempStore), new LdcI4(1), binary.CheckForOverflow, binary.Sign)));
assignment.FinalInstruction = new LdLoc(tempStore);
nextInst.ReplaceWith(new StLoc(inst.Variable, assignment));
inst.Value = assignment;
block.Instructions.RemoveAt(pos + 1); // remove nextInst
return true;
}
/// <summary>
/// Gets whether 'inst' is a possible store for use as a compound store.
/// </summary>
bool IsCompoundStore(ILInstruction inst, out IType storeType, out ILInstruction value)
{
value = null;
storeType = null;
if (inst is StObj stobj) {
storeType = stobj.Type;
value = stobj.Value;
return SemanticHelper.IsPure(stobj.Target.Flags);
} else if (inst is CallInstruction call && (call.OpCode == OpCode.Call || call.OpCode == OpCode.CallVirt)) {
if (call.Method.Parameters.Count == 0) {
return false;
}
foreach (var arg in call.Arguments.SkipLast(1)) {
if (!SemanticHelper.IsPure(arg.Flags)) {
return false;
}
}
storeType = call.Method.Parameters.Last().Type;
value = call.Arguments.Last();
return call.Method.Equals((call.Method.AccessorOwner as IProperty)?.Setter);
} else {
return false;
}
}
bool IsMatchingCompoundLoad(ILInstruction load, ILInstruction store, ILVariable forbiddenVariable)
{
if (load is LdObj ldobj && store is StObj stobj) {
Debug.Assert(SemanticHelper.IsPure(stobj.Target.Flags));
if (!SemanticHelper.IsPure(ldobj.Target.Flags))
return false;
if (forbiddenVariable.IsUsedWithin(ldobj.Target))
return false;
return ldobj.Target.Match(stobj.Target).Success;
} else if (MatchingGetterAndSetterCalls(load as CallInstruction, store as CallInstruction)) {
if (forbiddenVariable.IsUsedWithin(load))
return false;
return true;
} else {
return false;
}
}
/// <code>
/// stobj(target, binary.add(stloc l(ldobj(target)), ldc.i4 1))
/// where target is pure and does not use 'l'
/// -->
/// stloc l(compound.op.old(ldobj(target), ldc.i4 1))
///
/// -or-
///
/// call set_Prop(args..., binary.add(stloc l(call get_Prop(args...)), ldc.i4 1))
/// where target is pure and does not use 'l'
/// -->
/// stloc l(compound.op.old(call get_Prop(target), ldc.i4 1))
/// </code>
bool TransformPostIncDecOperatorOnAddress(Block block, int i)
/// <remarks>
/// Even though this transform operates only on a single expression, it's not an expression transform
/// as the result value of the expression changes (this is OK only for statements in a block).
/// </remarks>
bool TransformPostIncDecOperatorWithInlineStore(Block block, int pos)
{
if (!(block.Instructions[i] is StObj stobj))
var store = block.Instructions[pos];
if (!IsCompoundStore(store, out var targetType, out var value))
return false;
var binary = UnwrapSmallIntegerConv(stobj.Value, out var conv) as BinaryNumericInstruction;
var binary = UnwrapSmallIntegerConv(value, out var conv) as BinaryNumericInstruction;
if (binary == null || !binary.Right.MatchLdcI4(1))
return false;
if (!(binary.Operator == BinaryNumericOperator.Add || binary.Operator == BinaryNumericOperator.Sub))
@ -481,20 +541,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -481,20 +541,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (!(stloc.Variable.Kind == VariableKind.Local || stloc.Variable.Kind == VariableKind.StackSlot))
return false;
if (!(stloc.Value is LdObj ldobj))
return false;
if (!SemanticHelper.IsPure(ldobj.Target.Flags))
return false;
if (!ldobj.Target.Match(stobj.Target).Success)
if (!IsMatchingCompoundLoad(stloc.Value, store, stloc.Variable))
return false;
if (stloc.Variable.IsUsedWithin(ldobj.Target))
return false;
IType targetType = ldobj.Type;
if (!ValidateCompoundAssign(binary, conv, targetType))
return false;
context.Step("TransformPostIncDecOperatorOnAddress", stobj);
block.Instructions[i] = new StLoc(stloc.Variable, new CompoundAssignmentInstruction(
binary, ldobj, binary.Right, targetType, CompoundAssignmentType.EvaluatesToOldValue));
context.Step("TransformPostIncDecOperatorWithInlineStore", store);
block.Instructions[pos] = new StLoc(stloc.Variable, new CompoundAssignmentInstruction(
binary, stloc.Value, binary.Right, targetType, CompoundAssignmentType.EvaluatesToOldValue));
return true;
}
@ -505,31 +558,33 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -505,31 +558,33 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// -->
/// stloc l(compound.op.old(ldobj(target), ldc.i4 1))
/// </code>
bool TransformRoslynPostIncDecOperatorOnAddress(Block block, int i)
/// <remarks>
/// This pattern occurs with legacy csc for static fields, and with Roslyn for most post-increments.
/// </remarks>
bool TransformPostIncDecOperator(Block block, int i)
{
var inst = block.Instructions[i] as StLoc;
var stobj = block.Instructions.ElementAtOrDefault(i + 1) as StObj;
if (inst == null || stobj == null)
var store = block.Instructions.ElementAtOrDefault(i + 1);
if (inst == null || store == null)
return false;
if (!(inst.Value is LdObj ldobj))
if (!IsCompoundStore(store, out var targetType, out var value))
return false;
if (!SemanticHelper.IsPure(ldobj.Target.Flags))
return false;
if (!ldobj.Target.Match(stobj.Target).Success)
return false;
if (inst.Variable.IsUsedWithin(ldobj.Target))
if (!IsMatchingCompoundLoad(inst.Value, store, inst.Variable))
return false;
var binary = UnwrapSmallIntegerConv(stobj.Value, out var conv) as BinaryNumericInstruction;
var binary = UnwrapSmallIntegerConv(value, out var conv) as BinaryNumericInstruction;
if (binary == null || !binary.Left.MatchLdLoc(inst.Variable) || !binary.Right.MatchLdcI4(1))
return false;
if (!(binary.Operator == BinaryNumericOperator.Add || binary.Operator == BinaryNumericOperator.Sub))
return false;
var targetType = ldobj.Type;
if (!ValidateCompoundAssign(binary, conv, targetType))
return false;
context.Step("TransformRoslynPostIncDecOperatorOnAddress", inst);
context.Step("TransformPostIncDecOperator", inst);
inst.Value = new CompoundAssignmentInstruction(binary, inst.Value, binary.Right, targetType, CompoundAssignmentType.EvaluatesToOldValue);
block.Instructions.RemoveAt(i + 1);
if (inst.Variable.IsSingleDefinition && inst.Variable.LoadCount == 0) {
// dead store -> it was a statement-level post-increment
inst.ReplaceWith(inst.Value);
}
return true;
}
@ -590,10 +645,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -590,10 +645,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// -->
/// stloc s(compound.op.old(ldobj(ldsflda), ldc.i4 1))
/// </code>
bool TransformPostIncDecOnStaticField(Block block, int i)
bool TransformPostIncDecOnStaticField(Block block, int pos)
{
var inst = block.Instructions[i] as StLoc;
var stobj = block.Instructions.ElementAtOrDefault(i + 1) as StObj;
var inst = block.Instructions[pos] as StLoc;
var stobj = block.Instructions.ElementAtOrDefault(pos + 1) as StObj;
if (inst == null || stobj == null)
return false;
ILInstruction target;

Loading…
Cancel
Save