Browse Source

Fix/Add more pretty tests for compound assignment

pull/728/merge
Siegfried Pammer 9 years ago
parent
commit
d1026c4646
  1. 102
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs
  2. 115
      ICSharpCode.Decompiler/Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  3. 455
      ICSharpCode.Decompiler/Tests/TestCases/Pretty/CompoundAssignmentTest.il

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

@ -48,7 +48,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -48,7 +48,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
block.Instructions.RemoveAt(i);
continue;
}
TransformInlineAssignmentStObj(block, i);
if (TransformInlineAssignmentStObj(block, i))
continue;
if (TransformInlineAssignmentCall(block, i))
continue;
}
}
}
@ -67,36 +70,93 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -67,36 +70,93 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// -->
/// stloc s(stobj (..., value))
/// </code>
static void TransformInlineAssignmentStObj(Block block, int i)
static bool TransformInlineAssignmentStObj(Block block, int i)
{
var inst = block.Instructions[i] as StLoc;
if (inst == null || inst.Variable.Kind != VariableKind.StackSlot)
return;
// in some cases it can be a compiler-generated local
if (inst == null || (inst.Variable.Kind != VariableKind.StackSlot && inst.Variable.Kind != VariableKind.Local))
return false;
var nextInst = block.Instructions.ElementAtOrDefault(i + 1);
ILInstruction value;
ILInstruction replacement;
StObj fieldStore;
ILVariable local;
if (nextInst is StLoc) { // instance fields
var localStore = (StLoc)nextInst;
fieldStore = block.Instructions.ElementAtOrDefault(i + 2) as StObj;
if (fieldStore == null) { // otherwise it must local
if (localStore.Variable.Kind == VariableKind.StackSlot || !localStore.Value.MatchLdLoc(inst.Variable))
return false;
var memberStore = block.Instructions.ElementAtOrDefault(i + 2);
if (memberStore is StObj) {
fieldStore = memberStore as StObj;
if (!fieldStore.Value.MatchLdLoc(inst.Variable))
return false;
replacement = new StObj(fieldStore.Target, inst.Value, fieldStore.Type);
} else { // otherwise it must be local
TransformInlineAssignmentLocal(block, i);
return;
return false;
}
if (localStore.Variable.Kind == VariableKind.StackSlot || !localStore.Value.MatchLdLoc(inst.Variable) || !fieldStore.Value.MatchLdLoc(inst.Variable))
return;
value = inst.Value;
local = localStore.Variable;
block.Instructions.RemoveAt(i + 1);
} else if (nextInst is StObj) { // static fields
fieldStore = (StObj)nextInst;
if (!fieldStore.Value.MatchLdLoc(inst.Variable))
return;
value = inst.Value;
return false;
local = inst.Variable;
} else return;
replacement = new StObj(fieldStore.Target, inst.Value, fieldStore.Type);
} else return false;
block.Instructions.RemoveAt(i + 1);
inst.ReplaceWith(new StLoc(local, replacement));
return true;
}
/// <code>
/// stloc s(binary(callvirt(getter), value))
/// callvirt (setter, ldloc s)
/// ... usage of s ...
/// -->
/// ... compound.op.new(callvirt(getter), value) ...
/// </code>
/// -or-
/// <code>
/// stloc s(stloc v(binary(callvirt(getter), value)))
/// callvirt (setter, ldloc s)
/// ... usage of v ...
/// -->
/// ... compound.op.new(callvirt(getter), value) ...
/// </code>
static bool TransformInlineAssignmentCall(Block block, int i)
{
var inst = block.Instructions[i] as StLoc;
// in some cases it can be a compiler-generated local
if (inst == null || (inst.Variable.Kind != VariableKind.StackSlot && inst.Variable.Kind != VariableKind.Local))
return false;
BinaryNumericInstruction binary;
ILVariable localVariable;
if (inst.Value is StLoc) {
var tmp = (StLoc)inst.Value;
binary = tmp.Value as BinaryNumericInstruction;
localVariable = tmp.Variable;
} else {
binary = inst.Value as BinaryNumericInstruction;
localVariable = inst.Variable;
}
var getterCall = binary?.Left as CallInstruction;
var setterCall = block.Instructions.ElementAtOrDefault(i + 1) as CallInstruction;
if (getterCall == null || setterCall == null || !IsSameMember(getterCall.Method.AccessorOwner, setterCall.Method.AccessorOwner))
return false;
var owner = getterCall.Method.AccessorOwner as IProperty;
if (owner == null || !IsSameMember(getterCall.Method, owner.Getter) || !IsSameMember(setterCall.Method, owner.Setter))
return false;
var next = block.Instructions.ElementAtOrDefault(i + 2);
if (next == null)
return false;
var usages = next.Descendants.Where(d => d.MatchLdLoc(localVariable)).ToArray();
if (usages.Length != 1)
return false;
block.Instructions.RemoveAt(i + 1);
inst.ReplaceWith(new StLoc(local, new StObj(fieldStore.Target, value, fieldStore.Type)));
block.Instructions.RemoveAt(i);
usages[0].ReplaceWith(new CompoundAssignmentInstruction(binary.Operator, getterCall, binary.Right,
getterCall.Method.ReturnType, binary.CheckForOverflow, binary.Sign, CompoundAssignmentType.EvaluatesToNewValue));
return true;
}
/// <code>
@ -241,7 +301,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -241,7 +301,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
ILInstruction baseFieldAddressLoad3;
if (!targetFieldLoad.MatchLdFlda(out baseFieldAddressLoad2, out targetField) || !baseFieldAddressLoad2.MatchLdLoc(baseFieldAddress.Variable))
return false;
if (!stobj.Target.MatchLdFlda(out baseFieldAddressLoad3, out targetField2) || !baseFieldAddressLoad3.MatchLdLoc(baseFieldAddress.Variable) || !SameField(targetField, targetField2))
if (!stobj.Target.MatchLdFlda(out baseFieldAddressLoad3, out targetField2) || !baseFieldAddressLoad3.MatchLdLoc(baseFieldAddress.Variable) || !IsSameMember(targetField, targetField2))
return false;
baseAddress = new LdFlda(baseFieldAddress.Value, targetField);
} else if (baseFieldAddress.Value is LdElema) {
@ -279,7 +339,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -279,7 +339,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
IField field, field2;
if (inst.Variable.Kind != VariableKind.StackSlot || !inst.Value.MatchLdObj(out target, out type) || !target.MatchLdsFlda(out field))
return false;
if (!stobj.Target.MatchLdsFlda(out field2) || !SameField(field, field2))
if (!stobj.Target.MatchLdsFlda(out field2) || !IsSameMember(field, field2))
return false;
var binary = stobj.Value as BinaryNumericInstruction;
if (binary == null || !binary.Left.MatchLdLoc(inst.Variable) || !binary.Right.MatchLdcI4(1))
@ -289,10 +349,12 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -289,10 +349,12 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return true;
}
static bool SameField(IField a, IField b)
static bool IsSameMember(IMember a, IMember b)
{
a = (IField)a.MemberDefinition;
b = (IField)b.MemberDefinition;
if (a == null || b == null)
return false;
a = a.MemberDefinition;
b = b.MemberDefinition;
return a.Equals(b);
}
}

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

