Implemented compilation finished events

This commit is contained in:
2024-06-30 11:41:59 +02:00
parent 3fe2cd1da2
commit 247b82b529
8 changed files with 72 additions and 50 deletions

44
src/build/Call.go Normal file
View File

@ -0,0 +1,44 @@
package build
import (
"git.akyoto.dev/cli/q/src/build/config"
"git.akyoto.dev/cli/q/src/build/expression"
)
// CompileFunctionCall executes a function call.
func (f *Function) CompileFunctionCall(expr *expression.Expression) error {
funcName := expr.Children[0].Token.Text()
if funcName == "syscall" {
return f.CompileSyscall(expr)
}
function := f.functions[funcName]
if function != f {
function.Wait()
}
parameters := expr.Children[1:]
registers := f.cpu.Call[:len(parameters)]
err := f.ExpressionsToRegisters(parameters, registers)
if config.Verbose {
f.Logf("call: %s", funcName)
}
f.assembler.Call(funcName)
f.sideEffects += function.sideEffects
return err
}
// CompileSyscall executes a syscall.
func (f *Function) CompileSyscall(expr *expression.Expression) error {
parameters := expr.Children[1:]
registers := f.cpu.Syscall[:len(parameters)]
err := f.ExpressionsToRegisters(parameters, registers)
f.assembler.Syscall()
f.sideEffects++
return err
}