This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [gcjx] Generalise visitor
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: java-patches at gcc dot gnu dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Fri, 7 Oct 2005 09:15:15 +0530
- Subject: Re: [gcjx] Generalise visitor
- References: <di3nru$91s$1@sea.gmane.org> <m3oe62gnun.fsf@localhost.localdomain>
- Reply-to: Ranjit Mathew <rmathew at gmail dot com>
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/