Appearance
| 1 | namespace Syntax.Process is | |
| 2 | // How `a =~ b` compares two present operands, decided from their | |
| 3 | // static types alone. | |
| 4 | // | |
| 5 | // One decision serves every place an equality is built - the | |
| 6 | // operator written in source, the null-safe wrapper around it, a | |
| 7 | // `case` label, and each member of a synthesized `=~` - so that a | |
| 8 | // value compares the same way wherever the comparison is spelled. | |
| 9 | // | |
| 10 | // Nothing compares two of these, so what the synthesized `=~` | |
| 11 | // would make of a field whose type declares none does not arise. | |
| 12 | @suppress("synthesized-equality-fallback") | |
| 13 | union EqualityLowering is | |
| 14 | // An operator that answers equality directly: a `=~` the type | |
| 15 | // declares or inherits, the innate one a scalar, string or enum | |
| 16 | // carries, or a global one taking both operands. | |
| 17 | OPERATOR(function: Semantic.Symbols.Function) | |
| 18 | ||
| 19 | // A `<>` the type declares, read as equality against zero. A | |
| 20 | // type that defines an ordering has defined equality with it. | |
| 21 | ORDER(function: Semantic.Symbols.Function) | |
| 22 | ||
| 23 | // A type that cannot declare an operator - a tuple, or a bare | |
| 24 | // type parameter - compared through `EqualityComparer[T]`. | |
| 25 | COMPARER(comparer_type: Semantic.Types.Type) | |
| 26 | ||
| 27 | // An array or list, compared by count and then element by | |
| 28 | // element, each element by its own lowering. The element type | |
| 29 | // is settled here at the same time, so nesting recurses as far | |
| 30 | // as the static type does and no further. | |
| 31 | SEQUENCE(element_type: Semantic.Types.Type, element: EqualityLowering) | |
| 32 | ||
| 33 | // A class declaring neither operator, compared by reference. | |
| 34 | IDENTITY | |
| 35 | si | |
| 36 | si |