Implemented type checks

This commit is contained in:
2024-08-07 16:20:03 +02:00
parent 6e848774ed
commit 1b13539b22
19 changed files with 199 additions and 79 deletions

View File

@ -0,0 +1,32 @@
package core
import (
"git.akyoto.dev/cli/q/src/build/expression"
)
// CompileSyscall executes a kernel syscall.
func (f *Function) CompileSyscall(root *expression.Expression) error {
parameters := root.Children[1:]
registers := f.CPU.SyscallInput[:len(parameters)]
err := f.ExpressionsToRegisters(parameters, registers)
if err != nil {
return err
}
for _, register := range f.CPU.SyscallOutput {
f.SaveRegister(register)
}
f.Syscall()
for _, register := range registers {
if register == f.CPU.SyscallOutput[0] && root.Parent != nil {
continue
}
f.FreeRegister(register)
}
return nil
}