This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Type-bound procedure and procedure pointer component calls
- From: Daniel Kraft <d at domob dot eu>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Date: Mon, 25 Aug 2008 23:28:58 +0200
- Subject: Re: Type-bound procedure and procedure pointer component calls
- References: <48B19E34.7050709@domob.eu>
Hi,
I've started playing around with calling type-bound procedures, and
here's another, more conservative approach that could do well (maybe the
gfc_callee idea is somewhat "cleaner" but this one will be much easier
to integrate into the existing code):
Add a new ref-type REF_PROC or extend REF_COMPONENT with an attribute to
hold an actual arglist; then in match_varspec, if a component symbol is
found that is in the type-bound procedures namespace, parse an arglist
following it and build such a REF_PROC:
WRITE (*,*) val(1)%tbp_function (42)
will become
EXPR_VARIABLE(val) -> REF_ARRAY(1) -> REF_PROC(arglist(42), gfc_typebound*)
During resolution, we can transform such an expression easily into an
ordinary function call; the passed-object will be given by the
expression itself with the last reference removed, and the other things
needed for the call (the binding-target procedure and the arglist) are
in the REF_PROC.
For CALL's, we could add a new field
gfc_expr* tbp;
to gfc_code. If not NULL it will hold such a reference-expression as
above encapsulating the TBP-call. Once again, during resolution this
will be transformed into an ordinary CALL of a SUBROUTINE.
I think this approach should at least work basically for parsing PPC
calls also if REF_PROC is extended as needed. From resolution onwards
of course PPC's must be handled others than TBP's that can be
transformed into ordinary calls.
What do you think, Janus? And other comments also welcome, of course :)
I'll try to get some basic version of this working and submit a patch
for more details.
Cheers,
Daniel
--
Done: Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go: Hea-Kni-Mon-Pri-Ran-Rog-Tou