IL 语法分析
Managed Heap: GC auto manage. One process, One heap.
Call Stack: Runtime auto manage, every time when you call a method, the Record frame+1.
Record Frame save the
Method Parameter
andReturn Address
andLocal Variable
Evaluation Stack: Every Thread.
ldc.i4.1
: Put a 4 byte with value 1 to Evaluation Stack.
stloc.0
: Retrieve a value from Evaluation Stack then put it to Call Stack Record Frame V0 and set V0 = 1
stloc
Retval is an instruction that takes the result of the call to sscanf from the stack and stores it in the local
variable Retval. We need to save this value in
a local variable because we will need it later.
ldloc.0
: Put V0 to Evaluation Stack
ldloc Retval copies
the value of back onto the stack. We
need to check this value, which was taken off the stack by the instruction.Retvalstloc
box [mscorlib]System.Int32
: Retrieve a value from Evaluation Stack, then box this value type to reference type and put it to Managed Heap.
ldstr "i+j+k"
: Put the "i+j+k" reference to Evaluation Stack from Managed Heap.
ldstr “Enter a number”
is an instruction that loads the specified string constant onto the
stack. The string constant in this case is stored in the metadata. We can refer
to such strings as common language runtime string
constants or metadata string constants. You can
store and handle the string constants in another way, as explained in a few
moments, but ldstr deals exclusively with
common language runtime string constants, which are always stored in Unicode
format
call string [mscorlib] System.String::Concat(object, object)
: 從 Evaluation Stack 中取出兩個值,此二值皆為 Reference Type,下面的值當作第一個參數,上面的值當作第二個參數,呼叫 mscorlib.dll 所提供的 System.String.Concat() method 來將此二參數進行字串接合(String Concatenation),將接合出來的新字串放在 Managed Heap,將其 Reference 放進 Evaluation Stack。值得注意的是:由於 System.String.Concat() 是 static method,所以此處使用的指令是 call,而非 callvirt(呼叫虛擬)
ret
: End this call.
IL 语法分析的更多相关文章
- IL异常处理
异常处理在程序中也算是比较重要的一部分了,IL异常处理在C#里面实现会用到一些新的方法 1.BeginExceptionBlock:异常块代码开始,相当于try,但是感觉又不太像 2.EndExcep ...
- CLR via C# 摘要二:IL速记
最简单的IL程序 .assembly test {} .method void Func() { .entrypoint ldstr "hello world" call void ...
- IL实现简单的IOC容器
既然了解了IL的接口和动态类之间的知识,何不使用进来项目实验一下呢?而第一反应就是想到了平时经常说的IOC容器,在园子里搜索了一下也有这类型的文章http://www.cnblogs.com/kkll ...
- IL接口和类的属性
上一篇文章学习了IL的入门,接下来我们再通过两个例子来了解下类的属性.构造函数以及接口的使用 一.类的属性.构造函数 1.先看下我们要构建的类的C#代码,然后再进行IL的实现,示例代码如下: [Ser ...
- IL初步了解
一.概述: 近来也是在看AOP方面的东西,了解到Emit可以实现.之前对Emit的了解也就是停留在Reflector针对方法反编译出来的部分指令.就用这次机会学习下Emit也用这篇随笔记录下学习的过程 ...
- Linux源码Kconfig文件语法分析
Kconfig是我们进行内核配置的关键文件,用于生成menuconfig的界面并生成最终确定编译选项的.config文件.关于Kconfig文件的编写规则,在Documentation/kbuild/ ...
- 【转】fatal error C1900: “P1”(第“20081201”版)和“P2”(第“20080116”版)之间 Il 不匹配
转自:这里(然而这里并没有写原出处) 背景:今天傻逼逼地想用vs2010来编译一个vs2013的项目,其中这个项目用到了一个库(应该是用2013编译的) 在我浅薄的认知中,以为只是13支持的特性更多, ...
- VS2012 集成 IL DASM IL微软中间语言查看器
第一步: 找到IL DASM的安装位置,默认在C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools 第二步: ...
- 跟vczh看实例学编译原理——三:Tinymoe与无歧义语法分析
文章中引用的代码均来自https://github.com/vczh/tinymoe. 看了前面的三篇文章,大家应该基本对Tinymoe的代码有一个初步的感觉了.在正确分析"print ...
随机推荐
- go语言中map每次遍历的顺序不同-问题分析
WHAT? 发现下面这段代码,多次运行出的结果是不一样的 mapper := make(map[int]string) mapper[1] = "1" mapper[2] = &q ...
- go开发注意事项和dos的一些操作
不需要加分号 写法 go编译器一行一行编译,所以多条语句不能写在同一行,否则会报错 go语言定义的变量或者import的包如果没有使用到,代码不能通过编译 func main() { ... } 只能 ...
- TOTP算法实现二步验证
概念 TOTP算法(Time-based One-time Password algorithm)是一种从共享密钥和当前时间计算一次性密码的算法. 它已被采纳为Internet工程任务组标准RFC 6 ...
- django9-ajax
1.ajax 局部刷新 ,不可能每次提交请求刷新整个页面 2.ajax实例 在不刷新整个的情况下完成计算器 ,ajax的post需要添加csrftoken 1)设置一个组件ajaxcsrf.html ...
- 一则SQL优化案例
原始sql: select CASE ) counts ,) else deadline end as deadline from t_product_credit) c group by sort ...
- 配置flutter For IOS
https://www.cnblogs.com/lovestarfish/p/10628205.html 第一步,下载flutter最新版,解压到自己的目录里: 提供网址:https://flutte ...
- 4.智能快递柜(通信篇-SOCKET)
1.智能快递柜(开篇) 2.智能快递柜(终端篇) 3.智能快递柜(通信篇-HTTP) 4.智能快递柜(通信篇-SOCKET) 5.智能快递柜(通信篇-Server程序) 6.智能快递柜(平台篇) 7. ...
- 8.JavaCC官方入门指南-例3
例3:计算器-double类型加法 下面我们对上个例子的代码进行进一步的修改,使得代码具有简单的四则运算的功能. 第一步修改,我们将打印出每一行的值,使得计算器更具交互性.一开始,我们只是把数 ...
- Shell命令-系统信息及显示之df、top
文件及内容处理 - df.top 1. df:报告文件系统磁盘空间的使用情况 df命令的功能说明 df 命令用于显示目前在Linux系统上的文件系统的磁盘使用情况统计. df命令的语法格式 df [O ...
- 爬虫---爬取b站小视频
前面通过python爬虫爬取过图片,文字,今天我们一起爬取下b站的小视频,其实呢,测试过程中需要用到视频文件,找了几个网站下载,都需要会员什么的,直接写一篇爬虫爬取视频~~~ 分析b站小视频 1.进入 ...