Skip to content

Initial implementation of lpython builtin module #130

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

Merged
merged 24 commits into from
Feb 20, 2022

Conversation

namannimmo10
Copy link
Collaborator

Originally taken from #1 (comment)

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call it lpython_builtin.py.

@certik
Copy link
Contributor

certik commented Feb 11, 2022

Now we need to import this automatically when chr is encountered in AST to ASR and call it.

@namannimmo10 namannimmo10 changed the title Initial implementation of lfortran builtin module Initial implementation of lpython builtin module Feb 11, 2022
@certik
Copy link
Contributor

certik commented Feb 11, 2022

That looks good. The tests fail, so that needs to be fixed.

@certik
Copy link
Contributor

certik commented Feb 14, 2022

The load_module function has to accept the main (global) TranslationUnit and it will use it to:

  • on "import A" it will lookup the global TranslationUnit for a module A and use it (construct ExternalSymbols from it), otherwise it will recursively call itself to import A, and then use it
  • Once it's done importing a given module, it will save it to the global TranslationUnit

Let's open up a new issue for this.

namannimmo10 and others added 6 commits February 18, 2022 12:50
It imports the builtin module and puts the "ord" as an external symbol and
calls it. But currently it fails verify. To test:

lpython --show-asr integration_tests/test_builtin.py
@certik
Copy link
Contributor

certik commented Feb 19, 2022

It should work now. The strings in ord and chr are not always implemented in the LLVM backend, so we can't actually run it, but the ASR looks pretty good. I need to implement some intrinsic function that actually works in LLVM, then we can properly test it.

@certik
Copy link
Contributor

certik commented Feb 19, 2022

I implemented abs() to load our own function. It seems to work now. The compile time value is not implemented yet, we'll do it in a subsequent PR. Finally, we really have to refactor this to follow LFortran's design.

@namannimmo10
Copy link
Collaborator Author

namannimmo10 commented Feb 20, 2022

I think this should be ready to go in -- we can complete the remaining tasks in upcoming PRs. Thanks for working on it with me

@certik certik merged commit e1b2778 into lcompilers:main Feb 20, 2022
@certik
Copy link
Contributor

certik commented Feb 20, 2022

This approach now needs to be refactored like in LFortran.

@namannimmo10 namannimmo10 deleted the builtin branch February 20, 2022 16:39
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

Successfully merging this pull request may close these issues.

2 participants