global-context.go: variables holding function values can be invoked as function now
This commit is contained in:
parent
7650a4a441
commit
609fb21505
@ -40,11 +40,25 @@ func GetVar(ctx ExprContext, name string) (value any, exists bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetLocalFuncInfo(ctx ExprContext, name string) (item ExprFunc, exists bool) {
|
||||||
|
var v any
|
||||||
|
if len(name) > 0 {
|
||||||
|
if v, exists = ctx.GetVar(name); exists && isFunctor(v) {
|
||||||
|
f, _ := v.(Functor)
|
||||||
|
item = f.GetFunc()
|
||||||
|
} else {
|
||||||
|
item, exists = ctx.GetFuncInfo(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
func GetFuncInfo(ctx ExprContext, name string) (item ExprFunc, exists bool, ownerCtx ExprContext) {
|
func GetFuncInfo(ctx ExprContext, name string) (item ExprFunc, exists bool, ownerCtx ExprContext) {
|
||||||
if item, exists = ctx.GetFuncInfo(name); exists {
|
if len(name) > 0 {
|
||||||
ownerCtx = ctx
|
if item, exists = GetLocalFuncInfo(ctx, name); exists {
|
||||||
} else if item, exists = globalCtx.GetFuncInfo(name); exists {
|
ownerCtx = ctx
|
||||||
ownerCtx = globalCtx
|
} else if item, exists = globalCtx.GetFuncInfo(name); exists {
|
||||||
|
ownerCtx = globalCtx
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user