switch partial explanation

This commit is contained in:
Rusty Striker 2024-04-04 09:58:44 +03:00
parent 75e3c031bf
commit 7b14d7ccb3
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15

View file

@ -209,6 +209,10 @@ class Parser(sly.Parser):
@_('SWITCH "(" expression ")" "{" caselist DEFAULT ":" stmtlist "}"')
def switch_stmt(self, p):
# The way this works is, every caselist (and case) return a list of where to put the comparison and jump
# also, where to jump(as in, where is the next case)
# they also add a little jump over the next case check, which would probably be
# removed by the optimizer if there is a break (since we will have 2 jumps one after the other)
exp = p[2]
cases = p[5]
if exp.is_float: