How to get the compiled method the is being executed

痴心易碎 提交于 2019-12-07 17:07:31

问题


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

i.e.

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

回答1:


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


来源:https://stackoverflow.com/questions/24738561/how-to-get-the-compiled-method-the-is-being-executed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!