Interpreter: switch statement lowering#72
Conversation
Alonely0
left a comment
There was a problem hiding this comment.
At a first glance this looks great, but my head aches a bit too much for me to continue looking at a screen today, sorry. I'll push the review comments I have and try to do some more tomorrow.
@Alonely0 Thank you for reviewing this. If you have a headache, you might want to rest and try some meditation to relieve it (this works very well for me). |
Add AST lowering for switch: evaluate the scrutinee once into a register, emit a branch chain for each case, and jump to the default branch or past the statement when nothing matches. Match literal cases with Eq; match regex and typed-regex cases with Matches. Support default placed anywhere in the case list, including before later cases. Fixes uutils#70
db2dcff to
a37f099
Compare
That's good advice, ty! It's mostly due to eye-strain from astigmatism, so it might do wonders. I have been trying to get into meditation for a while, so I guess that's a good reason to try. |
Alonely0
left a comment
There was a problem hiding this comment.
Looks good to me! switch statements are such monsters to implement hahahah.
Add AST lowering for switch: evaluate the scrutinee once into a register, emit a branch chain for each case, and jump to the default branch or past the statement when nothing matches.
Match literal cases with Eq; match regex and typed-regex cases with Matches. Support default placed anywhere in the case list, including before later cases.
Fixes #70