q/src/core/JumpIfFalse.go
2025-02-25 17:16:09 +01:00

25 lines
532 B
Go

package core
import (
"git.urbach.dev/cli/q/src/asm"
"git.urbach.dev/cli/q/src/token"
)
// JumpIfFalse jumps to the label if the previous comparison was false.
func (f *Function) JumpIfFalse(operator token.Kind, label string) {
switch operator {
case token.Equal:
f.Jump(asm.JNE, label)
case token.NotEqual:
f.Jump(asm.JE, label)
case token.Greater:
f.Jump(asm.JLE, label)
case token.Less:
f.Jump(asm.JGE, label)
case token.GreaterEqual:
f.Jump(asm.JL, label)
case token.LessEqual:
f.Jump(asm.JG, label)
}
}