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"
|
||||
)
|
||||
@ -10,7 +8,7 @@ import (
|
||||
// CompileSwitch compiles a multi-branch instruction.
|
||||
func (f *Function) CompileSwitch(s *ast.Switch) error {
|
||||
f.count.multiBranch++
|
||||
end := fmt.Sprintf("%s_switch_%d_end", f.UniqueName, f.count.multiBranch)
|
||||
end := f.CreateLabel("switch end", f.count.multiBranch)
|
||||
|
||||
for _, branch := range s.Cases {
|
||||
if branch.Condition == nil {
|
||||
@ -28,8 +26,8 @@ func (f *Function) CompileSwitch(s *ast.Switch) error {
|
||||
f.count.branch++
|
||||
|
||||
var (
|
||||
success = fmt.Sprintf("%s_case_%d_true", f.UniqueName, f.count.branch)
|
||||
fail = fmt.Sprintf("%s_case_%d_false", f.UniqueName, f.count.branch)
|
||||
success = f.CreateLabel("case true", f.count.branch)
|
||||
fail = f.CreateLabel("case false", f.count.branch)
|
||||
err = f.CompileCondition(branch.Condition, success, fail)
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user