[Mesa-dev] [PATCH 1/3] glsl: add ir_partial_visitor

Eric Anholt eric at anholt.net
Wed Sep 8 09:20:08 PDT 2010


On Tue, 07 Sep 2010 13:08:37 -0700, Ian Romanick <idr at freedesktop.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Luca Barbieri wrote:
> > Well, the alternative is to copy&paste this into ir_lower_jumps and
> > other similar passes.
> > 
> > I added a new class instead of changing ir_visitor so that subclasses
> > that need to examine all leaves will get a compile error if not
> > updated when new leaves are introduced. This is debatable though,
> > since you need to add the function to ir_visitor anyway.
> 
> The problem with the default navigation is that code breaks in
> mysterious ways when new node types are added.  We've encountered this a
> couple times with the hierarchical visitor.  If the visitor base class
> is pure virtual, the compiler will tell you all the places that need to
> be updated when a new node type is added.  The cases where we've had
> this problem with the hierarchical visitor have been a bitch to debug.
> The extra bit of cut-and-paste seems like a small price to pay.

The only value I've seen from the pure virtual methods is that you don't
mis-type them (which is a problem I've had with the HV, since the
signatures don't all match).  People would still regularly cut-and-paste
the wrong junk in to make the compile succeed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20100908/cd6bae49/attachment.pgp>


More information about the mesa-dev mailing list