1 parent d75ba02 commit 2c75fccCopy full SHA for 2c75fcc
1 file changed
src/defs/type.cpp
@@ -0,0 +1,20 @@
1
+#include "type.hpp"
2
+
3
+namespace type {
4
+bool PointerType::equals(const Type &other) const {
5
+ if (other.kind != Kind::Pointer)
6
+ return false;
7
+ const auto &otherPtr = dynamic_cast<const PointerType &>(other);
8
+ if (!to || !otherPtr.to)
9
+ return !to && !otherPtr.to; // Both null or both not null
10
+ if (auto *struct_type = dynamic_cast<const StructType *>(otherPtr.to))
11
+ printf("%p: %s\n", otherPtr.to, struct_type->toString().c_str());
12
+ return to->equals(*otherPtr.to);
13
+}
14
+bool StructType::equals(const Type &other) const {
15
16
+ printf("Struct eq: %s\n", other.toString().c_str());
17
+ return other.kind == Kind::Struct &&
18
+ name == dynamic_cast<const StructType &>(other).name;
19
20
+} // namespace type
0 commit comments