(opName string, o *OverloadDecl)
| 1185 | } |
| 1186 | |
| 1187 | func formatOperator(opName string, o *OverloadDecl) string { |
| 1188 | args := o.ArgTypes() |
| 1189 | argTypes := make([]string, len(o.ArgTypes())) |
| 1190 | for j, a := range args { |
| 1191 | argTypes[j] = describeCELType(a) |
| 1192 | } |
| 1193 | ret := describeCELType(o.ResultType()) |
| 1194 | switch len(args) { |
| 1195 | case 1: |
| 1196 | return fmt.Sprintf("%s%s -> %s", opName, argTypes[0], ret) |
| 1197 | case 2: |
| 1198 | if opName == operators.Index { |
| 1199 | return fmt.Sprintf("%s[%s] -> %s", argTypes[0], argTypes[1], ret) |
| 1200 | } |
| 1201 | return fmt.Sprintf("%s %s %s -> %s", argTypes[0], opName, argTypes[1], ret) |
| 1202 | default: |
| 1203 | if opName == operators.Conditional { |
| 1204 | return fmt.Sprint("bool ? <T> : <T> -> <T>") |
| 1205 | } |
| 1206 | return formatCall(opName, o) |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | func formatCall(funcName string, o *OverloadDecl) string { |
| 1211 | args := make([]string, len(o.ArgTypes())) |
no test coverage detected