Simplified expression evaluation

This commit is contained in:
2025-02-28 16:07:10 +01:00
parent b67361c035
commit a5a8f0f503
17 changed files with 153 additions and 322 deletions

@ -1,26 +1,22 @@
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)
func (f *Function) EvaluateCall(expr *expression.Expression) (eval.Register, error) {
typ, err := f.CompileCall(expr)
if err != nil {
return nil, err
return eval.Register{}, err
}
if len(types) == 0 {
return nil, errors.New(errors.UntypedExpression, f.File, expr.Token.Position)
}
value := eval.Register{Register: f.CPU.Output[0]}
value := eval.Register{
Typ: types[0],
Register: f.CPU.Output[0],
if len(typ) > 0 {
value.Typ = typ[0]
}
return value, nil