mirror of https://github.com/icsharpcode/ILSpy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
2.1 KiB
124 lines
2.1 KiB
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
|
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) |
|
|
|
using System; |
|
|
|
public class IncrementDecrement |
|
{ |
|
public class MutableClass |
|
{ |
|
public int Field; |
|
} |
|
|
|
public static int StaticField; |
|
|
|
private IncrementDecrement.MutableClass M() |
|
{ |
|
return new IncrementDecrement.MutableClass(); |
|
} |
|
|
|
private unsafe int* GetPointer() |
|
{ |
|
return null; |
|
} |
|
|
|
public int PreIncrementInAddition(int i, int j) |
|
{ |
|
return i + ++j; |
|
} |
|
|
|
public int PreDecrementArrayElement(int[] array, int pos) |
|
{ |
|
return --array[pos]; |
|
} |
|
|
|
public int PreIncrementInstanceField() |
|
{ |
|
return ++this.M().Field; |
|
} |
|
|
|
public int PreIncrementInstanceField2(IncrementDecrement.MutableClass m) |
|
{ |
|
return ++m.Field; |
|
} |
|
|
|
public int PreIncrementStaticField() |
|
{ |
|
return ++IncrementDecrement.StaticField; |
|
} |
|
|
|
public int PreIncrementByRef(ref int i) |
|
{ |
|
return ++i; |
|
} |
|
|
|
public unsafe int PreIncrementByPointer() |
|
{ |
|
return ++(*this.GetPointer()); |
|
} |
|
|
|
public int CompoundMultiplyInstanceField() |
|
{ |
|
return this.M().Field *= 10; |
|
} |
|
|
|
public int CompoundXorStaticField() |
|
{ |
|
return IncrementDecrement.StaticField ^= 100; |
|
} |
|
|
|
public int CompoundMultiplyArrayElement1(int[] array, int pos) |
|
{ |
|
return array[pos] *= 10; |
|
} |
|
|
|
public int CompoundMultiplyArrayElement2(int[] array) |
|
{ |
|
return array[Environment.TickCount] *= 10; |
|
} |
|
|
|
public int CompoundShiftByRef(ref int i) |
|
{ |
|
return i <<= 2; |
|
} |
|
|
|
public unsafe double CompoundDivideByPointer(double* ptr) |
|
{ |
|
return *ptr /= 1.5; |
|
} |
|
|
|
public int PostIncrementInAddition(int i, int j) |
|
{ |
|
return i++ + j; |
|
} |
|
|
|
public int PostDecrementArrayElement(int[] array, int pos) |
|
{ |
|
return array[pos]--; |
|
} |
|
|
|
public int PostIncrementStaticField() |
|
{ |
|
return IncrementDecrement.StaticField++; |
|
} |
|
|
|
public int PostIncrementInstanceField(IncrementDecrement.MutableClass m) |
|
{ |
|
return m.Field++; |
|
} |
|
|
|
public int PostDecrementInstanceField() |
|
{ |
|
return this.M().Field--; |
|
} |
|
|
|
public int PostIncrementByRef(ref int i) |
|
{ |
|
return i++; |
|
} |
|
|
|
public unsafe int PostIncrementByPointer() |
|
{ |
|
return (*this.GetPointer())++; |
|
} |
|
}
|
|
|