Simplified Evaluate function

This commit is contained in:
2025-02-27 23:28:17 +01:00
parent e7afb2dab5
commit 31423ccc08
14 changed files with 318 additions and 133 deletions

28
src/core/EvaluateCall.go Normal file
View File

@ -0,0 +1,28 @@
package core
import (
"git.urbach.dev/cli/q/src/errors"
"git.urbach.dev/cli/q/src/eval"
"git.urbach.dev/cli/q/src/expression"
)
// EvaluateCall evaluates a function call.
func (f *Function) EvaluateCall(expr *expression.Expression) (eval.Value, error) {
types, err := f.CompileCall(expr)
if err != nil {
return eval.Value{}, err
}
if len(types) == 0 {
return eval.Value{}, errors.New(errors.UntypedExpression, f.File, expr.Token.Position)
}
value := eval.Value{
Kind: eval.Register,
Type: types[0],
Register: f.CPU.Output[0],
}
return value, nil
}