Week6 - Implement Entry & Bug Fixes

Implement Entry & Bug Fixes

Date: June 25, 2023.

Hii! Welcome to the sixth blog of my GSoC '23 journey. This week I majorly focused on implementation of Entry and some bug fixes.

An entry point in Fortran allows multiple entry functions to be defined within a program, each with its own unique name. These entry points can be invoked independently, providing different paths of execution within the program. This feature is particularly useful when dealing with large and complex programs that require different behaviors or computations based on specific conditions.

Let us take a small example to understand it better:

The above given code simply translates to:

So the implementation was fairly simply, when compiler encounters entry statement in the body, we create a subroutine if parent is subroutine or function if parent is function. Thereafter a hash map is maintained to track all the statements that are part of entry function, and a vector of active_entry_functions is maintained to keep track of all the entry functions that are active. Once we are done with populating body of parent function, compiler checks if there are any active functions, if yes then it iterates over all active functions and populates their body. More details about implementation can be found in PR: 1866

Apart from this I worked on Issue: 1839 this one was related to updating arguments of subroutine call and function after creating correct interface for external function. For this I implemented a update args visitor which iterates over entire generated ASR till now and checks if there is any mismatch of symbols present in subroutine call and function args, if yes then it replaces it correctly. This was done at PR: 1846.

All in all with 17.5 hours of work I was able to implement Entry statement and made external procedure handling robust. For the next week I am planning to get `min0`, `max0` implemented as this is blocking quite a few files to compile to ASR. Along with that I will check if there are any bugs that I can fix.

I would like to thank Ondřej Čertík for taking out time and helping me when I was stuck. Looking forward to many more commits.