反编译后,迭代器用的是状态机,栈本身就是状态机,由于协程本身也有栈, 我怀疑C#中的 迭代器和基于任务的异步编程是协程(未经过验证)

.class nested private auto ansi sealed beforefieldinit '<GetEnumerator>d__12'
extends [System.Runtime]System.Object
implements class [System.Runtime]System.Collections.Generic.IEnumerator`1<object>,
[System.Runtime]System.Collections.IEnumerator,
[System.Runtime]System.IDisposable

//这个位置相当于以上等于 private class  sealed <GetEnumerator>d__12:object,IEnumerator,IEnumerator,IDisposable
// nested :嵌套    
//implements  :实现接口
//extends:是继承父类,只要那个类不是声明为final或者那个类定义为abstract的就能继承,
beforefieldinit:beforefieldinit指示CLI在调用静态方法之前不必初始化类型。


{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
01 00 00 00
)
自定义实例:.custom 声明,后跟类型的方法声明 构造函数
CompilerGeneratedAttribute 特性应用到任何应用程序元素,以指示该元素由编译器生成。

// Fields 字段 .field private int32 '<>1__state' .field private object '<>2__current' .field public class School.ClassOfStudent '<>4__this' .field private int32 '<index>5__1' // Methods 
//

.method public hidebysig specialname rtspecialname
instance void .ctor (
int32 '<>1__state'
) cil managed
//cil managed:托管代码
{
.custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x2369
// Code size 15 (0xf)
.maxstack 8 // {
IL_0000: ldarg.0
// (no C# code)
IL_0001: call instance void [System.Runtime]System.Object::.ctor()
// this.<>1__state = <>1__state;
IL_0006: nop
IL_0007: ldarg.0
IL_0008: ldarg.1
IL_0009: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state'
// }
IL_000e: ret
} // end of method '<GetEnumerator>d__12'::.ctor .method private final hidebysig newslot virtual
instance void System.IDisposable.Dispose () cil managed
{
.custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
01 00 00 00
)
.override method instance void [System.Runtime]System.IDisposable::Dispose()
// Method begins at RVA 0x2379
// Code size 1 (0x1)
.maxstack 8 // }
IL_0000: ret
} // end of method '<GetEnumerator>d__12'::System.IDisposable.Dispose .method private final hidebysig newslot virtual
instance bool MoveNext () cil managed
{
.override method instance bool [System.Runtime]System.Collections.IEnumerator::MoveNext()
// Method begins at RVA 0x237c
// Code size 133 (0x85)
.maxstack 3
.locals init (
[0] int32,
[1] int32,
[2] bool
) // switch (<>1__state)
IL_0000: ldarg.0
IL_0001: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state'
IL_0006: stloc.0
// (no C# code)
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0012 IL_000a: br.s IL_000c IL_000c: ldloc.0
IL_000d: ldc.i4.1
IL_000e: beq.s IL_0014 IL_0010: br.s IL_0016 IL_0012: br.s IL_0018 // return false;
IL_0014: br.s IL_004f IL_0016: ldc.i4.0
IL_0017: ret // <>1__state = -1;
IL_0018: ldarg.0
IL_0019: ldc.i4.m1
IL_001a: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state'
// <index>5__1 = 0;
IL_001f: nop
IL_0020: ldarg.0
IL_0021: ldc.i4.0
IL_0022: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1'
// break;
IL_0027: br.s IL_0067 // <>2__current = <>4__this.students[<index>5__1];
IL_0029: nop
IL_002a: ldarg.0
IL_002b: ldarg.0
IL_002c: ldfld class School.ClassOfStudent School.ClassOfStudent/'<GetEnumerator>d__12'::'<>4__this'
IL_0031: ldfld class [System.Collections]System.Collections.Generic.List`1<class School.Student> School.ClassOfStudent::students
IL_0036: ldarg.0
IL_0037: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1'
IL_003c: callvirt instance !0 class [System.Collections]System.Collections.Generic.List`1<class School.Student>::get_Item(int32)
IL_0041: stfld object School.ClassOfStudent/'<GetEnumerator>d__12'::'<>2__current'
// <>1__state = 1;
IL_0046: ldarg.0
IL_0047: ldc.i4.1
IL_0048: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state'
// return true;
IL_004d: ldc.i4.1
IL_004e: ret // <>1__state = -1;
IL_004f: ldarg.0
IL_0050: ldc.i4.m1
IL_0051: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state'
// <index>5__1++;
IL_0056: nop
IL_0057: ldarg.0
IL_0058: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1'
IL_005d: stloc.1
// if (<index>5__1 < <>4__this.students.Count)
IL_005e: ldarg.0
IL_005f: ldloc.1
IL_0060: ldc.i4.1
IL_0061: add
IL_0062: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1' IL_0067: ldarg.0
IL_0068: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1'
IL_006d: ldarg.0
IL_006e: ldfld class School.ClassOfStudent School.ClassOfStudent/'<GetEnumerator>d__12'::'<>4__this'
IL_0073: ldfld class [System.Collections]System.Collections.Generic.List`1<class School.Student> School.ClassOfStudent::students
IL_0078: callvirt instance int32 class [System.Collections]System.Collections.Generic.List`1<class School.Student>::get_Count()
IL_007d: clt
IL_007f: stloc.2
IL_0080: ldloc.2
IL_0081: brtrue.s IL_0029 // return false;
IL_0083: ldc.i4.0
IL_0084: ret
} // end of method '<GetEnumerator>d__12'::MoveNext .method private final hidebysig specialname newslot virtual
instance object 'System.Collections.Generic.IEnumerator<System.Object>.get_Current' () cil managed
{
.custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
01 00 00 00
)
.override method instance !0 class [System.Runtime]System.Collections.Generic.IEnumerator`1<object>::get_Current()
// Method begins at RVA 0x240d
// Code size 7 (0x7)
.maxstack 8 // return <>2__current;
IL_0000: ldarg.0
IL_0001: ldfld object School.ClassOfStudent/'<GetEnumerator>d__12'::'<>2__current'
IL_0006: ret
} // end of method '<GetEnumerator>d__12'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current' .method private final hidebysig newslot virtual
instance void System.Collections.IEnumerator.Reset () cil managed
{
.custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
01 00 00 00
)
.override method instance void [System.Runtime]System.Collections.IEnumerator::Reset()
// Method begins at RVA 0x2415
// Code size 6 (0x6)
.maxstack 8 // throw new NotSupportedException();
IL_0000: newobj instance void [System.Runtime]System.NotSupportedException::.ctor()
IL_0005: throw
} // end of method '<GetEnumerator>d__12'::System.Collections.IEnumerator.Reset .method private final hidebysig specialname newslot virtual
instance object System.Collections.IEnumerator.get_Current () cil managed
{
.custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (
01 00 00 00
)
.override method instance object [System.Runtime]System.Collections.IEnumerator::get_Current()
// Method begins at RVA 0x241c
// Code size 7 (0x7)
.maxstack 8 // return <>2__current;
IL_0000: ldarg.0
IL_0001: ldfld object School.ClassOfStudent/'<GetEnumerator>d__12'::'<>2__current'
IL_0006: ret
} // end of method '<GetEnumerator>d__12'::System.Collections.IEnumerator.get_Current // Properties
.property instance object 'System.Collections.Generic.IEnumerator<System.Object>.Current'()
{
.get instance object School.ClassOfStudent/'<GetEnumerator>d__12'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current'()
}
.property instance object System.Collections.IEnumerator.Current()
{
.get instance object School.ClassOfStudent/'<GetEnumerator>d__12'::System.Collections.IEnumerator.get_Current()
} } // end of class <GetEnumerator>d__12

