IL操作码修改

发布于 2024-08-20 05:36:40 字数 559 浏览 2 评论 0原文

语言:VB.NET 3.5

IL 操作码:

    718 ldarg.0 
    719 callvirt    System.Windows.Forms.Button RClient.RClient::get_cmd1()
    724 ldarg.0 
    725 ldfld       System.String[] RClient.RClient::ButtonStrings
    730 ldc.i4.5    
    731 ldelem.ref  
    732 callvirt    System.Void System.Windows.Forms.ButtonBase::set_Text(System.String)
    737 ldarg.0 

对应于:

Me.cmd1.Text = Me.ButtonStrings(5)

至少我相信是这样。 我必须对 IL 进行哪些更改才能反映这一点:

Me.cmd1.Text = "some string"

Language: VB.NET 3.5

IL opcodes:

    718 ldarg.0 
    719 callvirt    System.Windows.Forms.Button RClient.RClient::get_cmd1()
    724 ldarg.0 
    725 ldfld       System.String[] RClient.RClient::ButtonStrings
    730 ldc.i4.5    
    731 ldelem.ref  
    732 callvirt    System.Void System.Windows.Forms.ButtonBase::set_Text(System.String)
    737 ldarg.0 

Corresponds to:

Me.cmd1.Text = Me.ButtonStrings(5)

At least I believe it does.
What changes to the IL would I have to make to reflect this instead:

Me.cmd1.Text = "some string"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2024-08-27 05:36:40
ldarg.0 
callvirt    System.Windows.Forms.Button RClient.RClient::get_cmd1()
ldstr      "some string"
callvirt    System.Void System.Windows.Forms.ButtonBase::set_Text(System.String)

第 1 行将 Me 压入堆栈。第 2 行执行方法 get_cmd1,该方法对应于堆栈顶部对象的属性 cmd1 的 getter。因此,这一行将 getter cmd1 的结果从栈顶的对象中压入,从而在进程中弹出栈顶。第 3 行将字符串 "some string" 压入堆栈。此时,堆栈顶部是字符串 "some string",堆栈中的下一项是 Me.cmd1。第 4 行执行方法 set_Text,字符串参数位于堆栈顶部。这对应于堆栈上第二个项目的 Text 设置器。堆栈上的第二项是 Me.cmd1。因此这些行相当于 Me.cmd1.Text = "some string"

ldarg.0 
callvirt    System.Windows.Forms.Button RClient.RClient::get_cmd1()
ldstr      "some string"
callvirt    System.Void System.Windows.Forms.ButtonBase::set_Text(System.String)

Line 1 pushes Me onto the stack. Line 2 executes the method get_cmd1 which corresponds to the getter for the property cmd1 for the object on the top of the stack. So, this line pushes the result of the getter cmd1 from the object on the top of the stack, popping the top of the stack in the process. Line 3 pushes the string "some string" on the stack. At this point the top of the stack is the string "some string" and the next item on the stack is Me.cmd1. Line 4 executes the method set_Text with string parameter being the top of the stack. This corresponds to the setter for Text for the second item on the stack. The second item on the stack is Me.cmd1. So these lines are equivalent to Me.cmd1.Text = "some string".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文