Repository navigation
Conversation
| /// * Using the unadjusted expression in any other context is not possible (might be invalid C#, | ||
| /// might have incorrect semantics). | ||
| /// * for other AdjustmentKind values: | ||
| /// * |
…e difference between the translated C# expression and the original IL instruction. The idea here is that we allow refactoring the expression builder method-by-method: legacy Visit* overloads can continue returning according to the old post-condition and Translate() will inject the necessary adjustments. Includes a bugfix where `binary.sub.ref(a, b)` (as in Unsafe.ByteOffset) was interpreted to have return type `Ref`, when it should be `I`.
… roundtrip-tests to fail.
This branch has not been deployed
This file contains hidden or 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
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.
The ExpressionBuilder previously had a complex post-condition: an ILInstruction with
StackType.I(nint) could actually be translated into a C# expression with typeintorlong, as long as after a cast tonintthe value would match that computed by the original instruction.This PR introduces the idea of calling this mismatch between C# and ILAst semantics an "adjustment", and represents it explicitly within TranslatedExpression.
This comes with a new set of methods on TranslatedExpression that effectively abstract over the (C# expression + adjustment) combination -- for example adding additional casts on top of it (merging those casts with the existing adjustment when possible).
This initial PR introduces the idea and uses it in
VisitConv.Next steps (in follow-up PRs):
ExpressionBuilderfrom the old API to the new APIConvertTo-- this method could do many kinds of conversions and in some edge cases it could be unclear what kind of conversion it would be doing. It will be replaced by multiple more focused methods.ExpressionBuilder.Visit*functions are migrated to this new API, it will be possible to introduce more kinds of adjustments -- for example, boxing conversions. All cases whereConvertTo(allowImplicit: true)currently removes cast expressions will be turned into adjustments.[]list literals etc.).