(opName string, o *OverloadDecl)
| 1089 | } |
| 1090 | |
| 1091 | func formatOperator(opName string, o *OverloadDecl) string { |
| 1092 | args := o.ArgTypes() |
| 1093 | argTypes := make([]string, len(o.ArgTypes())) |
| 1094 | for j, a := range args { |
| 1095 | argTypes[j] = describeCELType(a) |
| 1096 | } |
| 1097 | ret := describeCELType(o.ResultType()) |
| 1098 | switch len(args) { |
| 1099 | case 1: |
| 1100 | return fmt.Sprintf("%s%s -> %s", opName, argTypes[0], ret) |
| 1101 | case 2: |
| 1102 | if opName == operators.Index { |
| 1103 | return fmt.Sprintf("%s[%s] -> %s", argTypes[0], argTypes[1], ret) |
| 1104 | } |
| 1105 | return fmt.Sprintf("%s %s %s -> %s", argTypes[0], opName, argTypes[1], ret) |
| 1106 | default: |
| 1107 | if opName == operators.Conditional { |
| 1108 | return fmt.Sprint("bool ? <T> : <T> -> <T>") |
| 1109 | } |
| 1110 | return formatCall(opName, o) |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | func formatCall(funcName string, o *OverloadDecl) string { |
| 1115 | args := make([]string, len(o.ArgTypes())) |
no test coverage detected