Improved label consistency

This commit is contained in:
2025-02-21 17:04:13 +01:00
parent 08436c31c0
commit 4caac57210
11 changed files with 36 additions and 31 deletions

View File

@ -1,8 +1,6 @@
package core
import (
"fmt"
"git.akyoto.dev/cli/q/src/asm"
"git.akyoto.dev/cli/q/src/ast"
)
@ -17,8 +15,8 @@ func (f *Function) CompileIf(branch *ast.If) error {
var (
end string
success = fmt.Sprintf("%s_if_%d_true", f.UniqueName, f.count.branch)
fail = fmt.Sprintf("%s_if_%d_false", f.UniqueName, f.count.branch)
success = f.CreateLabel("if true", f.count.branch)
fail = f.CreateLabel("if false", f.count.branch)
err = f.CompileCondition(branch.Condition, success, fail)
)
@ -35,7 +33,7 @@ func (f *Function) CompileIf(branch *ast.If) error {
}
if branch.Else != nil {
end = fmt.Sprintf("%s_if_%d_end", f.UniqueName, f.count.branch)
end = f.CreateLabel("if end", f.count.branch)
f.Jump(asm.JUMP, end)
}