package core import ( "git.akyoto.dev/cli/q/src/build/ast" "git.akyoto.dev/cli/q/src/build/cpu" "git.akyoto.dev/cli/q/src/build/expression" "git.akyoto.dev/cli/q/src/build/token" ) // Execute executes an operation on a register with a value operand. func (f *Function) Execute(operation token.Token, register cpu.Register, value *expression.Expression) error { if value.IsLeaf() { return f.ExecuteLeaf(operation, register, value.Token) } if ast.IsFunctionCall(value) { err := f.CompileCall(value) if err != nil { return err } return f.ExecuteRegisterRegister(operation, register, f.cpu.Output[0]) } tmp := f.CurrentScope().MustFindFree(f.cpu.General) defer f.CurrentScope().Free(tmp) err := f.ExpressionToRegister(value, tmp) if err != nil { return err } return f.ExecuteRegisterRegister(operation, register, tmp) }