-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
WIP(general feedback appreciated): fix/refactor(control-flow): Switch rework and multi-node statement changes #5742
Open
Mr-Pine
wants to merge
24
commits into
INRIA:master
Choose a base branch
from
Mr-Pine:controlflow-switch-expression
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
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
Mr-Pine
force-pushed
the
controlflow-switch-expression
branch
from
April 10, 2024 21:23
54630ae
to
3c8e078
Compare
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:
default
cases 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_END
node 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
for