-
Notifications
You must be signed in to change notification settings - Fork 171
Added IntrinsicFunction in grammar #1616
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
Conversation
@anutosh491 do you need any help in completing this PR? I think, these PR changes have to be merged: |
@Thirumalai-Shaktivel Please go ahead and push all the necessary changes here. Please add LPython tests also if necessary. |
I will try to complete this tomorrow. @anutosh491 thanks for opening a PR for this. |
Sure, would be a good addition to have here ! |
I implemented IntrinsicFunction for the built-in Review this commit: 80c59fd and bc505b3 What are your thoughts on this? @certik @czgdp1807 @Smit-create |
ce0b35b
to
81360d6
Compare
dd498f9
to
4783466
Compare
I am just curious about a few things , which I would like to point out here .
It goes like this
Here do we expect |
or just
gives .
It's counterpart, LFortran works perfectly in this case ! |
Yup,
|
I'm not sure about this, but I think the @certik @czgdp1807 Am I correct? |
$ python examples/expr2.py
Traceback (most recent call last):
File "/Users/thirumalai/Open_Source/lpython/examples/expr2.py", line 4, in <module>
main0()
File "/Users/thirumalai/Open_Source/lpython/examples/expr2.py", line 2, in main0
print(sin(0.5))
NameError: name 'sin' is not defined. Did you mean: 'bin'? |
Ohhh so
Edit : Ahh my bad , I realize that's the error which we should be returning , what you've pointed out ! |
I think we have to intercept |
I see, but because currently the |
}; | ||
|
||
static inline bool is_intrinsic_function(const std::string& name) { | ||
return intrinsic_function_by_name_db.find(name) != intrinsic_function_by_name_db.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put a check for "sin" here, and ignore everything else for now, and use existing LPython mechanism for those. Let's get "sin" working in this PR, merge it. Then we can add more functions, one by one.
@@ -6106,7 +6123,20 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> { | |||
} | |||
|
|||
if (!s) { | |||
if (intrinsic_procedures.is_intrinsic(call_name)) { | |||
if (ASRUtils::IntrinsicFunctionRegistry::is_intrinsic_function(call_name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do it here instead, that way libasr
stays the same.
"If sin
, then something, otherwise original."
LPython doesn't have |
I'm currently working on this: #1616 (comment). After completing that I will finish this PR. |
Great. After that I will do the sync (on Tuesday). |
@Thirumalai-Shaktivel so |
Almost completed, @czgdp1807 after that you can review and merge this. |
This PR is ready! There are some changes in libasr here, I will submit another PR for it there. |
Please do it right away. We will merge both PRs together. I hope they aren't big changes? |
Thanks, for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is fine.
Co-authored-by: Thirumalai-Shaktivel <thirumalaishaktivel@gmail.com>
As I've been working on #1607 (comment) , which requires LPython to support
IntrinsicFunction
asexpr
. It seems it would also help us out at other places like #1606 (review) .