q/src/build/FunctionCall.go

28 lines
544 B
Go

package build
import (
"git.akyoto.dev/cli/q/src/build/expression"
)
// CompileFunctionCall compiles a top-level function call.
func (f *Function) CompileFunctionCall(expr *expression.Expression) error {
funcName := expr.Children[0].Token.Text()
parameters := expr.Children[1:]
for i := len(parameters) - 1; i >= 0; i-- {
err := f.ExpressionToRegister(parameters[i], f.CPU.Syscall[i])
if err != nil {
return err
}
}
if funcName == "syscall" {
f.Assembler.Syscall()
} else {
f.Assembler.Call(funcName)
}
return nil
}