-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Short circuit bool ops. #264
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emilyaherbert
previously approved these changes
Sep 23, 2021
sezna
previously approved these changes
Sep 23, 2021
@@ -964,8 +987,8 @@ impl OpVariant { | |||
Divide => "divide", | |||
Multiply => "multiply", | |||
Modulo => "modulo", | |||
Or => "or", | |||
And => "and", | |||
Or => "$or$", |
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 just prevents it from calling the stdlib version?
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.
Why not use &&
and ||
?
A new LazyOperator expression variant is introduced, type-checked and and converted to fairly simple ASM. These operators are no longer allowed to be overridden because they must be evaluated lazily and this can't be enforced with a trait. Instead, they're now compiler intrinsics.
`&&` and `||` are no longer overidable method invocations in std::ops, but rather intrinsic compiler operations.
otrho
force-pushed
the
otrho/226_short_circuit_bool_ops
branch
from
September 24, 2021 00:03
8e7106a
to
6a2d592
Compare
sezna
approved these changes
Sep 24, 2021
adlerjohn
added
the
compiler
General compiler. Should eventually become more specific as the issue is triaged
label
Jan 3, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #226.
I've special cased
&&
and||
to no longer be overriddenstd::ops::...
method invocations and have instead created a newExpression::LazyOperator
variant. It is type checked into aTypedExpression::LazyOperator
which translates to custom ASM gen for the lazy evaluation.Initially I was thinking it could be a special
FunctionApplication
which we detected and special-cased in the ASM gen, but I think this approach is nicer.