CompileOptions implements the Library interface method.
()
| 412 | |
| 413 | // CompileOptions implements the Library interface method. |
| 414 | func (lib *mathLib) CompileOptions() []cel.EnvOption { |
| 415 | opts := []cel.EnvOption{ |
| 416 | cel.Macros( |
| 417 | // math.least(num, ...) |
| 418 | cel.ReceiverVarArgMacro(leastMacro, mathLeast), |
| 419 | // math.greatest(num, ...) |
| 420 | cel.ReceiverVarArgMacro(greatestMacro, mathGreatest), |
| 421 | ), |
| 422 | cel.Function(minFunc, |
| 423 | cel.Overload("math_@min_double", []*cel.Type{cel.DoubleType}, cel.DoubleType, |
| 424 | cel.UnaryBinding(identity)), |
| 425 | cel.Overload("math_@min_int", []*cel.Type{cel.IntType}, cel.IntType, |
| 426 | cel.UnaryBinding(identity)), |
| 427 | cel.Overload("math_@min_uint", []*cel.Type{cel.UintType}, cel.UintType, |
| 428 | cel.UnaryBinding(identity)), |
| 429 | cel.Overload("math_@min_double_double", []*cel.Type{cel.DoubleType, cel.DoubleType}, cel.DoubleType, |
| 430 | cel.BinaryBinding(minPair)), |
| 431 | cel.Overload("math_@min_int_int", []*cel.Type{cel.IntType, cel.IntType}, cel.IntType, |
| 432 | cel.BinaryBinding(minPair)), |
| 433 | cel.Overload("math_@min_uint_uint", []*cel.Type{cel.UintType, cel.UintType}, cel.UintType, |
| 434 | cel.BinaryBinding(minPair)), |
| 435 | cel.Overload("math_@min_int_uint", []*cel.Type{cel.IntType, cel.UintType}, cel.DynType, |
| 436 | cel.BinaryBinding(minPair)), |
| 437 | cel.Overload("math_@min_int_double", []*cel.Type{cel.IntType, cel.DoubleType}, cel.DynType, |
| 438 | cel.BinaryBinding(minPair)), |
| 439 | cel.Overload("math_@min_double_int", []*cel.Type{cel.DoubleType, cel.IntType}, cel.DynType, |
| 440 | cel.BinaryBinding(minPair)), |
| 441 | cel.Overload("math_@min_double_uint", []*cel.Type{cel.DoubleType, cel.UintType}, cel.DynType, |
| 442 | cel.BinaryBinding(minPair)), |
| 443 | cel.Overload("math_@min_uint_int", []*cel.Type{cel.UintType, cel.IntType}, cel.DynType, |
| 444 | cel.BinaryBinding(minPair)), |
| 445 | cel.Overload("math_@min_uint_double", []*cel.Type{cel.UintType, cel.DoubleType}, cel.DynType, |
| 446 | cel.BinaryBinding(minPair)), |
| 447 | cel.Overload("math_@min_list_double", []*cel.Type{cel.ListType(cel.DoubleType)}, cel.DoubleType, |
| 448 | cel.UnaryBinding(minList)), |
| 449 | cel.Overload("math_@min_list_int", []*cel.Type{cel.ListType(cel.IntType)}, cel.IntType, |
| 450 | cel.UnaryBinding(minList)), |
| 451 | cel.Overload("math_@min_list_uint", []*cel.Type{cel.ListType(cel.UintType)}, cel.UintType, |
| 452 | cel.UnaryBinding(minList)), |
| 453 | ), |
| 454 | cel.Function(maxFunc, |
| 455 | cel.Overload("math_@max_double", []*cel.Type{cel.DoubleType}, cel.DoubleType, |
| 456 | cel.UnaryBinding(identity)), |
| 457 | cel.Overload("math_@max_int", []*cel.Type{cel.IntType}, cel.IntType, |
| 458 | cel.UnaryBinding(identity)), |
| 459 | cel.Overload("math_@max_uint", []*cel.Type{cel.UintType}, cel.UintType, |
| 460 | cel.UnaryBinding(identity)), |
| 461 | cel.Overload("math_@max_double_double", []*cel.Type{cel.DoubleType, cel.DoubleType}, cel.DoubleType, |
| 462 | cel.BinaryBinding(maxPair)), |
| 463 | cel.Overload("math_@max_int_int", []*cel.Type{cel.IntType, cel.IntType}, cel.IntType, |
| 464 | cel.BinaryBinding(maxPair)), |
| 465 | cel.Overload("math_@max_uint_uint", []*cel.Type{cel.UintType, cel.UintType}, cel.UintType, |
| 466 | cel.BinaryBinding(maxPair)), |
| 467 | cel.Overload("math_@max_int_uint", []*cel.Type{cel.IntType, cel.UintType}, cel.DynType, |
| 468 | cel.BinaryBinding(maxPair)), |
| 469 | cel.Overload("math_@max_int_double", []*cel.Type{cel.IntType, cel.DoubleType}, cel.DynType, |
| 470 | cel.BinaryBinding(maxPair)), |
| 471 | cel.Overload("math_@max_double_int", []*cel.Type{cel.DoubleType, cel.IntType}, cel.DynType, |
nothing calls this directly
no test coverage detected