PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

Add support for Calls to StructureType members

Open schreiberx opened this issue 1 year ago • 5 comments

It seems that Fortran functions are not supported by PsyIR.

Please see test_a.zip which creates CodeBlocks for fparser.two.Fortran2003.Function_Reference fparser.two.Fortran2003.Function_Reference fparser.two.Fortran2003.Structure_Constructor

This output has been created with branch https://github.com/stfc/PSyclone/compare/2577_support_pointer_assignments

This might be depending on #2577.

schreiberx avatar May 13 '24 10:05 schreiberx

I tried your code with #2583 PR and I get this: image

Is this what do you see too?

If that's the case, the only parts not supported are the rhs of:

dummy4 => this%foo_function_returning_pointer_oo_style()
varReal = this%foo_function_returning_real_oo_style()
varReal = foo_function_returning_real()

sergisiso avatar May 14 '24 09:05 sergisiso

@arporter for the 3rd one it's fparser that gets it wrong

function foo_function_returning_real()
   real :: foo_function_returning_real
end function
...
varReal = foo_function_returning_real()

the last line is: CodeBlock[[<class 'fparser.two.Fortran2003.Structure_Constructor'>]] Could fparser use its symbol table to identify the right node?

sergisiso avatar May 14 '24 09:05 sergisiso

Potentially, yes. This is probably issue https://github.com/stfc/fparser/issues/255 in fparser.

arporter avatar May 14 '24 09:05 arporter

I tried your code with #2583 PR and I get this: image

Is this what do you see too?

If that's the case, the only parts not supported are the rhs of:

dummy4 => this%foo_function_returning_pointer_oo_style()
varReal = this%foo_function_returning_real_oo_style()
varReal = foo_function_returning_real()

Yes, these 3 red CodeBlocks are what I'm getting.

schreiberx avatar May 14 '24 09:05 schreiberx

I will focus this issue to add support for the structure/derive type calls:

dummy4 => this%field%foo_function_returning_pointer_oo_style(arg1, arg2)
varReal = this%array_field(3)%foo_function_returning_real_oo_style(arg1, arg2)

which need to be converted to a PSyIR Call:

Call
   children[0] "routine" : StructureReference "this%array_field(3)%foo_function_returning_real_oo_style"
   children[1] "arguments[0]" Reference "arg1"
   children[2] "arguments[1]" Reference "arg2"

The 3rd statement from my previous comment, which we need to disambiguate between a Type constructor vs a function call with no arguments will be left for another issue.

sergisiso avatar Jun 19 '24 13:06 sergisiso