WIP(general feedback appreciated): fix/refactor(control-flow): Switch rework and multi-node statement changes#5742
Open
Mr-Pine wants to merge 24 commits intoINRIA:masterfrom
Open
Conversation
This was referenced Apr 6, 2024
As a side effect, fall throughs now go to the next block, not the next case expression
…anymore and handle return switch () {} expression
They now have a start and an end node. Should be ported to other multinode constructs like if, loops, conditionals, ...
…e switch selector node to branch
54630ae to
3c8e078
Compare
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.
In the process of handling switch expressions and enhanced switch statements I ended up rewriting the whole switch code.
Notable Changes to the results:
defaultcases don't have a dummy statement any more.The construct starts with a node that is assigned the entire statement, then the subnodes follow and the construct is finished with a
STATEMENT_ENDnode that is tagged with the start node (See details below).I intend to adapt this to other multi-node constructs as well and some support for this is already implemented, but the rest is probably better placed in another PR. I think this change enables a more complete representation of multi-node constructs, especially of multi-node expressions like conditionals (currently conditionals in returns are not handled at all, for example) or maybe even nested method calls. The design of this was based on the way conditionals are handled when assigned to local variables. I added the end marker mainly as a jump point for skipping the entire statement and for easier support with return statements.
I'd appreciate some feedback for these changes, especially on the last point as it has a pretty big impact
Details
for