[Pharo-dev] [Spy] How to inject code *inside* a method
marcus.denker at inria.fr
Fri Dec 6 04:35:00 EST 2013
On 06 Dec 2013, at 10:01, Roberto Minelli <roberto.minelli at usi.ch> wrote:
> Hi guys,
> I am using Spy for my project, and I need to do something which, on top of my knowledge, is not supported.
> Here is the point: Spy allows to insert code before (#beforeRun:with:in:) and after (#afterRun:with:in:) and works perfectly.
> Now suppose I want to inject some code *inside* the method, e.g.,
> do something
> "Injected code accessing some fields of the current instance of this object”
> Transcript show: self field asString.
> Is there any support for this?
Sadly not yet… we plan to have real support for this in Pharo4.
The AOP solutions (both AspectS and Phantom) do *not* support point cuts on sub-method
concepts like “instance variable access”.
The stuff I did for my PhD supports this quite nicely… but that I have not yet ported to Pharo.
(The idea is to do an “engineering grade” pass over this and put it in Pharo not as a research
prototype but as a real, production ready concept).
I really need to push this… people need it.
There is a way to do all this on a lower level (e.g. AST transformation or IR transformation)… I will write a mail how to
do that later the weekend.
More information about the Pharo-dev