@ -22,15 +22,80 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -22,15 +22,80 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public class CompoundAssignmentTest
{
[Flags]
private enum MyEnum
{
None = 0,
One = 1,
Two = 2,
Four = 4
}
private struct StructContainer
{
public bool HasIndex;
public int Field;
}
public class MutableClass
{
public int Field;
public int Property {
get;
set;
}
public uint this[string name] {
get {
return 0u;
}
set {
}
}
}
private int test1;
private int[] array1;
private StructContainer field1;
private MyEnum enumField;
public static int StaticField;
public static int StaticProperty {
get;
set;
}
private MutableClass M()
{
return new MutableClass();
}
private int[,] Array()
{
return (int[,])null;
}
private unsafe int* GetPointer()
{
// return null;
return (int*)0u;
}
public int GetIndex()
{
return new Random().Next(0, 100);
}
public int[] GetArray()
{
throw new NotImplementedException();
}
public int GetValue(int value)
{
return value;
}
public static void Main()
{
@ -123,31 +188,57 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -123,31 +188,57 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(this.array1[i * 2] += i * 2);
}
public int GetIndex()
public int ArrayUsageWithMethods()
{
return new Random().Next(0, 100);
return this.GetArray()[this.GetIndex()]++;
}
public int[] GetArray()
public void NestedField()
{
throw new NotImplementedException();
if (this.field1.HasIndex) {
Console.WriteLine(this.field1.Field++);
}
}
public int GetValue(int value)
public void Enum()
{
return value;
this.enumField |= MyEnum.Two;
this.enumField &= ~MyEnum.Four;
}
public int ArrayUsageWithMethods()
public int PreIncrementInAddition(int i, int j)
{
return this.GetArray()[this.GetIndex()]++;
return i + ++j;
}
public void NestedField()
public int PreIncrementArrayElement(int[] array, int pos)
{
if (this.field1.HasIndex) {
Console.WriteLine(this.field1.Field++);
}
return --array[pos];
}
public int PreIncrementInstanceField()
{
return ++this.M().Field;
}
public int PreIncrementInstanceField2(MutableClass m)
{
return ++m.Field;
}
public int PreIncrementInstanceProperty()
{
return ++this.M().Property;
}
public int PreIncrementStaticField()
{
return ++CompoundAssignmentTest.StaticField;
}
public int PreIncrementStaticProperty()
{
return ++CompoundAssignmentTest.StaticProperty;
}
}
}

