Implemented if statements

This commit is contained in:
Eduard Urbach 2024-07-07 12:30:57 +02:00
parent c139dced9e
commit 962a362578
Signed by: eduard
GPG key ID: 49226B848C78F6C8
16 changed files with 280 additions and 14 deletions

View file

@ -3,13 +3,14 @@ package core
import (
"fmt"
"git.akyoto.dev/cli/q/src/build/asm"
"git.akyoto.dev/cli/q/src/build/ast"
)
// 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(label)
f.assembler.Label(asm.LABEL, label)
defer f.assembler.Jump(label)
f.count.loop++
return f.CompileAST(loop.Body)