1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-21 01:21:34 +02:00
ferret/pkg/runtime/expressions/param.go
Tim Voronov 549b4abd3b
Feature/#5 collect keyword alt (#141)
Implemented COLLECT key word
2018-10-24 21:30:05 -04:00

31 lines
664 B
Go

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
}
func (e *ParameterExpression) Exec(ctx context.Context, _ *core.Scope) (core.Value, error) {
param, err := core.ParamFrom(ctx, e.name)
if err != nil {
return values.None, core.SourceError(e.src, err)
}
return param, nil
}