Added scope package

This commit is contained in:
2024-07-20 23:20:23 +02:00
parent 263c0cfb8b
commit 43cdac5572
37 changed files with 416 additions and 371 deletions

View File

@ -3,7 +3,6 @@ package core
import (
"fmt"
"git.akyoto.dev/cli/q/src/build/asm"
"git.akyoto.dev/cli/q/src/build/expression"
)
@ -74,39 +73,3 @@ func (f *Function) CompileCondition(condition *expression.Expression, successLab
return err
}
}
// JumpIfFalse jumps to the label if the previous comparison was false.
func (f *Function) JumpIfFalse(operator string, label string) {
switch operator {
case "==":
f.Jump(asm.JNE, label)
case "!=":
f.Jump(asm.JE, label)
case ">":
f.Jump(asm.JLE, label)
case "<":
f.Jump(asm.JGE, label)
case ">=":
f.Jump(asm.JL, label)
case "<=":
f.Jump(asm.JG, label)
}
}
// JumpIfTrue jumps to the label if the previous comparison was true.
func (f *Function) JumpIfTrue(operator string, label string) {
switch operator {
case "==":
f.Jump(asm.JE, label)
case "!=":
f.Jump(asm.JNE, label)
case ">":
f.Jump(asm.JG, label)
case "<":
f.Jump(asm.JL, label)
case ">=":
f.Jump(asm.JGE, label)
case "<=":
f.Jump(asm.JLE, label)
}
}