kubernetes/vendor/github.com/google/cel-go/checker/cost.go

type CostEstimator

type CallEstimate

type AstNode

type astNode

func (e astNode) Path() []string {}

func (e astNode) Type() *types.Type {}

func (e astNode) Expr() ast.Expr {}

func (e astNode) ComputedSize() *SizeEstimate {}

type SizeEstimate

// Add adds to another SizeEstimate and returns the sum.
// If add would result in an uint64 overflow, the result is math.MaxUint64.
func (se SizeEstimate) Add(sizeEstimate SizeEstimate) SizeEstimate {}

// Multiply multiplies by another SizeEstimate and returns the product.
// If multiply would result in an uint64 overflow, the result is math.MaxUint64.
func (se SizeEstimate) Multiply(sizeEstimate SizeEstimate) SizeEstimate {}

// MultiplyByCostFactor multiplies a SizeEstimate by a cost factor and returns the CostEstimate with the
// nearest integer of the result, rounded up.
func (se SizeEstimate) MultiplyByCostFactor(costPerUnit float64) CostEstimate {}

// MultiplyByCost multiplies by the cost and returns the product.
// If multiply would result in an uint64 overflow, the result is math.MaxUint64.
func (se SizeEstimate) MultiplyByCost(cost CostEstimate) CostEstimate {}

// Union returns a SizeEstimate that encompasses both input the SizeEstimate.
func (se SizeEstimate) Union(size SizeEstimate) SizeEstimate {}

type CostEstimate

// Add adds the costs and returns the sum.
// If add would result in an uint64 overflow for the min or max, the value is set to math.MaxUint64.
func (ce CostEstimate) Add(cost CostEstimate) CostEstimate {}

// Multiply multiplies by the cost and returns the product.
// If multiply would result in an uint64 overflow, the result is math.MaxUint64.
func (ce CostEstimate) Multiply(cost CostEstimate) CostEstimate {}

// MultiplyByCostFactor multiplies a CostEstimate by a cost factor and returns the CostEstimate with the
// nearest integer of the result, rounded up.
func (ce CostEstimate) MultiplyByCostFactor(costPerUnit float64) CostEstimate {}

// Union returns a CostEstimate that encompasses both input the CostEstimates.
func (ce CostEstimate) Union(size CostEstimate) CostEstimate {}

// addUint64NoOverflow adds non-negative ints. If the result is exceeds math.MaxUint64, math.MaxUint64
// is returned.
func addUint64NoOverflow(x, y uint64) uint64 {}

// multiplyUint64NoOverflow multiplies non-negative ints. If the result is exceeds math.MaxUint64, math.MaxUint64
// is returned.
func multiplyUint64NoOverflow(x, y uint64) uint64 {}

// multiplyByFactor multiplies an integer by a cost factor float and returns the nearest integer value, rounded up.
func multiplyByCostFactor(x uint64, y float64) uint64 {}

var selectAndIdentCost

var constCost

var createListBaseCost

var createMapBaseCost

var createMessageBaseCost

type coster

type iterRangeScopes

func (vs iterRangeScopes) push(varName string, expr ast.Expr) {}

func (vs iterRangeScopes) pop(varName string) {}

func (vs iterRangeScopes) peek(varName string) (int64, bool) {}

type CostOption

// PresenceTestHasCost determines whether presence testing has a cost of one or zero.
//
// Defaults to presence test has a cost of one.
func PresenceTestHasCost(hasCost bool) CostOption {}

type FunctionEstimator

// OverloadCostEstimate binds a FunctionCoster to a specific function overload ID.
//
// When a OverloadCostEstimate is provided, it will override the cost calculation of the CostEstimator provided to
// the Cost() call.
func OverloadCostEstimate(overloadID string, functionCoster FunctionEstimator) CostOption {}

// Cost estimates the cost of the parsed and type checked CEL expression.
func Cost(checked *ast.AST, estimator CostEstimator, opts ...CostOption) (CostEstimate, error) {}

func (c *coster) cost(e ast.Expr) CostEstimate {}

func (c *coster) costIdent(e ast.Expr) CostEstimate {}

func (c *coster) costSelect(e ast.Expr) CostEstimate {}

func (c *coster) costCall(e ast.Expr) CostEstimate {}

func (c *coster) costCreateList(e ast.Expr) CostEstimate {}

func (c *coster) costCreateMap(e ast.Expr) CostEstimate {}

func (c *coster) costCreateStruct(e ast.Expr) CostEstimate {}

func (c *coster) costComprehension(e ast.Expr) CostEstimate {}

func (c *coster) sizeEstimate(t AstNode) SizeEstimate {}

func (c *coster) functionCost(function, overloadID string, target *AstNode, args []AstNode, argCosts []CostEstimate) CallEstimate {}

func (c *coster) getType(e ast.Expr) *types.Type {}

func (c *coster) getPath(e ast.Expr) []string {}

func (c *coster) addPath(e ast.Expr, path []string) {}

func (c *coster) newAstNode(e ast.Expr) *astNode {}

// isScalar returns true if the given type is known to be of a constant size at
// compile time. isScalar will return false for strings (they are variable-width)
// in addition to protobuf.Any and protobuf.Value (their size is not knowable at compile time).
func isScalar(t *types.Type) bool {}

var doubleTwoTo64