Implemented loads with register offsets

This commit is contained in:
Eduard Urbach 2025-02-19 15:36:42 +01:00
parent c86766bd33
commit 144810c6c8
Signed by: eduard
GPG key ID: 49226B848C78F6C8
13 changed files with 320 additions and 145 deletions

View file

@ -0,0 +1,27 @@
package core
import (
"git.akyoto.dev/cli/q/src/asm"
"git.akyoto.dev/cli/q/src/cpu"
"git.akyoto.dev/cli/q/src/expression"
"git.akyoto.dev/cli/q/src/types"
)
// CallToRegister moves the result of a function call into the given register.
func (f *Function) CallToRegister(node *expression.Expression, register cpu.Register) (types.Type, error) {
types, err := f.CompileCall(node)
if err != nil {
return nil, err
}
if register != f.CPU.Output[0] {
f.RegisterRegister(asm.MOVE, register, f.CPU.Output[0])
}
if len(types) == 0 {
return nil, nil
}
return types[0], err
}