Added utility function GetLast() to context
This commit is contained in:
parent
ba479a1b99
commit
703ecf6829
@ -40,6 +40,7 @@ type ExprContext interface {
|
||||
SetParent(ctx ExprContext)
|
||||
GetParent() (ctx ExprContext)
|
||||
GetVar(varName string) (value any, exists bool)
|
||||
GetLast() any
|
||||
SetVar(varName string, value any)
|
||||
UnsafeSetVar(varName string, value any)
|
||||
EnumVars(func(name string) (accept bool)) (varNames []string)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user