Skip to content

Commit 2c75fcc

Browse files
committed
ups
1 parent d75ba02 commit 2c75fcc

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/defs/type.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)