OOP and/or Type Bound Procedure question

Jerry DeLisle jvdelisle@frontier.com
Tue Mar 22 01:04:00 GMT 2011


On 03/21/2011 07:12 AM, Mikael Morin wrote:
> On Sunday 20 March 2011 21:01:21 Jerry DeLisle wrote:
>> I have started on Derived Type I/O (User Defined).
>>
>> I have the attached code now accepted by the compiler, but I am not doing
>> any resolution or translation yet.
>>
>> Using gdb I am examining the gfc_expr that represents an instance of the
>> derived type.  No where do I see how or where the procedure pwf is tied to
>> the derived type.  I tried to replace the generic name write(formatted)
>> with just a regular name to see what happens not going through the matcher
>> changes I made and I still cannot find where the procedure is referenced.
>>
>> This being my first venture into this area, I need some hints about where
>> to go look for the type bound procedure.  We are going to need to provide
>> a pointer to this procedure to the run time library to implement the DTIO.
>>
>> TIA,
>>
>> Jerry
>
> If you didn't get the info from Janus (or someone else) yet, I can get you
> started from what I know.
>
> The typebound procedures are accessible from the derived_type_symbol-
>> f2k_derived->tb_sym_root which is a gfc_symtree mapping names (symtree->name)
> to gfc_typebound_proc structs (symtree->n.tb). Those gfc_typebound_proc
> structs have the union u containing either a gfc_symtree pointer to the
> procedure (symtree->n.sym) directly or a gfc_tbp_generic which is basically a
> linked list of gfc_typebound_proc structs. You can see in
> gfc_match_procedure_in_type and gfc_match_generic how those structs are
> filled.
>
> For a typebound function gfc_expr (a = b%func()), the relevant field is the
> value union whose subfield compcall contains the needed info in the gfc_expr-
>> expr_type==EXPR_COMPCALL case. Especially it contains the gfc_typebound_proc
> retrieved (with gfc_find_typebound_proc) from the derived_type's typebound
> procedures symtree cited above. You can see in gfc_match_varspec how the
> gfc_expr is filled, and in resolve_compcall how the values are used.
>
> For calls (call c%sub()) the gfc_code->expr1 field is a EXPR_COMPCALL gfc_expr
> as described above.
>
> I hope you find your way.
> Mikael

Thanks, this should get me going.

Jerry



More information about the Fortran mailing list