Unify several l-value access emission paths in SILGen #18071
Merged
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.
There were several bits of code which were unnecessarily repeating the core logic of breaking down an access strategy and either setting up an
LValue
or directly emitting it. These places have now been unified to just create and then load or othrwise use anLValue
.Introduce a visitor which handles the common parts of breaking down an access strategy and computing information like the
LValueTypeData
. In addition to its direct benefits (which are somewhat lost in the boilerplate of capturing local state into the visitor subclass), this eliminates some of the ad hoc-ness of how the various emission paths useAccessStrategy
.Finally, implement the
MaterializeToTemporary
strategy in its full generality by using the actual read and write sub-strategies instead of always falling back on calling the getter and setter. This part is not NFC because it causes us to perform the read part of a read/write to a stored-with-observers property by directly accessing the storage instead of calling the getter. It will be even less NFC as we generalize ways in which accesses can be performed.