Skip to content

search: revamp visitor internals

Administrator requested to merge rvt/vistor-revamp into master

Created by: rvantonder

This is a revamp of the visitor internals that allows overriding methods for specific visitor functions, in the same flavor as #9752. This simplifies Visit and VisitNode functions from before (now there is only VisitNodes).

It's awkward trying to do method overrides in Go in the presence of mutual recursion, where you end up with visitor.<method-call>(pass-visitor-as-this, <other things>). Without the recursion part, method overrides is not as weird. After looking into things in various places, this is the best I came up with and I'm happy with it. Now though, the visitor has to get its own state for the callback, because there doesn't appear to be a way to create a closure over a new type/struct that implements a method override. Anyway, it's an improvement on the previous implementation that'll simplify other things.

Existing tests cover this change.

Merge request reports

Loading