MCPcopy Create free account
hub / github.com/cel-expr/cel-go / pushIterKey

Method pushIterKey

common/cost/estimator.go:261–278  ·  view source on GitHub ↗

pushIterKey pushes the iteration key or index variable for a comprehension onto the scope stack.

(varName string, rangeExpr ast.Expr)

Source from the content-addressed store, hash-verified

259
260// pushIterKey pushes the iteration key or index variable for a comprehension onto the scope stack.
261func (c *coster) pushIterKey(varName string, rangeExpr ast.Expr) {
262 rangeSize := c.sizeOrUnknown(rangeExpr)
263 container := c.getType(rangeExpr).Kind()
264 var size *SizeEstimate
265 subpath := "@keys"
266 if container == types.ListKind {
267 s := FixedSizeEstimate(1)
268 size = &s
269 subpath = "@indices"
270 } else if rangeSize.Key != nil && (c.modelVersion >= 1 || c.isLegacyTracked(rangeExpr)) {
271 size = rangeSize.Key
272 }
273 var varPath []string
274 if path := c.getPath(rangeExpr); len(path) > 0 || c.modelVersion < 1 {
275 varPath = append(path, subpath)
276 }
277 c.localVars.push(varName, rangeExpr, varPath, size)
278}
279
280// pushIterValue pushes the iteration value variable for a comprehension onto the scope stack.
281func (c *coster) pushIterValue(varName string, rangeExpr ast.Expr) {

Callers 1

costComprehensionMethod · 0.95

Calls 7

sizeOrUnknownMethod · 0.95
getTypeMethod · 0.95
isLegacyTrackedMethod · 0.95
getPathMethod · 0.95
FixedSizeEstimateFunction · 0.70
KindMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected