This commit is contained in:
parent
6a50fb0025
commit
722d446220
|
@ -192,7 +192,7 @@ func (e evaluator) evalArg(ctx context.Context, ec *evalCtx, n astCmdArg) (Objec
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fromGoValue(dv)
|
||||
return FromGoValue(dv)
|
||||
}
|
||||
|
||||
return nil, errors.New("undefined variable: " + *n.Var)
|
||||
|
|
|
@ -119,7 +119,7 @@ func New(opts ...InstOption) *Inst {
|
|||
}
|
||||
|
||||
func (inst *Inst) SetVar(name string, value any) {
|
||||
obj, err := fromGoValue(value)
|
||||
obj, err := FromGoValue(value)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ func toGoValue(obj Object) (interface{}, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
func fromGoValue(v any) (Object, error) {
|
||||
func FromGoValue(v any) (Object, error) {
|
||||
switch t := v.(type) {
|
||||
case Object:
|
||||
return t, nil
|
||||
|
@ -544,7 +544,7 @@ func (p listableProxyObject) Len() int {
|
|||
}
|
||||
|
||||
func (p listableProxyObject) Index(i int) Object {
|
||||
e, err := fromGoValue(p.v.Index(i).Interface())
|
||||
e, err := FromGoValue(p.v.Index(i).Interface())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ func (s structProxyObject) Value(k string) Object {
|
|||
f = f.Elem()
|
||||
}
|
||||
|
||||
e, err := fromGoValue(f.Interface())
|
||||
e, err := FromGoValue(f.Interface())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ func (s structProxyObject) Value(k string) Object {
|
|||
|
||||
func (s structProxyObject) Each(fn func(k string, v Object) error) error {
|
||||
for _, f := range s.vf {
|
||||
v, err := fromGoValue(s.v.FieldByName(f.Name).Interface())
|
||||
v, err := FromGoValue(s.v.FieldByName(f.Name).Interface())
|
||||
if err != nil {
|
||||
v = nil
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ func (u userBuiltin) invoke(ctx context.Context, args invocationArgs) (Object, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return fromGoValue(v)
|
||||
return FromGoValue(v)
|
||||
}
|
||||
|
||||
func (ca CallArgs) bindArg(v interface{}, arg Object) error {
|
||||
|
@ -265,7 +265,7 @@ func (m missingHandlerInvokable) invoke(ctx context.Context, args invocationArgs
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return fromGoValue(v)
|
||||
return FromGoValue(v)
|
||||
}
|
||||
|
||||
type Invokable struct {
|
||||
|
@ -292,7 +292,7 @@ func (i Invokable) Invoke(ctx context.Context, args ...any) (any, error) {
|
|||
}
|
||||
|
||||
invArgs.args, err = slices.MapWithError(args, func(a any) (Object, error) {
|
||||
return fromGoValue(a)
|
||||
return FromGoValue(a)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue