Instantiating generic functions into valid functions in ASR (3rd week)

luthfan
Published: 07/01/2022

I made some good progress this week in handling generic functions on LPython's ASR level.

What I did this week

I managed to get the type parameters in the generic functions to be instantiated by different function calls. Currently, I'm working with a very simple function f that can take two values x and y of type T and returns a value of type T.

T = TypeVar('T')

def f(x: T, y: T) -> T:
  return x + y

This function is called in two different places with different types. First with integers, second with floats.

print(f(1,2))
print(f(1.0,1.0))

This week I managed to have each function call generates a new overloaded function for f. It also checks the consistencies of the assigned types and the type parameters.

What is coming up next week

Next I have to also handle the function calls themselves, because they technically are calling overloaded functions. LPython actually have already supported function overloading, so what I need to do is to learn the compiler and apply that overloading to these generic function calls.

Did I get stuck anywhere

Nowhere especially for this week.

DJDT

Versions

Time

Settings from gsoc.settings

Headers

Request

SQL queries from 1 connection

Static files (2312 found, 3 used)

Templates (11 rendered)

Cache calls from 1 backend

Signals

Log messages