如何获取正在执行的编译方法 [英] How to get the compiled method the is being executed

查看:45
本文介绍了如何获取正在执行的编译方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取当前正在执行的 CompiledMethod 实例?

How to get an instance of CompiledMethod that is currently being executed?

someMethod
  | thisMethod |
  thisMethod := "here I want to access an instance of _CompiledMethod_ that refers to #someMethod".
  ^ thisMethod selector

推荐答案

当前正在执行的方法可以通过#method消息从当前上下文中获取,可以通过thisContext访问 伪变量.

Method that is currently being executed can be retrieved by #method message from current context, which can be accessed through thisContext pseudo variable.

这样的示例代码将如下所示:

This way example code will look like this:

someMethod
  | thisMethod |
  thisMethod := thisContext method.
  ^ thisMethod selector

这篇关于如何获取正在执行的编译方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