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