1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-01-30 04:30:51 +02:00

31 lines
664 B
Go
Raw Normal View History

2018-09-28 21:04:16 -04:00
package expressions
import (
"context"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
type ParameterExpression struct {
src core.SourceMap
name string
}
func NewParameterExpression(src core.SourceMap, name string) (*ParameterExpression, error) {
if name == "" {
return nil, core.Error(core.ErrMissedArgument, "name")
}
return &ParameterExpression{src, name}, nil
}
2018-10-05 17:20:48 -04:00
func (e *ParameterExpression) Exec(ctx context.Context, _ *core.Scope) (core.Value, error) {
2018-09-28 21:04:16 -04:00
param, err := core.ParamFrom(ctx, e.name)
if err != nil {
return values.None, core.SourceError(e.src, err)
}
return param, nil
}