Added utility function GetLast() to context

This commit is contained in:
2024-06-17 06:56:32 +02:00
parent ba479a1b99
commit 703ecf6829
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -7,7 +7,7 @@ package expr
import (
"fmt"
"slices"
// "strings"
// "strings"
)
type SimpleStore struct {
@@ -50,6 +50,7 @@ func (ctx *SimpleStore) Merge(src ExprContext) {
ctx.funcStore[name], _ = src.GetFuncInfo(name)
}
}
/*
func varsCtxToBuilder(sb *strings.Builder, ctx ExprContext, indent int) {
sb.WriteString("vars: {\n")
@@ -165,6 +166,11 @@ func (ctx *SimpleStore) GetVar(varName string) (v any, exists bool) {
return
}
func (ctx *SimpleStore) GetLast() (v any) {
v = ctx.varStore["last"]
return
}
func (ctx *SimpleStore) UnsafeSetVar(varName string, value any) {
// fmt.Printf("[%p] setVar(%v, %v)\n", ctx, varName, value)
ctx.varStore[varName] = value