Type-bound procedure and procedure pointer component calls

Daniel Kraft d@domob.eu
Tue Aug 26 16:25:00 GMT 2008


Hi again,

here's the promised experimental patch implementing the approach 
sketched below.  It handles basic calls to NOPASS type-bound procedures 
(the typebound_call_1.f03 test included in the patch).

Apart from this, is it of course quite rough; no module IO, no 
passed-object handling and nearly no error checking for calls, no 
dynamic dispatch (of course)...  But I hope you get the idea of how the 
general design could be.

Janus, what do you think in respect to PPCs?  I think it should be 
"rather" easy to extend the current patch to support those:

Extend gfc_match_varspec and the gfc_ref structure to match them and 
store their data and then hook either into the resolving methods to 
handle your implementation or make the static-resolving conditional and 
handle EXEC_COMPCALL/EXPR_COMPCALL in the PPC case during trans somehow.

What do you think?

Daniel

Daniel Kraft wrote:
> 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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080826/c455c207/attachment-0001.ksh>


More information about the Fortran mailing list