// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.

// expr-context.go
package kern

// ----Expression Context
type ExprContext interface {
	Clone() ExprContext
	SetParent(ctx ExprContext)
	GetParent() (ctx ExprContext)
	GetGlobal() (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)
	VarCount() int
	DeleteVar(varName string)

	EnumFuncs(func(name string) (accept bool)) (funcNames []string)
	FuncCount() int
	DeleteFunc(funcName string)

	GetLocalFuncInfo(name string) (info ExprFunc, exists bool)
	GetFuncInfo(name string) (item ExprFunc, exists bool)
	Call(name string, args map[string]any) (result any, err error)
	RegisterFuncInfo(info ExprFunc)
	RegisterFunc(name string, f Functor, returnType string, param []ExprFuncParam) (funcInfo ExprFunc, err error)

	ToDict() (dict any) // must be a *DictType
	ToString(opt FmtOpt) string
}
