[gcjx] Generalise visitor
Ranjit Mathew
rmathew@gmail.com
Fri Oct 7 03:45:00 GMT 2005
On 06 Oct 2005 18:41:36 -0600, Tom Tromey <tromey@redhat.com> wrote:
> >>>>> "Ranjit" == Ranjit Mathew <rmathew@gmail.com> writes:
>
> Ranjit> The new methods are not exhaustive, but it's a start - technically,
> Ranjit> I could have just added visit() to model_element and a visit_element()
> Ranjit> to visitor and be done with it. However, I've attempted to declare
> Ranjit> a few more. The implementations of the methods are dummies for now.
>
> Ideally model_element::visit would be abstract. Presumably there are
> still other elements that aren't handled?
Yes, that's how I had started. But parse::compilation_unit()
actually creates an object of type model_element. Yes, there
are model elements that are not covered, but we can add them
as and when needed.
> Ranjit> + virtual void visit (visitor *);
>
> I usually don't reiterate the 'virtual'.
I've checked in the patch without these extraneous "virtual".
> Ranjit> + void visit_forwarding_type (model_forwarding_type *,
> Ranjit> + const model_type *)
> Ranjit> + {
> Ranjit> + // Nothing.
> Ranjit> + }
>
> We should have mixins that implement different subsets of the
> visitors, either as do-nothings or abort()s (or either -- write the
> mixin as a template). It seems to me that often a given visitor
> really only wants to deal with some subset of the model.
>
> In fact I considered doing this already, since fold already only wants
> to visit expressions, not statements.
I agree. However, at this stage I just wanted to get in stuff
that will help me in my nefarious plan to implement dump_tree().
Thanks,
Ranjit.
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/
More information about the Java-patches
mailing list