Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feature: add support for typecasting #27
feature: add support for typecasting #27
Changes from 4 commits
66d5459
8a09bdd
3f63229
17cd488
0ca1252
16fe026
c477d76
d64bfad
638d3dd
129af14
a158117
f71190d
52f99f1
f50afec
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This doesn't look right. I would expect the output IR to contain something like:
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.
For debugging, might be interesting to know what the IR output is if you modify the program to be like this:
or like this:
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 checked and using
results in the same IR. I think the discrepancy came from the fact that the variable
test
was not being used after declared. Your second suggestion helped me realize that addingreturn test
(or other lines that make use oftest
) results in an IR with the int[32] lines. I updated the unit test to reflect this.On a second note, I did not add support for arithmetic operations on BitVara in this PR because I focused on int typecasting. To add the arithmetic operations, would you suggest I add methods like
__mul__
and__rmul__
to theBitVar
class (whereself
gets casted to anIntVar
) or use a converter to intercept the arithmetic operations and cast the BitVars to IntVars?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.
Oh, good question. I think it's ok to leave out the arithmetic operations from this PR. I think it's ok (and maybe desirable) that the user must manually cast the BitVar to an int before doing arithmetic on it.