ProgramOptions implements the Library interface method.
()
| 389 | |
| 390 | // ProgramOptions implements the Library interface method. |
| 391 | func (lib *listsLib) ProgramOptions() []cel.ProgramOption { |
| 392 | var opts []cel.ProgramOption |
| 393 | if lib.version >= 3 { |
| 394 | // TODO: Add cost trackers for list operations |
| 395 | trackers := []interpreter.CostTrackerOption{ |
| 396 | interpreter.OverloadCostTracker("list_slice", trackListOutputSize), |
| 397 | interpreter.OverloadCostTracker("list_flatten", trackListFlatten), |
| 398 | interpreter.OverloadCostTracker("list_flatten_int", trackListFlatten), |
| 399 | interpreter.OverloadCostTracker("lists_range", trackListOutputSize), |
| 400 | interpreter.OverloadCostTracker("list_reverse", trackListOutputSize), |
| 401 | interpreter.OverloadCostTracker("list_distinct", trackListDistinct), |
| 402 | } |
| 403 | for _, t := range comparableTypes { |
| 404 | trackers = append(trackers, |
| 405 | interpreter.OverloadCostTracker( |
| 406 | fmt.Sprintf("list_%s_sort", t.TypeName()), |
| 407 | trackListSort, |
| 408 | ), |
| 409 | interpreter.OverloadCostTracker( |
| 410 | fmt.Sprintf("list_%s_sortByAssociatedKeys", t.TypeName()), |
| 411 | trackListSortBy, |
| 412 | ), |
| 413 | ) |
| 414 | } |
| 415 | opts = append(opts, cel.CostTrackerOptions(trackers...)) |
| 416 | } |
| 417 | return opts |
| 418 | } |
| 419 | |
| 420 | func genRange(n types.Int, maxSize int64) (ref.Val, error) { |
| 421 | if n < 0 { |
nothing calls this directly
no test coverage detected