58 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// simple-var-store.go
 | 
						|
package expr
 | 
						|
 | 
						|
type SimpleVarStore struct {
 | 
						|
	varStore map[string]any
 | 
						|
}
 | 
						|
 | 
						|
func NewSimpleVarStore() *SimpleVarStore {
 | 
						|
	return &SimpleVarStore{
 | 
						|
		varStore: make(map[string]any),
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) Clone() (clone ExprContext) {
 | 
						|
	clone = &SimpleVarStore{
 | 
						|
		varStore: CloneMap(ctx.varStore),
 | 
						|
	}
 | 
						|
	return clone
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) GetVar(varName string) (v any, exists bool) {
 | 
						|
	v, exists = ctx.varStore[varName]
 | 
						|
	return
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) SetVar(varName string, value any) {
 | 
						|
	ctx.varStore[varName] = value
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) EnumVars(acceptor func(name string) (accept bool)) (varNames []string) {
 | 
						|
	varNames = make([]string, 0)
 | 
						|
	for name := range ctx.varStore {
 | 
						|
		if acceptor != nil {
 | 
						|
			if acceptor(name) {
 | 
						|
				varNames = append(varNames, name)
 | 
						|
			}
 | 
						|
		} else {
 | 
						|
			varNames = append(varNames, name)
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) GetFuncInfo(name string) (f ExprFunc) {
 | 
						|
	return
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) Call(name string, args []any) (result any, err error) {
 | 
						|
	return
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) RegisterFunc(name string, functor Functor, minArgs, maxArgs int) {
 | 
						|
}
 | 
						|
 | 
						|
func (ctx *SimpleVarStore) EnumFuncs(acceptor func(name string) (accept bool)) (funcNames []string) {
 | 
						|
	return
 | 
						|
}
 |