operator-context.go: now supports contextes that implement the Formatter interface
This commit is contained in:
parent
f9486fa1bd
commit
8d9963207e
@ -31,6 +31,9 @@ func evalContextValue(ctx ExprContext, self *term) (v any, err error) {
|
||||
}
|
||||
|
||||
if sourceCtx != nil {
|
||||
if formatter, ok := ctx.(Formatter); ok {
|
||||
v = formatter.ToString(0)
|
||||
} else {
|
||||
keys := sourceCtx.EnumVars(func(name string) bool { return name[0] != '_' })
|
||||
d := make(map[string]any)
|
||||
for _, key := range keys {
|
||||
@ -38,9 +41,10 @@ func evalContextValue(ctx ExprContext, self *term) (v any, err error) {
|
||||
}
|
||||
keys = sourceCtx.EnumFuncs(func(name string) bool { return true })
|
||||
for _, key := range keys {
|
||||
d[key], _ =sourceCtx.GetFuncInfo(key)
|
||||
d[key], _ = sourceCtx.GetFuncInfo(key)
|
||||
}
|
||||
v = d
|
||||
}
|
||||
} else {
|
||||
err = self.errIncompatibleType(childValue)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user