Improved code generation

This commit is contained in:
Eduard Urbach 2024-07-09 17:00:04 +02:00
parent 6e22febc01
commit 3c189a025f
Signed by: eduard
GPG key ID: 49226B848C78F6C8
23 changed files with 201 additions and 95 deletions

View file

@ -10,8 +10,8 @@ import (
// CompileLoop compiles a loop instruction.
func (f *Function) CompileLoop(loop *ast.Loop) error {
label := fmt.Sprintf("%s_loop_%d", f.Name, f.count.loop)
f.assembler.Label(asm.LABEL, label)
defer f.assembler.Jump(label)
f.AddLabel(label)
defer f.Jump(asm.JUMP, label)
f.count.loop++
return f.CompileAST(loop.Body)
}