455
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 kb1brdcl
.assembly o4ovvbve
{
.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 kb1brdcl.exe
// MVID: {FA9A1DD3-2F44-4DB4-BC5E-6EF79C457314}
.module o4ovvbve.exe
// MVID: {8C8569FB-7FDE-4B4A-809D-7FA7F5088538}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x01190000
// Image base: 0x01310000
// =============== CLASS MEMBERS DECLARATION ===================
@ -36,6 +36,17 @@ @@ -36,6 +36,17 @@
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest
extends [mscorlib]System.Object
{
.class auto ansi sealed nested private MyEnum
extends [mscorlib]System.Enum
{
.custom instance void [mscorlib]System.FlagsAttribute::.ctor() = ( 01 00 00 00 )
.field public specialname rtspecialname int32 value__
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum None = int32(0x00000000)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum One = int32(0x00000001)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum Two = int32(0x00000002)
.field public static literal valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum Four = int32(0x00000004)
} // end of class MyEnum
.class sequential ansi sealed nested private beforefieldinit StructContainer
extends [mscorlib]System.ValueType
{
@ -43,9 +54,212 @@ @@ -43,9 +54,212 @@
.field public int32 Field
} // end of class StructContainer
.class auto ansi nested public beforefieldinit MutableClass
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) // ...Item..
.field public int32 Field
.field private int32 '<Property>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method public hidebysig specialname
instance int32 get_Property() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 11 (0xb)
.maxstack 1
.locals init (int32 V_0)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::'<Property>k__BackingField'
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method MutableClass::get_Property
.method public hidebysig specialname
instance void set_Property(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.CompoundAssignmentTest/MutableClass::'<Property>k__BackingField'
IL_0007: ret
} // end of method MutableClass::set_Property
.method public hidebysig specialname
instance uint32 get_Item(string name) cil managed
{
// Code size 7 (0x7)
.maxstack 1
.locals init (uint32 V_0)
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method MutableClass::get_Item
.method public hidebysig specialname
instance void set_Item(string name,
uint32 'value') cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method MutableClass::set_Item
.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 MutableClass::.ctor
.property instance int32 Property()
{
.get instance int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Property()
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Property(int32)
} // end of property MutableClass::Property
.property instance uint32 Item(string)
{
.get instance uint32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::get_Item(string)
.set instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::set_Item(string,
uint32)
} // end of property MutableClass::Item
} // end of class MutableClass
.field private int32 test1
.field private int32[] array1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/StructContainer field1
.field private valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum enumField
.field public static int32 StaticField
.field private static int32 '<StaticProperty>k__BackingField'
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.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 10 (0xa)
.maxstack 1
.locals init (int32 V_0)
IL_0000: ldsfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::'<StaticProperty>k__BackingField'
IL_0005: stloc.0
IL_0006: br.s IL_0008
IL_0008: ldloc.0
IL_0009: ret
} // end of method CompoundAssignmentTest::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.CompoundAssignmentTest::'<StaticProperty>k__BackingField'
IL_0006: ret
} // end of method CompoundAssignmentTest::set_StaticProperty
.method private hidebysig instance class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass
M() cil managed
{
// Code size 11 (0xb)
.maxstack 1
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass V_0)
IL_0000: nop
IL_0001: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::.ctor()
IL_0006: stloc.0
IL_0007: br.s IL_0009
IL_0009: ldloc.0
IL_000a: ret
} // end of method CompoundAssignmentTest::M
.method private hidebysig instance int32[0...,0...]
Array() cil managed
{
// Code size 7 (0x7)
.maxstack 1
.locals init (int32[0...,0...] V_0)
IL_0000: nop
IL_0001: ldnull
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method CompoundAssignmentTest::Array
.method private hidebysig instance int32*
GetPointer() cil managed
{
// Code size 8 (0x8)
.maxstack 1
.locals init (int32* V_0)
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: conv.u
IL_0003: stloc.0
IL_0004: br.s IL_0006
IL_0006: ldloc.0
IL_0007: ret
} // end of method CompoundAssignmentTest::GetPointer
.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 CompoundAssignmentTest::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 CompoundAssignmentTest::GetArray
.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 CompoundAssignmentTest::GetValue
.method public hidebysig static void Main() cil managed
{
.entrypoint
@ -392,50 +606,6 @@ @@ -392,50 +606,6 @@
IL_0049: ret
} // end of method CompoundAssignmentTest::Array
.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 CompoundAssignmentTest::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 CompoundAssignmentTest::GetArray
.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 CompoundAssignmentTest::GetValue
.method public hidebysig instance int32
ArrayUsageWithMethods() cil managed
{
@ -498,6 +668,190 @@ @@ -498,6 +668,190 @@
IL_0031: ret
} // end of method CompoundAssignmentTest::NestedField
.method public hidebysig instance void
Enum() cil managed
{
// Code size 31 (0x1f)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: dup
IL_0003: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0008: ldc.i4.2
IL_0009: or
IL_000a: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_000f: ldarg.0
IL_0010: dup
IL_0011: ldfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_0016: ldc.i4.s -5
IL_0018: and
IL_0019: stfld valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MyEnum ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::enumField
IL_001e: ret
} // end of method CompoundAssignmentTest::Enum
.method public hidebysig instance int32
PreIncrementInAddition(int32 i,
int32 j) cil managed
{
// Code size 14 (0xe)
.maxstack 3
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldarg.2
IL_0003: ldc.i4.1
IL_0004: add
IL_0005: dup
IL_0006: starg.s j
IL_0008: add
IL_0009: stloc.0
IL_000a: br.s IL_000c
IL_000c: ldloc.0
IL_000d: ret
} // end of method CompoundAssignmentTest::PreIncrementInAddition
.method public hidebysig instance int32
PreIncrementArrayElement(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.1
IL_000f: sub
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::PreIncrementArrayElement
.method public hidebysig instance int32
PreIncrementInstanceField() 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.1
IL_000e: add
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::PreIncrementInstanceField
.method public hidebysig instance int32
PreIncrementInstanceField2(class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass m) cil managed
{
// Code size 23 (0x17)
.maxstack 3
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: dup
IL_0003: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0008: ldc.i4.1
IL_0009: add
IL_000a: dup
IL_000b: stloc.1
IL_000c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest/MutableClass::Field
IL_0011: ldloc.1
IL_0012: stloc.0
IL_0013: br.s IL_0015
IL_0015: ldloc.0
IL_0016: ret
} // end of method CompoundAssignmentTest::PreIncrementInstanceField2
.method public hidebysig instance int32
PreIncrementInstanceProperty() 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.1
IL_000e: add
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::PreIncrementInstanceProperty
.method public hidebysig instance int32
PreIncrementStaticField() 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.1
IL_0007: add
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::PreIncrementStaticField
.method public hidebysig instance int32
PreIncrementStaticProperty() 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.1
IL_0007: add
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::PreIncrementStaticProperty
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
@ -508,6 +862,11 @@ @@ -508,6 +862,11 @@
IL_0006: ret
} // end of method CompoundAssignmentTest::.ctor
.property int32 StaticProperty()
{
.get int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::get_StaticProperty()
.set void ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest::set_StaticProperty(int32)
} // end of property CompoundAssignmentTest::StaticProperty
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.CompoundAssignmentTest

Loading…
Cancel
Save