-
Notifications
You must be signed in to change notification settings - Fork 164
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
Added support for functions to accept symbolic variables #2331
Added support for functions to accept symbolic variables #2331
Conversation
An example for reference
|
Can you add a test for this? |
I think so maybe we would need a
Where we are passing |
Just add a test for the feature you implemented in this PR, and later once you implement |
Yes, I think so I can implement the case for |
Also I am not sure why do we get an error through the
The C backend works perfectly
@Thirumalai-Shaktivel would you mind helping me out here. Once this is fixed the failing |
I think you have to cast the second argument from i32 to i64. As you can see, declare void @integer_set_si(void*, i64)
...
%3 = load i32, i32* %i, align 4
call void @integer_set_si(void* %2, i32 %3)
... In C, I think there might be an implicit cast for i32 to i64, so it works. |
Oops, sorry I think so I overlooked this. Thanks for the help ! |
I have a few doubts regarding few corner cases, hence converting to draft. |
I think this is ready now. |
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 good. Thanks!
Now that we have started porting sympy functions to LPython, I realized that there are some errors while trying to have symbolic parameters. Consider the following program
If we look at the C code generated for this.
But this would end up giving a segmentation fault, we don't need to apply the transformations which we apply on local variables (
a
in this case) to the parameterized variable (x
in this case). Something as simple as the following would do the job.Hence the changes introduced are the following
x: S
is being changed tox: CPtr
to replicate the void pointer (printsym(void* x)
)Here
a
should be freed but freeing ofx
has been taken care inmain0