ExprContext: new functions VarCount(), DeleteVar(), FuncCount(), DeleteFunc()
This commit is contained in:
parent
8547248ea2
commit
905337f963
@ -14,8 +14,15 @@ type ExprContext interface {
|
||||
GetLast() any
|
||||
SetVar(varName string, value any)
|
||||
UnsafeSetVar(varName string, value any)
|
||||
|
||||
EnumVars(func(name string) (accept bool)) (varNames []string)
|
||||
VarCount() int
|
||||
DeleteVar(varName string)
|
||||
|
||||
EnumFuncs(func(name string) (accept bool)) (funcNames []string)
|
||||
FuncCount() int
|
||||
DeleteFunc(funcName string)
|
||||
|
||||
GetFuncInfo(name string) (item ExprFunc, exists bool)
|
||||
Call(name string, args []any) (result any, err error)
|
||||
RegisterFuncInfo(info ExprFunc)
|
||||
|
@ -132,6 +132,14 @@ func (ctx *SimpleStore) EnumVars(acceptor func(name string) (accept bool)) (varN
|
||||
return
|
||||
}
|
||||
|
||||
func (ctx *SimpleStore) VarCount() int {
|
||||
return len(ctx.varStore)
|
||||
}
|
||||
|
||||
func (ctx *SimpleStore) DeleteVar(varName string) {
|
||||
delete(ctx.varStore, varName)
|
||||
}
|
||||
|
||||
func (ctx *SimpleStore) GetFuncInfo(name string) (info ExprFunc, exists bool) {
|
||||
info, exists = ctx.funcStore[name]
|
||||
return
|
||||
@ -163,6 +171,14 @@ func (ctx *SimpleStore) EnumFuncs(acceptor func(name string) (accept bool)) (fun
|
||||
return
|
||||
}
|
||||
|
||||
func (ctx *SimpleStore) FuncCount() int {
|
||||
return len(ctx.funcStore)
|
||||
}
|
||||
|
||||
func (ctx *SimpleStore) DeleteFunc(funcName string) {
|
||||
delete(ctx.funcStore, funcName)
|
||||
}
|
||||
|
||||
func (ctx *SimpleStore) Call(name string, args []any) (result any, err error) {
|
||||
if info, exists := GetLocalFuncInfo(ctx, name); exists {
|
||||
functor := info.Functor()
|
||||
|
Loading…
Reference in New Issue
Block a user