Added address space unit size to MemorySegment and MemorySegmentSection

Some recfactoring
This commit is contained in:
Nav
2024-12-27 01:53:02 +00:00
parent 7aeb2ddf08
commit 00c4cee6c2
11 changed files with 202 additions and 186 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace Targets\TargetDescriptionFiles;
class AddressRange
{
public int $startAddress;
public int $endAddress;
public function __construct(int $startAddress, int $endAddress)
{
$this->startAddress = $startAddress;
$this->endAddress = $endAddress;
}
public function size(): int
{
return $this->endAddress - $this->startAddress + 1;
}
public function contains(AddressRange $other): bool
{
return $this->startAddress <= $other->startAddress && $this->endAddress >= $other->endAddress;
}
public function intersectsWith(AddressRange $other): bool
{
return
($other->startAddress <= $this->startAddress && $other->endAddress >= $this->startAddress)
|| ($other->startAddress >= $this->startAddress && $other->startAddress <= $this->endAddress)
;
}
}