Implemented type checks
This commit is contained in:
32
src/build/core/CompileSyscall.go
Normal file
32
src/build/core/CompileSyscall.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user