Skip to content

Create a function to automatically compute the value member for an expr node #294

Closed

Description

@certik

Let's start with make_ImplicitCast_t. Let's create a new function make_ImplicitCast_t_value, that will not accept a value argument, but rather compute it automatically based on the other arguments, and return an ImplicitCast node.

We should probably do this for all expr "make" functions and put this code into libasr, that way it can be shared with LFortran.

I think that will clean up both LFortran and LPython quite a bit, as you wouldn't need to worry about value anymore. LFortran already has all kinds of code to fill in the value attribute, and LPython has replicated quite a bit of this. I think this can be extracted into libasr using the above design, thus simplifying both codes.

Activity

  1. Oshanath commented on Mar 27, 2022

    @Oshanath
    Contributor

    @certik There is a question of where to place the new function. For consistency, it should be in the asr.h file and also in the ASR namespace. But to deduce the value of 'value' we need ASRUtils and we cannot include that here since it will be a circular dependency. Any suggestions?

  2. certik commented on Mar 28, 2022

    @certik
    ContributorAuthor

    I would put this into ASRUtils into the libasr directory. And then we can use it in the AST to ASR file like any other function from ASRUtils. I would not modify the automatically generated file asr.h at all. Since this has to be written by hand anyway for each node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions