ProgramOptions implements the Library interface method.
()
| 411 | |
| 412 | // ProgramOptions implements the Library interface method. |
| 413 | func (lib *listsLib) ProgramOptions() []cel.ProgramOption { |
| 414 | var opts []cel.ProgramOption |
| 415 | if lib.version >= 3 { |
| 416 | trackers := []interpreter.CostTrackerOption{ |
| 417 | interpreter.OverloadCostTracker("list_slice", trackListOutputSize), |
| 418 | interpreter.OverloadCostTracker("lists_range", trackListOutputSize), |
| 419 | interpreter.OverloadCostTracker("list_reverse", trackListOutputSize), |
| 420 | interpreter.OverloadCostTracker("list_distinct", trackListDistinct), |
| 421 | } |
| 422 | if lib.version == 3 { |
| 423 | trackers = append(trackers, |
| 424 | interpreter.OverloadCostTracker("list_flatten", trackListFlattenLegacy), |
| 425 | interpreter.OverloadCostTracker("list_flatten_int", trackListFlattenLegacy), |
| 426 | ) |
| 427 | } else { |
| 428 | trackers = append(trackers, |
| 429 | interpreter.OverloadCostTracker("list_flatten", trackListFlatten), |
| 430 | interpreter.OverloadCostTracker("list_flatten_int", trackListFlatten), |
| 431 | ) |
| 432 | } |
| 433 | for _, t := range comparableTypes { |
| 434 | trackers = append(trackers, |
| 435 | interpreter.OverloadCostTracker( |
| 436 | fmt.Sprintf("list_%s_sort", t.TypeName()), |
| 437 | trackListSort, |
| 438 | ), |
| 439 | interpreter.OverloadCostTracker( |
| 440 | fmt.Sprintf("list_%s_sortByAssociatedKeys", t.TypeName()), |
| 441 | trackListSortBy, |
| 442 | ), |
| 443 | ) |
| 444 | } |
| 445 | opts = append(opts, cel.CostTrackerOptions(trackers...)) |
| 446 | } |
| 447 | return opts |
| 448 | } |
| 449 | |
| 450 | func genRange(n types.Int, maxSize int64) (ref.Val, error) { |
| 451 | if n < 0 { |
nothing calls this directly
no test coverage detected