Skip to content
← Back

src/ir/values/equality_comparison.ghul

1
namespace IR.Values is
2
use TypeTyped = Semantic.Types.Typed
3
use Semantic.Types.Type
4
5
// `a =~ b` where both operands are a bare type parameter: no member
6
// operator can resolve statically, so the comparison goes through
7
// `EqualityComparer[T].Default`. That reaches a user-written `=~`
8
// through the synthesized `Equals` bridge where the instantiation
9
// declares one, and the runtime's own comparers give every other
10
// instantiation its natural value equality. A target compiling each
11
// instantiation on its own has no comparer type, and compares as the
12
// type argument does.
13
class EQUALITY_COMPARISON: Value, TypeTyped is
14
left: Value
15
right: Value
16
comparer_type: Type?
17
type: Type
18
19
init(left: Value, right: Value, comparer_type: Type?, type: Type) is
20
super.init()
21
22
self.left = left
23
self.right = right
24
self.comparer_type = comparer_type
25
self.type = type
26
si
27
28
accept(visitor: Visitor) is
29
visitor.visit(self)
30
si
31
32
to_string() -> string =>
33
"equality-comparison[{comparer_type}]({left}, {right})"
34
si
35
si