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