Instrumenting field accesses with Opal?
Hi! Is there a way to get notified when fields are accessed? That would be awesome Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On 13 nov. 2013, at 14:21, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi!
Is there a way to get notified when fields are accessed? That would be awesome
You can use the current reflectivity prototype. It's on RMoD CI: https://ci.inria.fr/rmod/job/Reflectivity/ It should look like something like that: YourClass methods do: [ :method | method ast forAllNodes: [ :node | node isVariable and: [ node isInstance ] ] putAfter: [ RFMetalink expression: 'Transcript crShow: ''iv accessed''' ]; installWrapper ].
Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On 2013-11-13, at 14:42, Camille Teruel <camille.teruel@gmail.com> wrote:
On 13 nov. 2013, at 14:21, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi!
Is there a way to get notified when fields are accessed? That would be awesome
You can use the current reflectivity prototype. It's on RMoD CI: https://ci.inria.fr/rmod/job/Reflectivity/ It should look like something like that:
YourClass methods do: [ :method | method ast forAllNodes: [ :node | node isVariable and: [ node isInstance ] ] putAfter: [ RFMetalink expression: 'Transcript crShow: ''iv accessed''' ]; installWrapper ].
In the end we should be able to just use the Slot MOP ;)
On 13 Nov 2013, at 14:44, Camillo Bruni <camillobruni@gmail.com> wrote:
On 2013-11-13, at 14:42, Camille Teruel <camille.teruel@gmail.com> wrote:
On 13 nov. 2013, at 14:21, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi!
Is there a way to get notified when fields are accessed? That would be awesome
You can use the current reflectivity prototype. It's on RMoD CI: https://ci.inria.fr/rmod/job/Reflectivity/ It should look like something like that:
YourClass methods do: [ :method | method ast forAllNodes: [ :node | node isVariable and: [ node isInstance ] ] putAfter: [ RFMetalink expression: 'Transcript crShow: ''iv accessed''' ]; installWrapper ].
In the end we should be able to just use the Slot MOP ;)
or put a link on the slot object instead of all the AST nodes of accesses. Marcus
On 13 nov. 2013, at 14:51, Marcus Denker <marcus.denker@inria.fr> wrote:
On 13 Nov 2013, at 14:44, Camillo Bruni <camillobruni@gmail.com> wrote:
On 2013-11-13, at 14:42, Camille Teruel <camille.teruel@gmail.com> wrote:
On 13 nov. 2013, at 14:21, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi!
Is there a way to get notified when fields are accessed? That would be awesome
You can use the current reflectivity prototype. It's on RMoD CI: https://ci.inria.fr/rmod/job/Reflectivity/ It should look like something like that:
YourClass methods do: [ :method | method ast forAllNodes: [ :node | node isVariable and: [ node isInstance ] ] putAfter: [ RFMetalink expression: 'Transcript crShow: ''iv accessed''' ]; installWrapper ].
In the end we should be able to just use the Slot MOP ;)
or put a link on the slot object instead of all the AST nodes of accesses.
Yes it will be more concise and high-level (even if behind the scenes, the same thing happens) It will be for Pharo 4.0, an awesome release for sure :)
Marcus
Hi!
Is there a way to get notified when fields are accessed? That would be awesome
You can use the current reflectivity prototype. It's on RMoD CI: https://ci.inria.fr/rmod/job/Reflectivity/ It should look like something like that:
YourClass methods do: [ :method | method ast forAllNodes: [ :node | node isVariable and: [ node isInstance ] ] putAfter: [ RFMetalink expression: 'Transcript crShow: ''iv accessed''' ]; installWrapper ].
In the end we should be able to just use the Slot MOP ;) so cool :)
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 :) First "RFMetalink class(Object)>>doesNotUnderstand: #expression:" then "A variable node on left side of assignment doesn''t accept metalinks"
Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On 13 nov. 2013, at 15:18, Andrei Chis <chisvasileandrei@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 ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Thanks for discussing this issue. This is really interesting! Alexandre On Nov 13, 2013, at 12:02 PM, Camille Teruel <camille.teruel@gmail.com> wrote:
On 13 nov. 2013, at 15:18, Andrei Chis <chisvasileandrei@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 ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
participants (6)
-
Alexandre Bergel -
Andrei Chis -
Camille Teruel -
Camillo Bruni -
Marcus Denker -
Stéphane Ducasse