-
Notifications
You must be signed in to change notification settings - Fork 12
Simplify the two functions that handle or and and operators #147
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
Simplify the two functions that handle or and and operators #147
Conversation
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 it's fine but I'd like someone else's perspective on how comfortable they are with using higher order functions.
gnat2goto/driver/tree_walk.adb
Outdated
-- -- | ||
-- int intA = (int) A; // 1 | ||
-- int intB = (int) B; // 1 | ||
-- int intC = A | B // bitwise `or` or `and` |
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'd just say bitop
instead of |
followed by // bitop can be bitor, bitand
and theoretically also xor
and things like that.
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.
Good point.
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.
Also, the actual generated code looks more like (bool) ((int) A bitop (int) B)
?
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.
Yes, indeed, I wanted to make it as simple as possible, and try to simulate the sequence of the calls happening inside the function.
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.
Looks good.
fe81ccb
to
58d8907
Compare
And provide some documentation for them.
58d8907
to
4ca60b7
Compare
Instead of having two very similar functions that do the same thing but differ in one line, provide one polymorphic function that calls the appropriate function through a function pointer passed to it. I think this should simplify maintenance in the future.
Also add some documentation.