Simplified Evaluate function
This commit is contained in:
28
src/core/EvaluateCall.go
Normal file
28
src/core/EvaluateCall.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user