From 3e0aebd9a117252bbde647398bef3a1cec341650 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 22 Dec 2021 03:33:54 +0000 Subject: [PATCH] Address range intersection function --- src/Targets/TargetMemory.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Targets/TargetMemory.hpp b/src/Targets/TargetMemory.hpp index c1c212f2..aa5a5084 100644 --- a/src/Targets/TargetMemory.hpp +++ b/src/Targets/TargetMemory.hpp @@ -21,6 +21,13 @@ namespace Bloom::Targets TargetMemoryAddressRange() = default; TargetMemoryAddressRange(std::uint32_t startAddress, std::uint32_t endAddress) : startAddress(startAddress), endAddress(endAddress) {}; + + [[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const { + return + (other.startAddress <= this->startAddress && other.endAddress >= this->startAddress) + || (other.endAddress >= this->endAddress && other.startAddress <= this->endAddress) + ; + } }; struct TargetMemoryDescriptor