kubernetes/vendor/github.com/google/cel-go/interpreter/prune.go

type astPruner

// PruneAst prunes the given AST based on the given EvalState and generates a new AST.
// Given AST is copied on write and a new AST is returned.
// Couple of typical use cases this interface would be:
//
// A)
// 1) Evaluate expr with some unknowns,
// 2) If result is unknown:
//
//	a) PruneAst
//	b) Goto 1
//
// Functional call results which are known would be effectively cached across
// iterations.
//
// B)
// 1) Compile the expression (maybe via a service and maybe after checking a
//
//	compiled expression does not exists in local cache)
//
// 2) Prepare the environment and the interpreter. Activation might be empty.
// 3) Eval the expression. This might return unknown or error or a concrete
//
//	value.
//
// 4) PruneAst
// 4) Maybe cache the expression
// This is effectively constant folding the expression. How the environment is
// prepared in step 2 is flexible. For example, If the caller caches the
// compiled and constant folded expressions, but is not willing to constant
// fold(and thus cache results of) some external calls, then they can prepare
// the overloads accordingly.
func PruneAst(expr ast.Expr, macroCalls map[int64]ast.Expr, state EvalState) *ast.AST {}

func (p *astPruner) maybeCreateLiteral(id int64, val ref.Val) (ast.Expr, bool) {}

func (p *astPruner) maybePruneOptional(elem ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePruneIn(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePruneLogicalNot(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePruneOr(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePruneAnd(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePruneConditional(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePruneFunction(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) maybePrune(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) prune(node ast.Expr) (ast.Expr, bool) {}

func (p *astPruner) value(id int64) (ref.Val, bool) {}

func (p *astPruner) maybeValue(id int64) (ref.Val, bool) {}

func (p *astPruner) nextID() int64 {}

type astVisitor

func getMaxID(expr ast.Expr) int64 {}

func clearIterVarVisitor(varName string, state EvalState) astVisitor {}

func maxIDVisitor(maxID *int64) astVisitor {}

func visit(expr ast.Expr, visitor astVisitor) {}