最新文章

  1. 记录软件工程课程项目开发时遇到的各种小问题(django)
  2. Rabbitmq基本原理
  3. pageEncoding与contentType属性
  4. JS调用WebService
  5. 续Gulp使用入门三步压缩CSS
  6. http和socket通信的区别
  7. SoundPool没有声音的问题
  8. python中如何使用help命令?
  9. uboot使用tftp下载时出现“checksum bad”问题原因分析
  10. 构建混合云:配置Azure site to site VPN连接(3)
  11. 牛顿法(Newton&#39;s Method)
  12. Java Integer类型比较
  13. [USACO16OPEN]关闭农场Closing the Farm_Silver
  14. JavaScript设计模式之一Interface接口
  15. 基础概念【softmax|normalizatoin|standardization】
  16. MyBatis进阶(三)
  17. Java/JSP程序连接不上Mysql驱动问题解决方法
  18. 实现数组(java)
  19. PHP代码审计笔记--文件包含漏洞
  20. opencv图片右转函数

热门文章

  1. 『德不孤』Pytest框架 — 3、Pytest的基础说明
  2. C++11之future(二)
  3. 公司内部一次关于kafka消息队列消费积压故障复盘分享
  4. IoC容器-Bean管理XML方式(创建对象和set注入属性,有参构造注入属性)
  5. Git算不算程序员的必备技能?
  6. Error building SqlSession. ### The error may exist in dao/UserMapper.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration(2 字节的 UTF-8 序列的字节 2 无效。)
  7. maven一键构造及常用命令
  8. 常见线程池之 newCacheThreadPool 缓存线程池 简单使用
  9. CEH v8~v11 Module Slides 和 Lab Manual 下载
  10. java下载网络大文件之内存不够的解决办法(包含分片上传分片下载)