-
Notifications
You must be signed in to change notification settings - Fork 138
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
[Enhanced Switch] "Retrofit" some design into code generation for switch statement #3430
Milestone
Comments
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 12, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 13, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 13, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 13, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 13, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 13, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 14, 2024
srikanth-sankaran
added a commit
to srikanth-sankaran/eclipse.jdt.core
that referenced
this issue
Dec 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of Java 24, there are 5 kinds of switches namely, "Classic" integer selector switches, enum switches, string switches, type switches with patterns and primitive switches.
Code generation for each of these involves some abstractable steps such as (a) Prologue (all preparatory steps including and upto the case selection) (b) Code generation for the switch block (c) generation of injected default case - where applicable (d) epilogue - any and all actions to wrap up.
ATM, there is no clear design that is worth speaking of - there is some faint half/quarter hearted attempt at differentiating prologues, but this is inconsistently followed through, resulting in two big "blobs" of code - one for switching on strings and one for all other switches.
There is no attempt at code reuse - see the duplication between
org.eclipse.jdt.internal.compiler.ast.SwitchStatement.generateCodeForStringSwitch(BlockScope, CodeStream)
andorg.eclipse.jdt.internal.compiler.ast.SwitchStatement.generateCode(BlockScope, CodeStream)
- bottom half of each could be extracted as common code.There is also no clear separation of concerns - resulting in spaghetti style intertwining of disparate concerns.
We can certainly do better by retrofitting some design that would promote readability, code organization and reuse.
The text was updated successfully, but these errors were encountered: