Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: resolution of concrete procedures #339

Open
3 tasks
quepas opened this issue Jul 3, 2024 · 0 comments
Open
3 tasks

Proposal: resolution of concrete procedures #339

quepas opened this issue Jul 3, 2024 · 0 comments

Comments

@quepas
Copy link
Contributor

quepas commented Jul 3, 2024

This is only a proposal. A draft implementation has been prepared here: #340 .

One of the useful information missing in loki is the information about the real function being called when a generic interface is used:

...
interface swap
        module procedure swap_int, swap_real
end interface swap
...

Then, called somewhere else:

real :: r1, r2
...
! Loki knows it is a "generic" procedure, but that's all 
call swap(r1, r2)

Currently, in the CallStmt, loki points to a dtype with a procedure of DEFERED type. This PR adds capability of figuring out the concrete function really called (in some easy cases). The resolution mechanism tries to match parameters of each concrete function with arguments passed to the generic function call. Of course, the whole resolution is conservative (as everything in compilers! :D) and additional information is added only when everything matches.

The matching is based on the ExpressionDimensionsMapper and a new ExpressionTypeMapper which takes a piece of the AST and tries to deduce it's final type. This mapper is not very capable, it works well on typed variables, literals and some easy expressions (with sum op).

We weren't sure if we should populate the procedure with the concrete routine in the ProcedureType, so we have added an additional field concrete_procedure which points to the concrete procedure when a generic is used, and the normal procedure otherwise.

I am looking forward to your comments and the discussion of this feature.

Things to do:

  • Implementation for other parsers
  • More capable ExpressionTypeMapper
  • More unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant