[gcjx] RFC/RFA: A Simple Pretty-Printer for the AST (WIP)

Tom Tromey tromey@redhat.com
Sun Oct 9 16:36:00 GMT 2005


>>>>> "Ranjit" == Ranjit Mathew <rmathew@gmail.com> writes:

Ranjit>   if (ref_foo_object)
Ranjit>     descend (ref_foo_object.get ());
Ranjit> here and ref_foo.get() is not supposed to be kosher. However,
Ranjit> I had first implemented a descend( const ref_element &bar) which
Ranjit> was working fine till I encountered an owner<model_foo> where
Ranjit> the VALUE was a NULL pointer. In this case, the assert_cast
Ranjit> to convert an owner<model_foo> to owner<model_element> fails
Ranjit> and aborts the program.

Ranjit> I do not know if having an owner<model_foo> with a NULL VALUE
Ranjit> is a genuine bug or a "feature", but this was the reason I had
Ranjit> to drop this variant of the descend() method.

I think ref_foo.get() is fine to use (I suppose despite the comment in
owner.hh.  hmm); it is already used all over the place.  In fact I was
meaning to change the visitor code not to pass ref_ objects at all but
only the unwrapped forms, since it seems to me that we can rely on the
model maintaining ownership of the objects during walking.

A null-valued ref_ object is also fine.  Unfortunately I did not write
the enough documentation comments for this sort of thing... I had
intended to document all the places where null-valued fields are valid
(since not knowing what is valid where is one of the things about gcj
that I find annoying).  This is still on the to-do list.

Anyway, consider something like model_if.  The 'else' branch is
optional and this is expressed by having a null ref_stmt.

Yeah, casting ref_derived to ref_base when the value is null won't
work.  This didn't seem like an important case.  It could be fixed in
the appropriate places in owner<> if need be.

Tom



More information about the Java-patches mailing list