This is the code that uses assignmentNodes:

        ((Point slotNamed: #x) assignmentNodes collect: [ :each | each 
methodNode compiledMethod ] ) asSet

But as a downside, it has to create the AST. 

So maybe better is to use the API of the Variable:

        Point methods select: [ :each | (Point slotNamed: #x) isWrittenIn: each 
]

This is implemented to scan on the bytecode level for InstanceVariableSlot and 
thus is much faster:

        InstanceVariableSlot>>#isWrittenIn:
                ^aCompiledCode writesField: index


> On 28 Jun 2025, at 00:38, steven.cost...@kloum.io wrote:
> 
> Yes, to a variable (so including slots and all) you can ask readNodes and 
> assignmentNodes (accessingNodes gives both).
> It gives nodes from the AST, but from there you can obtain the methods and 
> everything.
> 
> Le 27.06.2025 22:27, Aik-Siong Koh a écrit :
>> A variable can have references.
>> Those references can be split into readers and writers of the variable.
>> Can Pharo list readers and writers separately?
>> Thanks,
>> Aik-Siong Koh

Reply via email to