[Pharo-dev] Instrumenting field accesses with Opal?

Camille Teruel camille.teruel at gmail.com
Wed Nov 13 10:02:29 EST 2013


On 13 nov. 2013, at 15:18, Andrei Chis <chisvasileandrei at gmail.com> wrote:

> 
> 
> 
> YourClass methods do: [ :method |
> 	method ast 
> 		forAllNodes: [ :node | node isVariable and: [ node isInstance ] ]
> 		putAfter: [ RFMetalink expression: 'Transcript crShow: ''iv accessed''' ];
> 		installWrapper ].
> 
> 
> 
> I tried this code but it fails in the latest version of Reflectivity :)

Neither in old ones, my mistake :)

> First "RFMetalink class(Object)>>doesNotUnderstand: #expression:"

Yes it's #fromExpression:

> then "A variable node on left side of assignment doesn''t accept metalinks"

Indeed
For iv assignment, you should put metalinks on the assignment node.
So it should be something like that:

YourClass methods do: [ :method |
	method ast 
		forAllNodes: [ :node | node isVariable and: [node isRead and: [ node isInstance ] ] ]
		putAfter: [ RFMetalink fromExpression: 'Transcript crShow: ''iv read''' ];
		forAllNodes: [ :node | node isAssignment and: [ node variable isInstance ] ]
		putAfter: [ RFMetalink fromExpression: 'Transcript crShow: ''iv written''' ];
		installWrapper ]
	

>  
>> 		
>> Alexandre
>> -- 
>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>> Alexandre Bergel  http://www.bergel.eu
>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>> 
>> 
>> 
>> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131113/013d3b3d/attachment-0002.html>


More information about the Pharo-dev mailing list