33import com .compilerprogramming .ezlang .types .Symbol ;
44import com .compilerprogramming .ezlang .types .EZType ;
55
6+ import java .util .Objects ;
7+
68public class Operand {
79
810 EZType type ;
@@ -17,6 +19,19 @@ public ConstantOperand(long value, EZType type) {
1719 public String toString () {
1820 return String .valueOf (value );
1921 }
22+
23+ @ Override
24+ public boolean equals (Object o ) {
25+ if (this == o ) return true ;
26+ if (o == null || getClass () != o .getClass ()) return false ;
27+ ConstantOperand that = (ConstantOperand ) o ;
28+ return value == that .value ;
29+ }
30+
31+ @ Override
32+ public int hashCode () {
33+ return Objects .hashCode (value );
34+ }
2035 }
2136
2237 public static class NullConstantOperand extends Operand {
@@ -46,6 +61,19 @@ public RegisterOperand copy(Register register) {
4661 public String toString () {
4762 return reg .name ();
4863 }
64+
65+ @ Override
66+ public boolean equals (Object o ) {
67+ if (this == o ) return true ;
68+ if (o == null || getClass () != o .getClass ()) return false ;
69+ RegisterOperand operand = (RegisterOperand ) o ;
70+ return Objects .equals (reg , operand .reg );
71+ }
72+
73+ @ Override
74+ public int hashCode () {
75+ return Objects .hashCode (reg );
76+ }
4977 }
5078
5179 public static class LocalRegisterOperand extends RegisterOperand {
0 commit comments