Visiting Nodes
Guido Chari
charig at gmail.com
Sat May 2 13:31:43 UTC 2015
Hi Christian and Stefan,
@Stefan Thanks, sure it helps.
Anyway i was thinking on having the possibility to implement a different
visit method for my different kind of nodes. I understand what you said
christian about ensuring visiting all nodes. But with this restriction, my
visitor always receive as a parameter a Node. This mean I cannot implement
the visitNodeType1, visitNodeType2 methods that i think is the standard
scheme for the pattern. The workaround is to put instanceOf in a generic
visitor and delegate then to particular implementations but does not seem
as a tidy solution. So summarizing, my use case would be that i need a
different visit method implementation for each kind of node.
Best,
Guido.
2015-05-01 16:45 GMT-03:00 <christian.humer at gmail.com>:
> Hi Guido,
>
> Node#accept is final because we want to guarantee that all nodes annotated
> with @Child and @Children are visited. Can you give me some more details on
> your use-case? Adding or replacing nodes can be done using the Node#replace
> and Node#insert methods.
> - Christian Humer
>
>
>
>
>
> ------ Original Message ------
> From: "Guido Chari" <charig at gmail.com>
> To: graal-dev at openjdk.java.net
> Sent: 01.05.2015 17:17:54
> Subject: Visiting Nodes
>
> Hi,
>>
>> I am extending TruffleSOM and i need a post-processing over the AST. I
>> would like to implement a visitor that add nodes with my particular
>> behavior after compilation. But then i realized the accept method on Node
>> is declared as final. Wouldn't it be better to allow subclassing the
>> accept?
>>
>> Best,
>> Guido.
>>
>
>
More information about the graal-dev
mailing list