2024-03-28 06:29:11 +01:00
|
|
|
// simple-var-store.go
|
|
|
|
package expr
|
|
|
|
|
|
|
|
type SimpleVarStore struct {
|
|
|
|
store map[string]any
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSimpleVarStore() *SimpleVarStore {
|
|
|
|
return &SimpleVarStore{
|
|
|
|
store: make(map[string]any),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-02 04:36:03 +02:00
|
|
|
func (ctx *SimpleVarStore) Clone() (clone exprContext) {
|
|
|
|
clone = &SimpleVarStore{
|
|
|
|
store: CloneMap(ctx.store),
|
|
|
|
}
|
|
|
|
return clone
|
|
|
|
}
|
|
|
|
|
2024-04-03 06:29:57 +02:00
|
|
|
func (ctx *SimpleVarStore) GetVar(varName string) (v any, exists bool) {
|
2024-03-28 06:29:11 +01:00
|
|
|
v, exists = ctx.store[varName]
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-04-03 06:29:57 +02:00
|
|
|
func (ctx *SimpleVarStore) SetVar(varName string, value any) {
|
2024-03-28 06:29:11 +01:00
|
|
|
ctx.store[varName] = value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *SimpleVarStore) GetFuncInfo(name string) (f exprFunc) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *SimpleVarStore) Call(name string, args []any) (result any, err error) {
|
|
|
|
return
|
|
|
|
}
|
2024-03-30 06:54:43 +01:00
|
|
|
|
2024-04-02 04:36:03 +02:00
|
|
|
func (ctx *SimpleVarStore) RegisterFunc(name string, functor Functor, minArgs, maxArgs int) {
|
2024-03-30 06:54:43 +01:00
|
|
|
}
|