Improved label consistency
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user