Added address space unit size to MemorySegment and MemorySegmentSection
Some recfactoring
This commit is contained in:
@@ -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)
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user