Created
January 12, 2011 19:09
-
-
Save bojanrajkovic/776674 to your computer and use it in GitHub Desktop.
IL for the test program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
class Test { | |
public static IEnumerable<int> TestA (int n) { | |
for (int i = 0; i < n; i++) { | |
yield return i; | |
} | |
} | |
public static void Main (string[] args) { | |
foreach (var i in TestA (10)) | |
Console.WriteLine (i); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.assembly extern mscorlib | |
{ | |
.ver 2:0:0:0 | |
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. | |
} | |
.assembly 'test' | |
{ | |
.custom instance void class [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. | |
.hash algorithm 0x00008004 | |
.ver 0:0:0:0 | |
} | |
.module test.exe // GUID = {BE4FF952-E6A4-4027-A545-273B91AD270E} | |
.class private auto ansi beforefieldinit Test | |
extends [mscorlib]System.Object | |
{ | |
// method line 1 | |
.method public hidebysig specialname rtspecialname | |
instance default void '.ctor' () cil managed | |
{ | |
// Method begins at RVA 0x20ec | |
// Code size 7 (0x7) | |
.maxstack 8 | |
IL_0000: ldarg.0 | |
IL_0001: call instance void object::'.ctor'() | |
IL_0006: ret | |
} // end of method Test::.ctor | |
// method line 2 | |
.method public static hidebysig | |
default class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> TestA (int32 n) cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x20f4 | |
// Code size 30 (0x1e) | |
.maxstack 3 | |
.locals init ( | |
class Test/'<TestA>c__Iterator0' V_0) | |
IL_0000: newobj instance void class Test/'<TestA>c__Iterator0'::'.ctor'() | |
IL_0005: stloc.0 | |
IL_0006: ldloc.0 | |
IL_0007: ldarg.0 | |
IL_0008: stfld int32 Test/'<TestA>c__Iterator0'::n | |
IL_000d: ldloc.0 | |
IL_000e: ldarg.0 | |
IL_000f: stfld int32 Test/'<TestA>c__Iterator0'::'<$>n' | |
IL_0014: ldloc.0 | |
IL_0015: dup | |
IL_0016: ldc.i4.s 0xfffffffe | |
IL_0018: stfld int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_001d: ret | |
} // end of method Test::TestA | |
// method line 3 | |
.method public static hidebysig | |
default void Main (string[] args) cil managed | |
{ | |
// Method begins at RVA 0x2120 | |
.entrypoint | |
// Code size 61 (0x3d) | |
.maxstack 10 | |
.locals init ( | |
int32 V_0, | |
class [mscorlib]System.Collections.Generic.IEnumerator`1<int32> V_1) | |
IL_0000: ldc.i4.s 0x0a | |
IL_0002: call class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> class Test::TestA(int32) | |
IL_0007: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>::GetEnumerator() | |
IL_000c: stloc.1 | |
.try { // 0 | |
IL_000d: br IL_001f | |
IL_0012: ldloc.1 | |
IL_0013: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>::get_Current() | |
IL_0018: stloc.0 | |
IL_0019: ldloc.0 | |
IL_001a: call void class [mscorlib]System.Console::WriteLine(int32) | |
IL_001f: ldloc.1 | |
IL_0020: callvirt instance bool class [mscorlib]System.Collections.IEnumerator::MoveNext() | |
IL_0025: brtrue IL_0012 | |
IL_002a: leave IL_003c | |
} // end .try 0 | |
finally { // 0 | |
IL_002f: ldloc.1 | |
IL_0030: brfalse IL_003b | |
IL_0035: ldloc.1 | |
IL_0036: callvirt instance void class [mscorlib]System.IDisposable::Dispose() | |
IL_003b: endfinally | |
} // end handler 0 | |
IL_003c: ret | |
} // end of method Test::Main | |
.class nested private auto ansi sealed beforefieldinit '<TestA>c__Iterator0' | |
extends [mscorlib]System.Object | |
implements class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>, class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>, [mscorlib]System.Collections.IEnumerator, [mscorlib]System.IDisposable, [mscorlib]System.Collections.IEnumerable { | |
.custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
.field assembly int32 '<i>__0' | |
.field assembly int32 n | |
.field assembly int32 $PC | |
.field assembly int32 $current | |
.field assembly int32 '<$>n' | |
// method line 4 | |
.method public hidebysig specialname rtspecialname | |
instance default void '.ctor' () cil managed | |
{ | |
// Method begins at RVA 0x2188 | |
// Code size 7 (0x7) | |
.maxstack 8 | |
IL_0000: ldarg.0 | |
IL_0001: call instance void object::'.ctor'() | |
IL_0006: ret | |
} // end of method <TestA>c__Iterator0::.ctor | |
// method line 5 | |
.method private final virtual hidebysig newslot specialname | |
instance default int32 'System.Collections.Generic.IEnumerator<int>.get_Current' () cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x2190 | |
.override method instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>::get_Current() | |
// Code size 7 (0x7) | |
.maxstack 8 | |
IL_0000: ldarg.0 | |
IL_0001: ldfld int32 Test/'<TestA>c__Iterator0'::$current | |
IL_0006: ret | |
} // end of method <TestA>c__Iterator0::System.Collections.Generic.IEnumerator<int>.get_Current | |
// method line 6 | |
.method private final virtual hidebysig newslot specialname | |
instance default object System.Collections.IEnumerator.get_Current () cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x2198 | |
.override class [mscorlib]System.Collections.IEnumerator::get_Current | |
// Code size 12 (0xc) | |
.maxstack 8 | |
IL_0000: ldarg.0 | |
IL_0001: ldfld int32 Test/'<TestA>c__Iterator0'::$current | |
IL_0006: box [mscorlib]System.Int32 | |
IL_000b: ret | |
} // end of method <TestA>c__Iterator0::System.Collections.IEnumerator.get_Current | |
// method line 7 | |
.method private final virtual hidebysig newslot | |
instance default class [mscorlib]System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x21a8 | |
.override class [mscorlib]System.Collections.IEnumerable::GetEnumerator | |
// Code size 7 (0x7) | |
.maxstack 8 | |
IL_0000: ldarg.0 | |
IL_0001: call instance class [mscorlib]System.Collections.Generic.IEnumerator`1<int32> class Test/'<TestA>c__Iterator0'::'System.Collections.Generic.IEnumerable<int>.GetEnumerator'() | |
IL_0006: ret | |
} // end of method <TestA>c__Iterator0::System.Collections.IEnumerable.GetEnumerator | |
// method line 8 | |
.method private final virtual hidebysig newslot | |
instance default class [mscorlib]System.Collections.Generic.IEnumerator`1<int32> 'System.Collections.Generic.IEnumerable<int>.GetEnumerator' () cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x21b0 | |
.override method instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>::GetEnumerator() | |
// Code size 40 (0x28) | |
.maxstack 5 | |
.locals init ( | |
class Test/'<TestA>c__Iterator0' V_0) | |
IL_0000: ldarg.0 | |
IL_0001: ldflda int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_0006: ldc.i4.0 | |
IL_0007: ldc.i4.s 0xfffffffe | |
IL_0009: call int32 class [mscorlib]System.Threading.Interlocked::CompareExchange([out] int32&, int32, int32) | |
IL_000e: ldc.i4.s 0xfffffffe | |
IL_0010: bne.un.s IL_0014 | |
IL_0012: ldarg.0 | |
IL_0013: ret | |
IL_0014: newobj instance void class Test/'<TestA>c__Iterator0'::'.ctor'() | |
IL_0019: stloc.0 | |
IL_001a: ldloc.0 | |
IL_001b: ldarg.0 | |
IL_001c: ldfld int32 Test/'<TestA>c__Iterator0'::'<$>n' | |
IL_0021: stfld int32 Test/'<TestA>c__Iterator0'::n | |
IL_0026: ldloc.0 | |
IL_0027: ret | |
} // end of method <TestA>c__Iterator0::System.Collections.Generic.IEnumerable<int>.GetEnumerator | |
// method line 9 | |
.method public final virtual hidebysig newslot | |
instance default bool MoveNext () cil managed | |
{ | |
// Method begins at RVA 0x21e4 | |
// Code size 113 (0x71) | |
.maxstack 4 | |
.locals init ( | |
unsigned int32 V_0, | |
bool V_1) | |
IL_0000: ldarg.0 | |
IL_0001: ldfld int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_0006: stloc.0 | |
IL_0007: ldarg.0 | |
IL_0008: ldc.i4.m1 | |
IL_0009: stfld int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_000e: ldloc.0 | |
IL_000f: switch ( | |
IL_0021, | |
IL_0045) | |
IL_001c: br IL_006b | |
IL_0021: ldarg.0 | |
IL_0022: ldc.i4.0 | |
IL_0023: stfld int32 Test/'<TestA>c__Iterator0'::'<i>__0' | |
IL_0028: br IL_0053 | |
IL_002d: ldarg.0 | |
IL_002e: ldarg.0 | |
IL_002f: ldfld int32 Test/'<TestA>c__Iterator0'::'<i>__0' | |
IL_0034: stfld int32 Test/'<TestA>c__Iterator0'::$current | |
IL_0039: ldarg.0 | |
IL_003a: ldc.i4.1 | |
IL_003b: stfld int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_0040: br IL_006d | |
IL_0045: ldarg.0 | |
IL_0046: ldarg.0 | |
IL_0047: ldfld int32 Test/'<TestA>c__Iterator0'::'<i>__0' | |
IL_004c: ldc.i4.1 | |
IL_004d: add | |
IL_004e: stfld int32 Test/'<TestA>c__Iterator0'::'<i>__0' | |
IL_0053: ldarg.0 | |
IL_0054: ldfld int32 Test/'<TestA>c__Iterator0'::'<i>__0' | |
IL_0059: ldarg.0 | |
IL_005a: ldfld int32 Test/'<TestA>c__Iterator0'::n | |
IL_005f: blt IL_002d | |
IL_0064: ldarg.0 | |
IL_0065: ldc.i4.m1 | |
IL_0066: stfld int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_006b: ldc.i4.0 | |
IL_006c: ret | |
IL_006d: ldc.i4.1 | |
IL_006e: ret | |
IL_006f: ldloc.1 | |
IL_0070: ret | |
} // end of method <TestA>c__Iterator0::MoveNext | |
// method line 10 | |
.method public final virtual hidebysig newslot | |
instance default void Dispose () cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x2264 | |
// Code size 8 (0x8) | |
.maxstack 8 | |
IL_0000: ldarg.0 | |
IL_0001: ldc.i4.m1 | |
IL_0002: stfld int32 Test/'<TestA>c__Iterator0'::$PC | |
IL_0007: ret | |
} // end of method <TestA>c__Iterator0::Dispose | |
// method line 11 | |
.method public final virtual hidebysig newslot | |
instance default void Reset () cil managed | |
{ | |
.custom instance void class [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::'.ctor'() = (01 00 00 00 ) // .... | |
// Method begins at RVA 0x2270 | |
// Code size 6 (0x6) | |
.maxstack 8 | |
IL_0000: newobj instance void class [mscorlib]System.NotSupportedException::'.ctor'() | |
IL_0005: throw | |
} // end of method <TestA>c__Iterator0::Reset | |
.property instance int32 'System.Collections.Generic.IEnumerator<int>.Current' () | |
{ | |
.get instance default int32 Test/'<TestA>c__Iterator0'::'System.Collections.Generic.IEnumerator<int>.get_Current' () | |
} | |
.property instance object System.Collections.IEnumerator.Current () | |
{ | |
.get instance default object Test/'<TestA>c__Iterator0'::System.Collections.IEnumerator.get_Current () | |
} | |
} // end of class <TestA>c__Iterator0 | |
} // end of class Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment