diff --git a/expr-context.go b/expr-context.go index 499a33b..53982bf 100644 --- a/expr-context.go +++ b/expr-context.go @@ -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) diff --git a/simple-store.go b/simple-store.go index 737671f..b34f18b 100644 --- a/simple-store.go +++ b/simple-store.go @@ -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()