{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/cil-language-learning/",
  "atlas": "https://www.pystone.net/?node=cil-language-learning#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/cil-language-learning.md",
  "context": "https://www.pystone.net/notes/cil-language-learning.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:cil-language-learning",
  "slug": "cil-language-learning",
  "title": "IL语言学习",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "IL语言学习",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "2cdb49c9c6c8c69dc218439910a50366b76487596ed0d35182ec2d12be131763",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "IL语言学习",
      "anchor": "il语言学习",
      "citation": "https://www.pystone.net/notes/cil-language-learning/#il%E8%AF%AD%E8%A8%80%E5%AD%A6%E4%B9%A0"
    },
    {
      "depth": 3,
      "text": "概念引入",
      "anchor": "概念引入",
      "citation": "https://www.pystone.net/notes/cil-language-learning/#%E6%A6%82%E5%BF%B5%E5%BC%95%E5%85%A5"
    },
    {
      "depth": 3,
      "text": "常用操作码",
      "anchor": "常用操作码",
      "citation": "https://www.pystone.net/notes/cil-language-learning/#%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E7%A0%81"
    },
    {
      "depth": 4,
      "text": "三种call的区别",
      "anchor": "三种call的区别",
      "citation": "https://www.pystone.net/notes/cil-language-learning/#%E4%B8%89%E7%A7%8Dcall%E7%9A%84%E5%8C%BA%E5%88%AB"
    },
    {
      "depth": 3,
      "text": "ProjectAuditor中分析到的指令",
      "anchor": "projectauditor中分析到的指令",
      "citation": "https://www.pystone.net/notes/cil-language-learning/#projectauditor%E4%B8%AD%E5%88%86%E6%9E%90%E5%88%B0%E7%9A%84%E6%8C%87%E4%BB%A4"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:programming-languages-and-runtimes",
      "title": "编程语言与运行时",
      "url": "https://www.pystone.net/notes/programming-languages-and-runtimes/",
      "atlas": "https://www.pystone.net/?node=programming-languages-and-runtimes#knowledge-atlas",
      "label": "编程语言与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": ".NET与CSharp中的“IL语言学习”导航项",
      "citation": "https://www.pystone.net/notes/programming-languages-and-runtimes/#net%E4%B8%8Ecsharp"
    }
  ],
  "contentMarkdown": "# IL语言学习\n\n> 创建时间：2020/4/28 16:48\n\n<https://www.cnblogs.com/zery/p/3366175.html>\n<https://www.cnblogs.com/zery/p/3376973.html>\n<https://blog.csdn.net/u012395622/article/details/46545349>\n<https://www.cnblogs.com/yuanyang/p/5422351.html>\n\n操作码文档（包括操作码的用法和特点）：\n<https://docs.microsoft.com/zh-cn/dotnet/api/system.reflection.emit.opcodes?view=netcore-3.1>\n\n### 概念引入\n\n### 常用操作码\n\nnop:即No Operation 没有任何操作，我们也不用管它，\nldstr.:即Load String 把字符串加压入Evaluation Stack中\nstloc.：把Evaluation Stack中的值弹出赋值到Call Stack中的Record Frame中\nldloc.:把Call Stack中的Record Frame中指定位置的值取出(copy)存入 Evaluation Stack中 以上两条指令为相互的操作stloc赋值，ldloc取值\ncall: 调用指定的方法\nret: 即return 标记返回\n\n#### 三种call的区别\n\n**Call** :常用于调用编译时就确定的方法，可以直接去元数据里找方法，如静态函数，实例方法，也可以call虚方法，不过只是call这个类型本身的虚方法，和实例的方法性质一样。另外，call不做null检测。\n\n**Calli** : MSDN上讲是间接调用指针指向的函数。\n\n**Callvirt** : 可以调用实例方法和虚方法，调用虚方法时以多态方式调用，不能调用静态方法。Callvirt调用时会做null检测，如果实例是null，会抛出NullReferenceException，所以速度上比call慢点。\n\n### ProjectAuditor中分析到的指令\n\nNewobj：创建一个值类型的新对象或新实例，并将对象引用（O 类型）推送到计算堆栈上。\n\nNewarr：将对新的从零开始的一维数组（其元素属于特定类型）的对象引用推送到计算堆栈上。\n\nBox：将值类转换为对象引用（O 类型）。\n\nCall：调用由传递的方法说明符指示的方法。\n\nCallvirt：对对象调用后期绑定方法，并且将返回值推送到计算堆栈上。\n\nRet：从当前方法返回，并将返回值（如果存在）从调用方的计算堆栈推送到被调用方的计算堆栈上。\n"
}
