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 }