Equality operators for TargetMemoryDescriptor and TargetAddressRange

This commit is contained in:
Nav
2021-12-25 01:45:33 +00:00
parent d4a27b1bac
commit 844c7e78ae

View File

@@ -22,6 +22,10 @@ namespace Bloom::Targets
TargetMemoryAddressRange(std::uint32_t startAddress, std::uint32_t endAddress)
: startAddress(startAddress), endAddress(endAddress) {};
bool operator == (const TargetMemoryAddressRange& rhs) const {
return this->startAddress == rhs.startAddress && this->endAddress == rhs.endAddress;
}
[[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const {
return
(other.startAddress <= this->startAddress && other.endAddress >= this->startAddress)
@@ -38,6 +42,10 @@ namespace Bloom::Targets
TargetMemoryDescriptor(TargetMemoryType type, TargetMemoryAddressRange addressRange)
: type(type), addressRange(addressRange) {};
bool operator == (const TargetMemoryDescriptor& rhs) const {
return this->type == rhs.type && this->addressRange == rhs.addressRange;
}
[[nodiscard]] std::uint32_t size() const {
return (this->addressRange.endAddress - this->addressRange.startAddress) + 1;
}